Comment 6 for bug 296739

Revision history for this message
James Henstridge (jamesh) wrote :

Just to reiterate what I said before, if you are hitting this bug then your code is buggy. You are including interpolation markers in your raw query string and they are being treated as such by psycopg2.

Since this bug was filed, Storm's column object has grown a contains_string() method that would let you do a case sensitive version of the query in the original comment as:

    result = store.find(Language, Language.englishname.contains_string('Spanish'))

It should be pretty easy to hook in a "case_senstive=False" optional argument to this function if needed.

If you must do raw SQL, consider interpolating the strings that are out of your control. For example:

    result = store.find(Language, SQL('englishname ILIKE ?', ['%Spanish%']))

This will have psycopg2 interpolate the string '%Spanish%', so you don't need to worry about interpolation markers in the string itself.