-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
refactor: check that the user-defined table has 1 and only 1 primary … #127
base: main
Are you sure you want to change the base?
Conversation
…key. Update test_meta_errors.py style: pre-commit style: pre-commit fix: test case
@tarsil Like this? |
Ok, I think I understand what is happening here. I will have a look later. Thank you for submitting the PR @vvanglro 👍🏼 |
@vvanglro although your change is great my concern is for the people already using Saffier as this will break the existing codebase. The purpose of automatically generate the primary key is for you not to worry about declaring it. Pretty much like Django does and this change will force everyone to add an ID into the existing codebase. |
My suggestion would be to release this change as a larger release. For example v1.4.0 or v2.0.0 |
I need to think about this honestly since this can cause a world of trouble and people can simply stop using it because of it. Very unlikely but it’s a possibility. Another thing that should be added if we proceed with this step is to add a warning or several in the docs explaining that prior to version 2.0.0 (not v2.0.0), the ID was automatically added by Saffier but from the release 2.0.0 that will be managed by the user providing more control and freedom over the primary keys. This should probably be included in this PR too. Something like this if this make sense? |
Yes, this also fixes the bug that would report multiple primary keys if the user-defined primary key field had a name other than id. You can add deprecated auto-add primary key field warnings to subsequent 1.x releases to transition to version 2.x. Until you think you can release 2.0. |
The deprecation warning should definitely be added but the AutoMixin happens when the ID is an integer. @vvanglro what I would love to see it tested here since you changed is some tests proving that you can add different primary keys with different names and types (based on what you are trying to solve)? If that is ok and passing + current tests, then I will proceed with initial pre-releases of Saffier with the warnings before merging this and do the big release. |
Signed-off-by: vvanglro <[email protected]>
Close #123 .