It's just a simple syntax issue in Boncheff's query. in_ takes a list so it 
should be:

*session.query(MyModel).filter(MyModel.foo[0]['tags'].in_(['test_tag1'])).all()*
 


On Tuesday, November 27, 2018 at 11:55:57 AM UTC-8 himanshu jain wrote:

> How did you get it working?
> can you give an example please
>
>
> On Thursday, March 17, 2016 at 6:44:42 AM UTC-7, Boncheff wrote:
>>
>> Thanks for your replies - it is now working as expected 
>>
>> On Tuesday, 15 March 2016 16:50:58 UTC, Boncheff wrote:
>>>
>>> We have a DB model that contains a 'foo' field which is JSONType
>>>
>>> Inside this we store the following data:
>>>
>>> foo =>    [{"apps": ["test_app"]}, {"tags": ["test_tag1", "test_tag2"]}]
>>>
>>> My question is, how can I, using session.query, select all items that 
>>> have a *test_tag_1* as a tag inside the foo column?
>>>
>>> I tried* 
>>> session.query(MyModel).filter(MyModel.foo[0]['tags'].in_('test_tag1')).all()*
>>>  
>>> but this results in 
>>>
>>> *** NotImplementedError: Operator 'getitem' is not supported on this 
>>> expression
>>>
>>> Is what I am trying to achieve even possible?
>>>
>>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/44285d8e-1a1f-4722-b946-31c904b0c0d4n%40googlegroups.com.

Reply via email to