Can't seem to find any reference to anyone else having this issue, so it 
must be something I'm doing incorrectly. In Mysql, the contains operator 
doesnt seem to be translated properly by the dialect. 

Docs state the following:
    contains(other, **kwargs)¶
    Implement the ‘contains’ operator.
    In a column context, produces the clause LIKE '%<other>%'

But I'm getting the following:
    >print table.c.attribute.contains("test")
    ciq_user_event.attribute LIKE '%%' || :attribute_1 || '%%'

It should be something more like this ('||' is not a concat operator in 
mysql):
    ciq_user_event.attribute LIKE CONCAT('%', :attribute_1, '%') 

rather than .contains('test'), I can obviously do 
.like(func.concat("%","test","%")). 

But I'd really appreciate anyone reaching out and explaining what I'm 
missing with the .contains operator in mysql. 

sqlalchemy 0.8.0

For completeness:
ubuntu 12.04
python 2.7.3
mysqlconnector 1.0.9
AWS RDS, MySQL 5.5.27

Thanks!
Randy


(Actual code snippet below):
__________________________________________________________
engine = sqlalchemy.create_engine('mysql+mysqlconnector://%s:%s@%s/%s' % 
(config["user"], config["pass"], config["host"], config["db"]),connect_args 
= {"sql_mode": config["mode"],'client_flags': [ClientFlag.SSL],'ssl_ca': 
config["ssl_loc"],'ssl_cert': None,'ssl_key': None})
metadata = sqlalchemy.MetaData()
metadata.reflect(bind=engine)
conn = engine.connect() 
table = sqlalchemy.Table('ciq_user_event',metadata)   
select = 
sqlalchemy.select([table.c.partner_id]).where(table.c.attribute.contains("test"))
print select

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to