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

Making Orm.save() more robust #119

Closed
Jaymon opened this issue Sep 23, 2020 · 1 comment
Closed

Making Orm.save() more robust #119

Jaymon opened this issue Sep 23, 2020 · 1 comment

Comments

@Jaymon
Copy link
Owner

Jaymon commented Sep 23, 2020

We have a version of save that's like this:

    def save(self):
        try:
            super(Orm, self).save()

        except UniqueError as e:
            pk_name = self.schema.pk_name
            if pk_name and (pk_name in self.modified_fields):
                self.update()

            else:
                raise

It would be great to have a more robust version, that catches the unique error, pulls out the fields, then sets those fields in a where portion of a Query and tries the update.

@Jaymon
Copy link
Owner Author

Jaymon commented Mar 11, 2023

I think this is no longer needed since there is now Orm.upsert

@Jaymon Jaymon closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant