Jaymon / prom

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

Query should run values through isetter also #46

Closed Jaymon closed 3 years ago

Jaymon commented 7 years ago

I'm not sure if it does this or not, but Query should run values through the isetter method also before it runs the query, that way if you have a mapping from String to int in the isetter methods, say something like:

mapping = {
    "foo": 1,
}

Then doing something like:

MyOrm.query.is_name("foo")

the "foo" value would be converted to 1 before running the query.

Jaymon commented 6 years ago

I think I can add a classmethod Field.iwhere that can be called anytime a field is set in the query. What I don't like about this is it might couple Query and Orm too tightly again and I just got finished uncoupling them

Jaymon commented 3 years ago

This was solved with the Field.iquery(query, v) method that gets run everytime a field is set in a query. The reason why this had to be a different method than Field.iset is because the iset method takes an orm instance and the Query instance often doesn't have an orm instance to pass to the iset method.