Skip to content

Commit 88b73fa

Browse files
committed
Support build_explain_clause(options = [])
This commit implements `build_explain_clause(options = [])` that is no-op to remove the warning below because Oracle Database does not support something like `explain analyze` in MySQL. ```ruby $ bundle exec rspec spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb:356 ==> Loading config from ENV or use default ==> Running specs with ruby version 3.3.5 /home/yahonda/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/bundler/gems/rails-cefd9e9942c5/activesupport/lib/active_support/logger_silence.rb:5: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add logger to your Gemfile or gemspec to silence this warning. ==> Effective ActiveRecord version 7.1.4 Run options: include {:locations=>{"./spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb"=>[356]}} DEPRECATION WARNING: The current database adapter, OracleEnhanced, does not support explain options. To remove this warning, the adapter must implement `build_explain_clause(options = [])`. (called from block (3 levels) in <top (required)> at /home/yahonda/src/github.com/rsim/oracle-enhanced/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb:356) . Finished in 0.50556 seconds (files took 0.54442 seconds to load) 1 example, 0 failures $ ``` Fix #2394 Refer to rails/rails#47043
1 parent 64fe24d commit 88b73fa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def supports_explain?
6565
true
6666
end
6767

68-
def explain(arel, binds = [])
68+
def explain(arel, binds = [], options = [])
6969
sql = "EXPLAIN PLAN FOR #{to_sql(arel, binds)}"
7070
return if /FROM all_/.match?(sql)
7171
if ORACLE_ENHANCED_CONNECTION == :jdbc
@@ -76,6 +76,11 @@ def explain(arel, binds = [])
7676
select_values("SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY)", "EXPLAIN").join("\n")
7777
end
7878

79+
def build_explain_clause(options = [])
80+
# Oracle does not have anything similar to "EXPLAIN ANALYZE"
81+
# https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/EXPLAIN-PLAN.html#GUID-FD540872-4ED3-4936-96A2-362539931BA0
82+
end
83+
7984
# New method in ActiveRecord 3.1
8085
# Will add RETURNING clause in case of trigger generated primary keys
8186
def sql_for_insert(sql, pk, binds, _returning)

0 commit comments

Comments
 (0)