Jaymon / prom

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

save() when you set the primary key #117

Closed Jaymon closed 1 year ago

Jaymon commented 4 years ago

It's become a common workflow for me to set the primary key, and so I've had to change multiple orm's to do something like this:

from prom.exception import UniqueError

def save(self):
    try:
        super(Foo, self).save()
    except UniqueError:
        self.update()

I think .save() should probably just automatically do this, and for the times I want specific error handling I can call .insert() or .update() manually.

Jaymon commented 2 years ago

https://github.com/Jaymon/prom/issues/119

Jaymon commented 1 year ago

I think this is handled by Orm.upsert