diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index 1d74648a..672b18da 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -213,3 +213,10 @@ def header(stream) end ActiveRecord::SchemaDumper.prepend(NoHeaderExt) + +# CRDB does not support ALTER COLUMN TYPE inside a transaction +# NOTE: This would be better in an exclude test, however this base +# class is used by a lot of inherited tests. We repeat less here. +class BaseCompatibilityTest < ActiveRecord::TestCase + self.use_transactional_tests = false +end diff --git a/test/cases/migration/compatibility_test.rb b/test/cases/migration/compatibility_test.rb deleted file mode 100644 index 282c7f84..00000000 --- a/test/cases/migration/compatibility_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require "cases/helper_cockroachdb" -require "support/copy_cat" - -module ActiveRecord - module CockroachDB - class Migration - class CompatibilityTest < ActiveRecord::Migration::CompatibilityTest - CopyCat.copy_methods(self, ActiveRecord::Migration::CompatibilityTest, - :test_add_index_errors_on_too_long_name_7_0, - :test_create_table_add_index_errors_on_too_long_name_7_0 - ) do - def on_sym(node) - return unless node.children[0] == :very_long_column_name_to_test_with - - insert_after(node.loc.expression, "_and_actually_way_longer_because_cockroach_is_in_the_128_game") - end - end - end - end - end -end diff --git a/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb b/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb index 86f19ac9..fc038b19 100644 --- a/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb +++ b/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb @@ -21,7 +21,7 @@ exclude :test_pk_and_sequence_for_with_non_standard_primary_key, "The test needs a little rework since the sequence is empty in CRDB" # NOTE: The expression `do $$ BEGIN RAISE WARNING 'foo'; END; $$` works with PG, not CRDB. -plpgsql_needed = "PL-PGSQL differs in CockroachDB. Not tested yet." +plpgsql_needed = "PL-PGSQL differs in CockroachDB. Not tested yet. See #339" exclude :test_ignores_warnings_when_behaviour_ignore, plpgsql_needed exclude :test_logs_warnings_when_behaviour_log, plpgsql_needed exclude :test_raises_warnings_when_behaviour_raise, plpgsql_needed diff --git a/test/excludes/ActiveRecord/Migration/CompatibilityTest.rb b/test/excludes/ActiveRecord/Migration/CompatibilityTest.rb index 53dbc57a..aecd68fd 100644 --- a/test/excludes/ActiveRecord/Migration/CompatibilityTest.rb +++ b/test/excludes/ActiveRecord/Migration/CompatibilityTest.rb @@ -1,8 +1,19 @@ exclude :test_legacy_change_column_with_null_executes_update, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" exclude :test_legacy_add_foreign_key_with_deferrable_true, "CRDB does not support DEFERRABLE constraints" exclude :test_disable_extension_on_7_0, "CRDB does not support enabling/disabling extensions." -# CRDB does not support ALTER COLUMN TYPE inside a transaction -BaseCompatibilityTest.descendants.each { _1.use_transactional_tests = false } -exclude :test_add_index_errors_on_too_long_name_7_0, "The max length in CRDB is 128, not 64." -exclude :test_create_table_add_index_errors_on_too_long_name_7_0, "The max length in CRDB is 128, not 64." +# exclude :test_add_index_errors_on_too_long_name_7_0, "The max length in CRDB is 128, not 64." +# exclude :test_create_table_add_index_errors_on_too_long_name_7_0, "The max length in CRDB is 128, not 64." + +require "support/copy_cat" + +CopyCat.copy_methods(self, self, + :test_add_index_errors_on_too_long_name_7_0, + :test_create_table_add_index_errors_on_too_long_name_7_0 +) do + def on_sym(node) + return unless node.children[0] == :very_long_column_name_to_test_with + + insert_after(node.loc.expression, "_and_actually_way_longer_because_cockroach_is_in_the_128_game") + end +end