On Tuesday, 10 December 2013 10:00:20 UTC-5, Michael Bayer wrote:
>
> the test case I’m using is below.  You might want to make sure you’re on 
> the latest psycopg2, this is also SQLAlchemy 0.8.4 but the SQL output seems 
> the same.   Overall, if maybe you’re on an older postgresql version, you 
> need to log in with psql, figure out what SQL query works directly, then 
> just render that with whatever casts are needed.
>

Found the problem!  I think I forgot to drop the table at some point during 
my tests.  Your example below works, and if I go back to mine and make it 
match it now works too.  

I should be able to apply this to the actual object I was having trouble 
with, now.  Thanks for the help!

 

>
>
>
> from sqlalchemy import *
> from sqlalchemy.orm import *
> from sqlalchemy.ext.declarative import declarative_base
> from sqlalchemy.dialects.postgresql import ARRAY, array
> Base = declarative_base()
>
> class MyTable(Base):
>    __tablename__ = 'mytable'
>    id = Column(Integer, primary_key=True)
>    myset = Column(ARRAY(String))
>
> engine = create_engine("postgresql://scott:tiger@localhost/test", 
> echo=True)
>
> Base.metadata.drop_all(engine)
> Base.metadata.create_all(engine)
>
> session = Session(engine)
> z = ['a', 'b', 'c']
> match = session.query(MyTable).\
>         filter(MyTable.myset == cast(z, ARRAY(String))).\
>         all()
>
>
>

-- 
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to