On Jan 29, 2013, at 1:31 PM, Jonathan Vanasco wrote:
>
>> How about using
>>
>> dbSession.query(models.User).filter(models.User.contains(name))
>
> That generates a LIKE statement , not an ILIKE. I need to case-
> insensitive match. as a stopgap, i might be able to chain a lower()
> in there, but something like this should be support.
>
> also i'm not so sure what's going on with the sql this generates for
> postgres:
> startswith :
> - LIKE 'jonathan' || '%'
>
> contains
> - LIKE 'jonathan' || '%%'
ilike is available using column.ilike("some string"). You can turn it into a
"contains" by adding in the appropriate "%" signs manually. If you want to do
lower() manually, then you can say func.lower(column).contains('some string'),
though ilike() does the lower() logic when used on a backend that doesn't have
ILIKE built in.
Also contains() produces this:
LIKE '%%' || <bindparam> || '%%'
why concatenation? in case the value you're passing to startswith()/contains()
is a SQL expression itself and not a literal value.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.