Jaymon / prom

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

break up isetter to iupdate and icreate #45

Closed Jaymon closed 6 years ago

Jaymon commented 7 years ago

It would just be easier if all the methods had the very same interface, in this case you get passed the value and then you return a value, right now I have to lookup isetter everytime I want to use it because this is the definition:

@foo.isetter
def foo(cls, val, is_update, is_modified)

I would also just like to make this whole interface better and easier to use, I ran into an issue the other day with this method being called with val=None when it wasn't actually getting set, which broke the principal of expectation, so I just think the whole interface can be cleaned up a bit, maybe have an inochange or something like that method also.

Jaymon commented 7 years ago

also add an idefault method, or maybe better an fdefault method since iinsert would be the better default method for adding to the db

Jaymon commented 7 years ago

I think we should add ijsonable also and get rid of Orm.jsonable_field

Jaymon commented 6 years ago

So, in the grand tradition of having to relearn old lessons, I now know why things were setup the way they were initially.

having an update and insert is kind of annoying actually in practice, and a quick audit of all the times I used isetter it seems like it is far more common for me wanting to set a value if a value isn't there, which means you have to include is_modified, though I can get rid of is_update I think when you want to hit both of them it's less annoying just to do isetter than having to add both insert and update.

isetter was a classmethod, I have moved thatinto having an instance, but the reason why it was a class method was so it could be called from query outside of the Orm, I can't decide if this is expected behavior or not. On the one hand, it's nice to be able to have fields like _created and _updated set automatically even when you are building the query outside of the Orm, but on the other hand it's strange that all the f* methods are meant to live within the realm of an instance but the i* methods are meant to be called on a class, that feels unexpected to me. However, switching to instances means #46 is basically impossible.