I'm trying to work with the postgres ARRAY type and I'm having a hard time 
figuring out what I'm doing wrong with filtering queries on the array 
column.  Here's some sample code, omitting the session setup:

class MyTable(Base):                                                       
     
   __tablename__ = 'mytable'
   id = Column(Integer, primary_key=True)                                   
   
   myset = Column(sqlalchemy.dialects.postgresql.ARRAY(String))             
                       

Base.metadata.create_all(engine)                                           
     
                                                                            
    
z = ['a', 'b', 'c']                                                         
                                                                            
        
match = session.query(MyTable).\                                           
     
        filter(MyTable.myset == z).\                                       
     
        all()                                                               
                                                                            
        


Note that the table is completely empty at this point, and has just been 
created by the create_all() method.  I expect to get back an empty 'match' 
list, but when the query runs I get a long stack trace and the following 
sql error:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) operator does not 
exist: character varying[] = text[]
LINE 3: WHERE mytable.myset = ARRAY[E'a', E'b', E'c']
                            ^
HINT:  No operator matches the given name and argument type(s). You might 
need to add explicit type casts.
 'SELECT mytable.id AS mytable_id, mytable.myset AS mytable_myset \nFROM 
mytable \nWHERE mytable.myset = %(myset_1)s' {'myset_1': ['a', 'b', 'c']}

On the off chance it mattered, I've tried setting z to be a tuple instead 
of a list, but no joy there either.  What am I misunderstanding about how 
the array type works?

Thanks!

-- 
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