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

Better error message when trying to drop constraints/indexes in a transaction block #99

Merged
merged 8 commits into from
Nov 27, 2018

Conversation

theGOTOguy
Copy link
Contributor

@theGOTOguy theGOTOguy commented Oct 25, 2018

This will fail with an opaque error for all but very trivial databases, so we throw a more meaningful error right away instead of letting this fail at the point of dropping constraints/indexes in order to avoid confusion.

#95

…and throw a useful error instead of letting the copy fail at the point of dropping indices/constraints.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 98.834% when pulling 248c88e on theGOTOguy:better_error into b27230f on california-civic-data-coalition:master.

@theGOTOguy
Copy link
Contributor Author

It turns out that many of your existing tests are predicated on the success of drop_constraints and drop_indexes inside a transaction block because the test databases are simple enough not to break when you do so. Thus, I've patched out the check for your tests.

Note that this may be a breaking change for some users who are using from_csv with very simple databases inside transactions. However, these same users would not be harmed by explicitly adding drop_constraints=False and drop_indexes=False because their performance hit would be insignificant anyway based on the simplicity of their databases.

I suspect, however, that the vast majority of users will never notice this change because they're not doing this in a transaction block and instead just have it in some management command. The benefit is that new users with non-trivial databases will not be confused by the opaque error message psycopg2 throws at you when you try to use drop_constraints or drop_indexes in a transaction block.

@palewire
Copy link
Owner

palewire commented Oct 25, 2018 via email

@theGOTOguy
Copy link
Contributor Author

Sure, I'm not in any rush. If you're not interested in this PR or the other one I added, no problem, I don't take it personally.

@palewire palewire merged commit 68f9985 into palewire:master Nov 27, 2018
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

Successfully merging this pull request may close these issues.

3 participants