Skip to content

Commit

Permalink
Merge pull request #185 from dlanileonardo/master
Browse files Browse the repository at this point in the history
Fix: Adjust wrong number of arguments
  • Loading branch information
omohokcoj authored Nov 30, 2024
2 parents b3262d9 + adfb23f commit 40d2c25
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/motor/queries/run_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def execute_query(query, limit, variables_hash, filters)
when 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
PostgresqlExecQuery.call(connection_class.connection, statement)
else
statement = normalize_statement_for_sql(statement)
statement = normalize_statement_for_sql(connection_class.connection, statement)

connection_class.connection.exec_query(*statement)
end
Expand Down Expand Up @@ -219,12 +219,12 @@ def fetch_query_data(variable_name)

# @param array [Array]
# @return [Array]
def normalize_statement_for_sql(statement)
def normalize_statement_for_sql(conn, statement)
sql, _, attributes = statement

sql = ActiveRecord::Base.send(:replace_bind_variables,
sql.gsub(STATEMENT_VARIABLE_REGEXP, '?'),
attributes.map(&:value))
params = [sql.gsub(STATEMENT_VARIABLE_REGEXP, '?'), attributes.map(&:value)]
params.unshift(conn) if Rails.version.to_f >= 7.2
sql = ActiveRecord::Base.send(:replace_bind_variables, *params)

[sql, 'SQL', []]
end
Expand Down

0 comments on commit 40d2c25

Please sign in to comment.