Skip to content
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

Truncation failure with CockroachDB #54

Open
agaffney opened this issue Feb 17, 2021 · 2 comments
Open

Truncation failure with CockroachDB #54

agaffney opened this issue Feb 17, 2021 · 2 comments

Comments

@agaffney
Copy link

DatabaseCleaner treats CockroachDB as PostgreSQL (which makes sense because CockroachDB emulated PostgreSQL to some extent). It uses the RESTART IDENTITY clause in the TRUNCATE TABLE query, which isn't supported by CockroachDB. There should probably be separate handling for CockroachDB that doesn't use that clause, and perhaps runs a separate query to reset the auto-increment counter.

@botandrose
Copy link
Contributor

Hi @agaffney, thanks for the issue. We don't currently support CockroachDB in this adapter, but I'm certainly open to supporting it in one way or another! The question is what that should look like. Does it look like adding support (code and tests) to this repo, or does it look like creating a new adapter for database_cleaner, or maybe even generalizing the code in this adapter to leverage AR's built-in abilities to abstract across various DBs? Thoughts?

@agaffney
Copy link
Author

I do not have a suggested course of action here. This is just something I ran into while testing moving a Rails app from PostgreSQL to CockroachDB.

I was able to work around the issue by manually removing the RESTART IDENTITY part of the query, but that seemed to cause some issues with our spec tests, because they expect the ID column's value to get reset between tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants