From 5370814337827ca05649d976812d63547d599ac1 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 31 Jan 2025 15:05:42 -0500 Subject: [PATCH] Fix explain test comparisons Explain now returns an object. We need to coerce it into a string for rspec comparisons. https://blog.saeloun.com/2024/11/21/rails-7-2-adds-support-for-explain-method-to-activerecord-relation/ https://github.com/rails/rails/commit/c1ea574b276389e565c38ff0584962afaefdeb2d --- .../oracle_enhanced_adapter_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb b/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb index 25c63d62c..fda442cc2 100644 --- a/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +++ b/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb @@ -354,15 +354,15 @@ class ::TestPost < ActiveRecord::Base it "should explain query" do explain = TestPost.where(id: 1).explain - expect(explain).to include("Cost") - expect(explain).to include("INDEX UNIQUE SCAN") + expect(explain.inspect).to include("Cost") + expect(explain.inspect).to include("INDEX UNIQUE SCAN") end it "should explain query with binds" do binds = [ActiveRecord::Relation::QueryAttribute.new("id", 1, ActiveRecord::Type::OracleEnhanced::Integer.new)] explain = TestPost.where(id: binds).explain - expect(explain).to include("Cost") - expect(explain).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL") + expect(explain.inspect).to include("Cost") + expect(explain.inspect).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL") end end @@ -768,13 +768,13 @@ class ::TestPost < ActiveRecord::Base it "should explain considers hints" do post = TestPost.optimizer_hints("FULL (\"TEST_POSTS\")") post = post.where(id: 1) - expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |") + expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |") end it "should explain considers hints with /*+ */" do post = TestPost.optimizer_hints("/*+ FULL (\"TEST_POSTS\") */") post = post.where(id: 1) - expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |") + expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |") end end