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

refactor: check that the user-defined table has 1 and only 1 primary … #127

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vvanglro
Copy link
Contributor

Close #123 .

…key.

Update test_meta_errors.py

style: pre-commit

style: pre-commit

fix: test case
@vvanglro
Copy link
Contributor Author

@tarsil Like this?

@tarsil
Copy link
Owner

tarsil commented Jan 17, 2024

Ok, I think I understand what is happening here. I will have a look later. Thank you for submitting the PR @vvanglro 👍🏼

@tarsil
Copy link
Owner

tarsil commented Jan 17, 2024

@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.

@vvanglro
Copy link
Contributor Author

My suggestion would be to release this change as a larger release. For example v1.4.0 or v2.0.0

@tarsil
Copy link
Owner

tarsil commented Jan 17, 2024

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?

@vvanglro
Copy link
Contributor Author

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.

@tarsil
Copy link
Owner

tarsil commented Jan 17, 2024

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.

@tarsil tarsil added the On Hold label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

About automatically adding the id field as the primary key.
2 participants