vertical-knowledge / ripozo-sqlalchemy

A python package for integrating sqlalchemy with ripozo
http://ripozo-sqlalchemy.readthedocs.org/
GNU General Public License v2.0
7 stars 6 forks source link

Question: How to retrieve_list with an "IN" clause? #7

Closed spudfkc closed 8 years ago

spudfkc commented 8 years ago

I'm looking to use the sqlalchemymanager to retrieve a list of resources, but I want to add a filter to only retrieve resources that have a property that is in a list of given properties - I am unsure how to do this.

In sqlalchemy, I would do a MyUserClass.query.filter(MyUserClass.id.in_(some_collection)), but I see that alchemymanager.retrieve_list uses filter_by (which, IIRC, does not support the "in" clause). see: https://github.com/vertical-knowledge/ripozo-sqlalchemy/blob/master/ripozo_sqlalchemy/alchemymanager.py#L194

What is the recommended way of filtering a list here?

timmartin19 commented 8 years ago

Unfortunately, at this time the AlchemyManager.retrieve_list only supports simple queries. So it's not really possible. My recommendation would be to extend the manager. (Though that method should be broken up into pieces to make it easier...)