Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Making Orm.save() more robust #119

Closed Jaymon closed 1 year ago

Jaymon commented 3 years ago

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 commented 1 year ago

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