Module: ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements

Included in:
ActiveRecord::ConnectionAdapters::Mysql2Adapter
Defined in:
lib/active_record/connection_adapters/mysql2/database_statements.rb

Instance Method Summary collapse

Instance Method Details

#exec_delete(sql, name = nil, binds = []) ⇒ Object Also known as: exec_update

:nodoc:



36
37
38
39
40
41
42
43
44
45
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 36

def exec_delete(sql, name = nil, binds = []) # :nodoc:
  if without_prepared_statement?(binds)
    with_raw_connection do |conn|
      @affected_rows_before_warnings = nil
      execute_and_free(sql, name) { @affected_rows_before_warnings || conn.affected_rows }
    end
  else
    exec_stmt_and_free(sql, name, binds) { |stmt| stmt.affected_rows }
  end
end

#internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: false, allow_retry: false) ⇒ Object

:nodoc:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 16

def internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: false, allow_retry: false) # :nodoc:
  if without_prepared_statement?(binds)
    execute_and_free(sql, name, async: async, allow_retry: allow_retry) do |result|
      if result
        build_result(columns: result.fields, rows: result.to_a)
      else
        build_result(columns: [], rows: [])
      end
    end
  else
    exec_stmt_and_free(sql, name, binds, cache_stmt: prepare, async: async) do |_, result|
      if result
        build_result(columns: result.fields, rows: result.to_a)
      else
        build_result(columns: [], rows: [])
      end
    end
  end
end

#select_allObject

Returns an ActiveRecord::Result instance.



8
9
10
11
12
13
14
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 8

def select_all(*, **) # :nodoc:
  if ExplainRegistry.collect? && prepared_statements
    unprepared_statement { super }
  else
    super
  end
end