Module: ActiveRecord::ConnectionAdapters::DatabaseStatements
- Included in:
- CrateAdapter
- Defined in:
- lib/active_record/connection_adapters/crate/database_statements.rb
Instance Method Summary collapse
- #do_exec_query(sql, name, binds) ⇒ Object
- #exec_query(sql, name = 'SQL', binds = []) ⇒ Object
-
#execute(sql, name = nil) ⇒ Object
Executes an SQL statement, returning a ResultSet object on success or raising a CrateError exception otherwise.
-
#sql_key(sql) ⇒ Object
Returns the statement identifier for the client side cache of statements.
Instance Method Details
#do_exec_query(sql, name, binds) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_record/connection_adapters/crate/database_statements.rb', line 34 def do_exec_query(sql, name, binds) params = [] binds.each_with_index do |(column, value), index| ar_column = column.is_a?(ActiveRecord::ConnectionAdapters::Column) # only quote where clause values unless ar_column # && column.sql_type == 'timestamp' v = value quoted_value = ar_column ? quote(v, column) : quote(v, nil) params << quoted_value else params << value end end @connection.execute sql, params end |
#exec_query(sql, name = 'SQL', binds = []) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/active_record/connection_adapters/crate/database_statements.rb', line 25 def exec_query(sql, name = 'SQL', binds = []) result = nil log(sql, name, binds) { result = do_exec_query(sql, name, binds) } fields = result.cols ActiveRecord::Result.new(fields, result.values) end |
#execute(sql, name = nil) ⇒ Object
Executes an SQL statement, returning a ResultSet object on success or raising a CrateError exception otherwise.
59 60 61 62 63 |
# File 'lib/active_record/connection_adapters/crate/database_statements.rb', line 59 def execute(sql, name = nil) log(sql, name) do @connection.execute(sql) end end |
#sql_key(sql) ⇒ Object
Returns the statement identifier for the client side cache of statements
53 54 55 |
# File 'lib/active_record/connection_adapters/crate/database_statements.rb', line 53 def sql_key(sql) sql end |