Module: BigQueryAdapter::DatabaseStatements
- Included in:
- ActiveRecord::ConnectionAdapters::BigQueryAdapter
- Defined in:
- lib/big_query_adapter/database_statements.rb
Overview
Includes helper methods
Constant Summary collapse
- NATIVE_DATABASE_TYPES =
{ boolean: { name: 'BOOL' }, integer: { name: 'INTEGER' }, float: { name: 'FLOAT' }, string: { name: 'STRING' }, datetime: { name: 'DATETIME' }, date: { name: 'DATE' }, timestamp: { name: 'TIMESTAMP' }, time: { name: 'TIME' } }.freeze
Instance Method Summary collapse
-
#exec_query(sql, name = 'SQL', _binds = [], prepare: false) ⇒ Object
Executes
sql
statement in the context of this connection usingbinds
as the bind substitutes. -
#execute(sql, name = nil, _binds = []) ⇒ Object
Executes the SQL statement in the context of this connection.
- #native_database_types ⇒ Object
-
#supports_ddl_transactions ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
-
#valid_type?(type) ⇒ Boolean
:nodoc:.
Instance Method Details
#exec_query(sql, name = 'SQL', _binds = [], prepare: false) ⇒ Object
Executes sql
statement in the context of this connection using binds
as the bind substitutes. name
is logged along with the executed sql
statement. rubocop:disable Lint/UnusedMethodArgument
35 36 37 38 39 40 |
# File 'lib/big_query_adapter/database_statements.rb', line 35 def exec_query(sql, name = 'SQL', _binds = [], prepare: false) log(sql, name) do result = @connection.run(sql) ActiveRecord::Result.new(result.columns, result.rows) end end |
#execute(sql, name = nil, _binds = []) ⇒ Object
Executes the SQL statement in the context of this connection. Returns the number of rows affected.
25 26 27 28 29 |
# File 'lib/big_query_adapter/database_statements.rb', line 25 def execute(sql, name = nil, _binds = []) log(sql, name) do @connection.do(sql) end end |
#native_database_types ⇒ Object
15 16 17 |
# File 'lib/big_query_adapter/database_statements.rb', line 15 def native_database_types NATIVE_DATABASE_TYPES end |
#supports_ddl_transactions ⇒ Object
rubocop:enable Lint/UnusedMethodArgument
43 44 45 |
# File 'lib/big_query_adapter/database_statements.rb', line 43 def supports_ddl_transactions false end |
#valid_type?(type) ⇒ Boolean
:nodoc:
19 20 21 |
# File 'lib/big_query_adapter/database_statements.rb', line 19 def valid_type?(type) # :nodoc: !native_database_types[type].nil? end |