-
Notifications
You must be signed in to change notification settings - Fork 240
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
Fix truncate not actually truncating #909
base: master
Are you sure you want to change the base?
Conversation
This fixes an issue that causes postgres database to not actually truncate.
Thanks for this PR! |
Sounds good. Thanks for your quick response! With regards to the 'restart identity'; yes, looking at your given link, Rails does not do that either. Looking at the postgres docs it's not the default behavior either. I come from MySQL, where that is the expected behavior, hence the confusion. That does not take away that there should probably be an easy way to truncate with an increment-reset and that it makes testing and asserting (or cleaning up before/after tests) a lot easier (if it does reset). It makes for better cleanup and feels like that should be expected behavior while running multiple tests. |
you're right. |
@jondot I've changed the hardcoded query string to a sea_query built string. |
This fixes an issue that causes postgres database to not actually truncate, so Id column auto-increment does not get reset to 1 and new models continue to use Id from existing increment.
This truncate query is actually faster and this fixes an issue where some tests fail (when using postgres db) because snapshot thinks new entities should have Id 1 when they do not.
Now, I'm very new to both Rust and Loco, so please inspect this code carefully and make sure I haven't done anything stupid.