Robert, my understanding is that SQLAlchemy knows nothing about the 
Postgres's `similarity` function - sqlalchemy.func just magically generates 
the SQL output depending on which member you invoke. Try 
`func.magic_unicorns()`. So, there's not much to optimize here - it outputs 
what you give it. See this for 
details: 
http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.func

It's up to you to build a query which uses the `%` syntax if you need it. 
SQLAlchemy's Columns have the `.op()` method for that 
(http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html#sqlalchemy.sql.expression.ColumnElement.op)

So this raw sql query: "... WHERE model.description  % 'string' AND 
similarity(model.description, 'string') > 0.5" becomes

      
my_query.filter(Model.description.op('%')('string')).filter(func.similarity(Model.description,
 
'string') > 0.5)


-- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to