activerecord-cockroachdb-adapter
activerecord-cockroachdb-adapter copied to clipboard
[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/explain_test.rb
Error:
PostgreSQLExplainTest#test_explain_with_eager_loading:
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: foreign key violation: "authors" row author_address_id=1, id=1 has no match in "author_addresses"
: ALTER TABLE "authors" ADD CONSTRAINT "fk_rails_94423a17a3"
FOREIGN KEY ("author_address_id")
REFERENCES "author_addresses" ("id")
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
/Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
/Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
/Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb:25:in `block in disable_referential_integrity'
/Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb:23:in `each'
/Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb:23:in `disable_referential_integrity'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:391:in `insert_fixtures_set'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:566:in `block in create_fixtures'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:558:in `each'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:558:in `create_fixtures'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1031:in `load_fixtures'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:968:in `setup_fixtures'
/Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:860:in `before_setup'
bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/explain_test.rb:16
PostgreSQLExplainTest#test_explain_for_one_query [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/explain_test.rb:13]:
Expected /QUERY\ PLAN/ to match EXPLAIN for: SELECT "authors".* FROM "authors" WHERE "authors"."id" = $1 [["id", 1]]
tree
------
scan
(5 rows)
.
bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/explain_test.rb:10
See the Contributing Guide for instructions on running tests.
If the test isn't valid against CockroachDB
- Add a ruby file to
test/excludesthat matches the name of the test class if one doesn't already exist. For example to exclude a test fromActiveRecord::AdapterTest, createtest/excludes/ActiveRecord/AdapterTest.rb. - Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude
test_indexesfromActiveRecord::AdapterTest: https://github.com/cockroachdb/activerecord-cockroachdb-adapter/blob/c3cb637bd855b36bbf9e76b7947162054b95022e/test/excludes/ActiveRecord/AdapterTest.rb#L1 - Finally, if the test can run against CockroachDB with a few changes, add it to
test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under theCockroachDBmodule to avoid name collisions. Seetest/cases/adapter_test.rbfor an example.
See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48.