Skip to content

Commit 2c25eb3

Browse files
authored
Fix EXPLAIN queries (#1076)
1 parent 7bfce52 commit 2c25eb3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ module Explain
88
SQLSERVER_STATEMENT_PREFIX = "EXEC sp_executesql "
99
SQLSERVER_STATEMENT_REGEXP = /N'(.+)', N'(.+)', (.+)/
1010

11-
def exec_explain(queries)
11+
def exec_explain(queries, options = [])
1212
return super unless connection.adapter_name == "SQLServer"
1313

1414
unprepared_queries = queries.map do |(sql, binds)|
1515
[unprepare_sqlserver_statement(sql, binds), binds]
1616
end
17-
super(unprepared_queries)
17+
super(unprepared_queries, options)
1818
end
1919

2020
private
2121

22-
# This is somewhat hacky, but it should reliably reformat our prepared sql statment
22+
# This is somewhat hacky, but it should reliably reformat our prepared sql statement
2323
# which uses sp_executesql to just the first argument, then unquote it. Likewise our
24-
# `sp_executesql` method should substitude the @n args with the quoted values.
24+
# `sp_executesql` method should substitute the @n args with the quoted values.
2525
def unprepare_sqlserver_statement(sql, binds)
2626
return sql unless sql.start_with?(SQLSERVER_STATEMENT_PREFIX)
2727

lib/active_record/connection_adapters/sqlserver/showplan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Showplan
1212
OPTION_XML = "SHOWPLAN_XML"
1313
OPTIONS = [OPTION_ALL, OPTION_TEXT, OPTION_XML]
1414

15-
def explain(arel, binds = [])
15+
def explain(arel, binds = [], options = [])
1616
sql = to_sql(arel)
1717
result = with_showplan_on { sp_executesql(sql, "EXPLAIN", binds) }
1818
printer = showplan_printer.new(result)

0 commit comments

Comments
 (0)