diff --git a/test/cases/sanitize_test.rb b/test/cases/sanitize_test.rb deleted file mode 100644 index 04f60d3a..00000000 --- a/test/cases/sanitize_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "cases/helper_cockroachdb" -require "cases/helper" - -module ActiveRecord - module CockroachDB - class SanitizeTest < ActiveRecord::TestCase - def test_bind_range - quoted_abc = %(#{ActiveRecord::Base.lease_connection.quote('a')},#{ActiveRecord::Base.lease_connection.quote('b')},#{ActiveRecord::Base.lease_connection.quote('c')}) - assert_equal "'0'", bind("?", 0..0) - assert_equal "'1','2','3'", bind("?", 1..3) - assert_equal quoted_abc, bind("?", "a"..."d") - end - - private - - def bind(statement, *vars) - if vars.first.is_a?(Hash) - ActiveRecord::Base.send(:replace_named_bind_variables, statement, vars.first) - else - ActiveRecord::Base.send(:replace_bind_variables, statement, vars) - end - end - end - end -end diff --git a/test/excludes/SanitizeTest.rb b/test/excludes/SanitizeTest.rb index b7ae1d0e..45093bcd 100644 --- a/test/excludes/SanitizeTest.rb +++ b/test/excludes/SanitizeTest.rb @@ -1,4 +1,13 @@ exclude :test_bind_enumerable, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" exclude :test_named_bind_variables, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" exclude :test_sanitize_sql_array_handles_named_bind_variables, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" -exclude :test_bind_range, "This test is overridden for CockroachDB because this adapter adds quotes to numeric values." + +require "support/copy_cat" + +# CRDB quotes ranges, like Trilogy. +CopyCat.copy_methods(self, self, :test_bind_range) do + def on_sym(node) + return unless node in [:sym, :TrilogyAdapter] + replace(node.loc.expression, ":CockroachDBAdapter") + end +end