-
Notifications
You must be signed in to change notification settings - Fork 53
chore: faster referential integrity for tests #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0e5baae to
945c57c
Compare
945c57c to
6afe199
Compare
|
|
||
| # This overrides the method from PostegreSQL adapter | ||
| # Resets the sequence of a table's primary key to the maximum value. | ||
| def reset_pk_sequence!(table, pk = nil, sequence = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the difference lied in a condition database_version < 10, which will never be true in our codebase!
| options[:deferrable] = extract_constraint_deferrable(row["deferrable"], row["deferred"]) | ||
|
|
||
| options[:validate] = row["valid"] | ||
| to_table = PostgreSQL::Utils.unquote_identifier(row["to_table"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already done a few lines ago
| # Normally, the primary keys would use CockroachDB's unique_rowid(). | ||
| def test_create_symbol_fixtures | ||
| fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, :collections, collections: Course) { Course.lease_connection } | ||
| fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, :collections, collections: Course) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mimicking upstream change
rafiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really great speedup, thank you! Also, the new debugging functions look very useful.
Improve performance of the
#disable_referential_integrityby fetching every foreign keys at once. This method is where most time is spent in tests, hence this PR helps dividing by 3 our test suite time.