we don't currently have native support for ARRAY operations and there is some 
infrastructure work that should make it easier in 0.8 to add.

for now, when you need custom operators use op():

Model.array_column.op("@>")("somevalue")


On Aug 13, 2012, at 10:10 AM, Vlad K. wrote:

> 
> Hi all,
> 
> 
> what is the proper way to filter for element in a PostgreSQL ARRAY column? 
> in_() does not produce valid syntax for PostgreSQL (  does (value) instead of 
> array[value] ).
> 
> For now I'm doing the following, but I'm not sure how to bind values and not 
> have such a gaping sql injection vuln (even though somevalue is checked 
> against a list of allowed (unicode) values, I want proper binding:
> 
> 
> rows = session.query(Model).filter(text("{0} @> 
> {1}".format(Model.__table__.c.array_column, 'somevalue').all()
> 
> 
> Which should produce:
> 
> 
> SELECT * FROM model_table WHERE array_column @> ARRAY['somevalue']
> 
> 
> -- 
> 
> 
> .oO V Oo.
> 
> 
> Work Hard,
> Increase Production,
> Prevent Accidents,
> and
> Be Happy!  ;)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to