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

UUIDPrimaryKeyMixin not working with SQLite #453

Closed
floriankick opened this issue May 7, 2021 · 4 comments · Fixed by #454
Closed

UUIDPrimaryKeyMixin not working with SQLite #453

floriankick opened this issue May 7, 2021 · 4 comments · Fixed by #454
Labels
bug An existing feature is not working as intended

Comments

@floriankick
Copy link

Describe the bug
The UUIDPrimaryKeyMixin ist not working properly with SQLite.
When creating a Model, the UUID is generated and saved correctly in the database, but the models id is set to the rowid instead of the actual uuid.

To Reproduce
Steps to reproduce the behavior:

  1. Setup project using SQLite database
  2. Create Model with UUIDPrimaryKeyMixin
  3. Save new record by calling create() function, without providing a value for the id field:
    project = Project.create({'label': name})
  4. Access the id field:
    new_id = project.id
  5. It will be some integer value

Expected behavior
The id field of the model should be set to the UUID value that was saved to the database.

What database are you using?

  • Type: SQLite
  • Version: 3.34.0
  • Masonite ORM: 1.0.46

Additional context
I traced the problem down to the SQLitePostProcessor.
It returns the lastrowid in process_insert_get_id():

    def process_insert_get_id(self, builder, results, id_key="id"):
        # [...]

        results.update({id_key: builder.get_connection().get_cursor().lastrowid})

        return results
@floriankick floriankick added the bug An existing feature is not working as intended label May 7, 2021
@floriankick
Copy link
Author

Just saw, that the implementation for MySQL is the same. Maybe the bug occurs there as well.

@josephmancuso
Copy link
Member

@floriankick yeah it looks like this was missed when we implemented the post processor. Thanks for reporting it, we will take a look

@girardinsamuel @Marlysson

@josephmancuso
Copy link
Member

Just a thought we need to explore but maybe we can do this via registering an observer in the UUIDPrimaryKeyMixin

@josephmancuso
Copy link
Member

@floriankick This is fixed with version 1.0.47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants