Module: ActiveRecord::ConnectionAdapters::Kudu::DatabaseStatements

Included in:
ActiveRecord::ConnectionAdapters::KuduAdapter
Defined in:
lib/active_record/connection_adapters/kudu/database_statements.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#exec_delete(sql, name, binds) ⇒ Object



27
28
29
30
31
# File 'lib/active_record/connection_adapters/kudu/database_statements.rb', line 27

def exec_delete(sql, name, binds)
  # We are not able to return number of affected rows so we will just say that there was some update
  super
  1
end

#exec_query(sql, _ = 'SQL', binds = [], prepare: false) ⇒ Object

:nodoc:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_record/connection_adapters/kudu/database_statements.rb', line 11

def exec_query(sql, _ = 'SQL', binds = [], prepare: false)
  ::Rails.logger.warn 'Prepared statements are not supported' if prepare

  unless without_prepared_statement? binds
    type_casted_binds(binds).each do |bind|
      bind = quote(bind)
      sql = sql.sub('?', bind.to_s)
    end
  end
  #::Rails.logger.info 'QUERY : ' + sql.to_s
  result = connection.query sql
  columns = result.first&.keys.to_a
  rows = result.map { |row| row.fetch_values(*columns) }
  ::ActiveRecord::Result.new(columns.map(&:to_s), rows)
end

#exec_update(sql, name, binds) ⇒ Object



33
34
35
36
37
# File 'lib/active_record/connection_adapters/kudu/database_statements.rb', line 33

def exec_update(sql, name, binds)
  # We are not able to return number of affected rows so we will just say that there was some update
  super
  1
end