Jaymon / prom

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

Query.or_field #110

Closed Jaymon closed 1 year ago

Jaymon commented 4 years ago

Ran into this the other day, I needed to check <FIELD_NAME> IS NULL OR <FIELD_NAME> >= ?.

A good syntax for this would be:

Foo.query.or_bar("<VALUE_1>", "<VALUE_2>")

Which would result in:

(bar = '<VALUE_1>' OR bar = '<VALUE_2>')

But that can also just be done with in, and I need support for other operators, I've thought about something like:

Foo.query.or_bar(
    Foo.query.is_bar("<VALUE_1>"),
    Foo.query.gte_bar("<VALUE_2>")
)

Which works but is verbose. The queries passed into the or_bar method would only have their where_fields used.