I would like to use an array comparison in a query, but with each array 
element being the result of a function. I do this by making the array with:
terms = [func.dmetaphone(t) for t in terms.split()]

When I use this array in a comparison I get an error "can't adapt type 
'Function'" because it is passing [<sqlalchemy.sql.expression.Function at 
0x1057b8310; dmetaphone>] as the array.

My full query looks like:

terms = [func.dmetaphone(t) for t in terms.split()] 
metaphones = 
Session.query(func.dmetaphone(func.unnest(func.string_to_array(Customer.name, 
' '))).label('mphone'), Customer.id).subquery() 
customers = Session.query(metaphones.columns.id) \  
                   .group_by(metaphones.columns.id) \  
                   
.having(func.array_agg(metaphones.columns.mphone).op('<@')(terms))

>From all the documentation I have read it this should work, but SQLAlchemy 
is not evaluating the func.dmetaphone call within the array. Is there a way 
to force it to do that?


Thanks,

Jason

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/Rv742SjyArEJ.
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