I see that Postgres defaults to a case-sensitive LIKE whereas MySQL &
sqlite default to case-insensitive:
http://www.postgresql.org/docs/8.0/interactive/functions-matching.html
- ILIKE for case-insensitive
http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
http://www.sqlite.org/lang_expr.html

This makes DAL applications not properly portable across DB back-
ends :/

>From reading the book, it seems that the recommendation to guarantee
case-insensitive would be to use .lower() [or .upper()]:
http://web2py.com/book/default/chapter/06#like,-startswith,-contains,-upper,-lower

However this then precludes the ability force a case-insensitive
search on MySQL/sqlite.

I've no idea whether ILIKE is more or less efficient than LOWER() LIKE
within pgsql.

For now I have started making all my .like() lookups use .lower() but
I thought I'd throw this out there
- minimally it should be in a FAQ (ideally in the next Book) & ideally
we could have a case_sensitive=True option for the DAL like()
operator...to ensure that both pgsql & mysql/sqlite existing apps
didn't break, it could default differently depending on the db type?

Cheers,
Fran.

Reply via email to