Module: ActiveRecord::ConnectionAdapters::Cubrid2::DatabaseStatements
- Included in:
- ActiveRecord::ConnectionAdapters::Cubrid2Adapter
- Defined in:
- lib/active_record/connection_adapters/cubrid2/database_statements.rb
Instance Method Summary collapse
- #exec_delete(sql, name = nil, binds = []) ⇒ Object (also: #exec_update)
- #exec_query(sql, name = 'SQL', binds = [], prepare: false) ⇒ Object
-
#execute(sql, name = nil) ⇒ Object
Executes the SQL statement in the context of this connection.
-
#query(sql, name = nil) ⇒ Object
:nodoc:.
-
#query_value(sql, name = nil) ⇒ Object
:nodoc:.
-
#query_values(sql, name = nil) ⇒ Object
:nodoc:.
-
#select_all(*param1, **param2) ⇒ Object
Returns an ActiveRecord::Result instance.
-
#write_query?(sql) ⇒ Boolean
:nodoc:.
Instance Method Details
#exec_delete(sql, name = nil, binds = []) ⇒ Object Also known as: exec_update
63 64 65 66 67 68 69 70 71 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 63 def exec_delete(sql, name = nil, binds = []) if without_prepared_statement?(binds) @lock.synchronize do execute_and_free(sql, name) { |stmt| stmt.affected_rows } end else exec_stmt_and_free(sql, name, binds) { |stmt| stmt.affected_rows } end end |
#exec_query(sql, name = 'SQL', binds = [], prepare: false) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 51 def exec_query(sql, name = 'SQL', binds = [], prepare: false) if without_prepared_statement?(binds) execute_and_free(sql, name) do |result| _build_stmt_result(result) end else exec_stmt_and_free(sql, name, binds, cache_stmt: prepare) do |_, result| _build_stmt_result(result) end end end |
#execute(sql, name = nil) ⇒ Object
Executes the SQL statement in the context of this connection.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 39 def execute(sql, name = nil) if preventing_writes? && write_query?(sql) raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}" end # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been # made since we established the connection # @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone # @connection.query_options[:database_timezone] = ActiveRecord.default_timezone super end |
#query(sql, name = nil) ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 16 def query(sql, name = nil) # :nodoc: execute(sql, name) end |
#query_value(sql, name = nil) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 25 def query_value(sql, name = nil) # :nodoc: _single_value_from_rows(query(sql, name)) end |
#query_values(sql, name = nil) ⇒ Object
:nodoc:
20 21 22 23 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 20 def query_values(sql, name = nil) # :nodoc: res = exec_query(sql, name) res&.rows&.map(&:first) end |
#select_all(*param1, **param2) ⇒ Object
Returns an ActiveRecord::Result instance.
8 9 10 11 12 13 14 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 8 def select_all(*param1, **param2) # :nodoc: if ExplainRegistry.collect? && prepared_statements unprepared_statement { super } else super end end |
#write_query?(sql) ⇒ Boolean
:nodoc:
34 35 36 |
# File 'lib/active_record/connection_adapters/cubrid2/database_statements.rb', line 34 def write_query?(sql) # :nodoc: !READ_QUERY.match?(sql) end |