Jaymon / prom

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

Orm.pool() method improvements #50

Closed Jaymon closed 6 years ago

Jaymon commented 7 years ago

it would be cool to treat this method differently depending on if it was called with a class or an instance of the class

so, if it was called with just the class then nothing would change, but, if it is called with an instance then the Pool instance will have that instance already in its cache:

class Foo(Orm): pass

Foo.pool() # nothing changes, it returns an empty Pool instance

f = Foo.create()
f.pool() # the Pool instance contains f instance at f.pk
Jaymon commented 6 years ago

this might not be worth doing since if the Orm instance doesn't have a pk then it can't be put into the OrmPool instance, and I'm not sure I want this method to return 3 different states to save one query