redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

Improve query parameters

Open wiseaidev opened this issue 3 years ago • 2 comments
trafficstars

The current implementation of the find method requires manually passing a table name Customer followed by the name of the column last_name which seems redundant. For instance, the following query:

Customer.find(Customer.last_name == "Brookins").all()

Should be simplified as:

Customer.find(last_name == "Brookins").all()

The find method is already being performed on the Customer table, so no need to specify Customer in the parameter. Not sure about the complexity that this feature will introduce, but, ideally, users should not specify the Customer table in the arguments.

wiseaidev avatar Aug 07 '22 07:08 wiseaidev

think the python interpreter would complain because last_name is not declared anywhere

mpmX avatar Aug 16 '22 15:08 mpmX

I don't think so cause the whole thing within the parenthesis is evaluated as a custom expression:

https://github.com/redis/redis-om-python/blob/60f102d18829b35604bdb5efb3a18679b39d16da/aredis_om/model/model.py#L1188-L1189

It can be customized by changing the left field of the following class:

https://github.com/redis/redis-om-python/blob/60f102d18829b35604bdb5efb3a18679b39d16da/aredis_om/model/model.py#L218-L223

wiseaidev avatar Aug 16 '22 22:08 wiseaidev