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:



41
42
43
44
45
46
47
48
49
50
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 41

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) ⇒ Object

:nodoc:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 21

def internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: false) # :nodoc:
  if without_prepared_statement?(binds)
    execute_and_free(sql, name, async: async) 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
15
16
17
18
19
# File 'lib/active_record/connection_adapters/mysql2/database_statements.rb', line 8

def select_all(*, **) # :nodoc:
  result = nil
  with_raw_connection do |conn|
    result = if ExplainRegistry.collect? && prepared_statements
      unprepared_statement { super }
    else
      super
    end
    conn.abandon_results!
  end
  result
end