DEV: Track SQL queries from MiniSql (#28824)

`track_sql_queries` only returned queries that were executed by
ActiveRecord. All queries executed through DB.exec, DB.query and others
were not returned.
This commit is contained in:
Bianca Nenciu
2024-09-11 10:14:53 +03:00
committed by GitHub
parent 1f1709d249
commit d63ffe22f4
3 changed files with 26 additions and 6 deletions

View File

@ -99,6 +99,16 @@ class MiniSqlMultisiteConnection < MiniSql::ActiveRecordPostgres::Connection
CustomBuilder.new(self, sql)
end
def run(sql, params)
ActiveSupport::Notifications.instrument(
"sql.mini_sql",
sql: sql_fragment(sql, *params),
name: "MiniSql",
)
super
end
def sql_fragment(query, *args)
if args.length > 0
param_encoder.encode(query, *args)