eve-sqlalchemy
eve-sqlalchemy copied to clipboard
Feature request: Compare two fields instead of field-value pairs
Imagine a Job
model that has fields total_tasks
and done_tasks
. With Eve it is possible to query for those jobs which total_tasks
are smaller than a number:
Either job?where=total_tasks<100
.
Or job?where={"total_tasks":"<\"100\""}
.
But I cannot ask for running jobs (i.e., those that done_tasks != total_tasks
) because, AFAIK. there is no way to set a field (total_tasks
) instead of a value (100
). I think that this is not an Eve-SQLAlchemy limitation but an Eve limitation, but I might be wrong since I've never used Eve with Mongo.
I have just opened this same request on Eve, where, I consider that it fits better.
You can always add a column_property
and use this to filter:
class People(CommonColumns):
# ...
total_tasks = Column(Integer, default=0, nullable=False)
done_tasks = Column(Integer, default=0, nullable=False)
is_running = column_property(done_tasks < total_tasks)
GET http://127.0.0.1:5000/people?where={"is_running":true}