-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
IntegrityError with unique field and get_or_create #140
Comments
Hi I tried running your example (though I had to modify it, because it was out of context) and could not reproduce it. Could you give me some more details on problem (like stacktrace of error) and some info about how Would be best if you could concatenate all your code in one file (like files in examples), so I could reproduce error exactly as you have it. |
Please find files attached. |
Okay, so I see the problem now. Issue there that Even though I wouldn't say it is bug, but it is certainly undesired behaviour. Will fix it now |
Thank you! |
Seems like it will take more time than I thought because I encountered concurrency issues on other db backends apart from sqlite Apart from the fix from our side - your current solution with handling IntegrityError should work fine, only problem with it is that you should have such handler on each |
@abondar The base framework is in place, so we could check and/or re-implement the fix? |
Did you use naive or timezone aware dates? This might be the MRE #1556 |
Describe the bug
Hi!
First of all thank you for developing such useful ORM.
I am not sure that this is really bug, maybe I am doing something wrong.
I get IntegrityError with fields having unique=True and using get_or_create.
To Reproduce
Models.py is:
I have file for generating schemas:
And file with main pipeline (some code is excluded as irrelevant):
I get following errors when I run script with empty DB:
sqlite3.IntegrityError: UNIQUE constraint failed: checkdates.check_date
and
sqlite3.IntegrityError: UNIQUE constraint failed: results.date_id, results.project_id, results.suspicious_url
but all data is saved (well, I hope it is).
And no errors if date is already in DB.
Expected behavior
No error messages.
Additional context
So this might be a bug if I'm doing it right.
The text was updated successfully, but these errors were encountered: