method
perform_query
v8.1.1 -
Show latest stable
-
0 notes -
Class: DatabaseStatements
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- 7.2.3
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notification_payload:, batch: false)
private
Hide source
# File activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb, line 86 def perform_query(raw_connection, sql, binds, type_casted_binds, prepare,, notification_payload,, batch: false) total_changes_before_query = raw_connection.total_changes affected_rows = nil if batch raw_connection.execute_batch2(sql) else stmt = if prepare @statements[sql] ||= raw_connection.prepare(sql) @statements[sql].reset! else # Don't cache statements if they are not prepared. raw_connection.prepare(sql) end begin unless binds.nil? || binds.empty? stmt.bind_params(type_casted_binds) end result = if stmt.column_count.zero? # No return stmt.step affected_rows = if raw_connection.total_changes > total_changes_before_query raw_connection.changes else 0 end ActiveRecord::Result.empty(affected_rows: affected_rows) else rows = stmt.to_a affected_rows = if raw_connection.total_changes > total_changes_before_query raw_connection.changes else 0 end ActiveRecord::Result.new(stmt.columns, rows, stmt.types.map { |t| type_map.lookup(t) }, affected_rows: affected_rows) end ensure stmt.close unless prepare end end verified! notification_payload[:affected_rows] = affected_rows notification_payload[:row_count] = result&.length || 0 result end

