DAL contains query with single quote (with PG backend)

21 views
Skip to first unread message

Manuele Pesenti

unread,
Jul 15, 2019, 8:45:48 AM7/15/19
to web2py-users
Hi! I have some trouble looking for records in PostgreSQL DB filtering
using "contains" DAL method with substring containing single quote...

I found the raw solution sobstituting the resulting query filter
"(housenumbers.city ILIKE '%sant\_olcese%' ESCAPE '\'))" with
"(housenumbers.city ILIKE E'%sant\'olcese%' ESCAPE '\'))"
but it exclude the use of any DAL method I guess...

I don't know why in the original query string the single quote is
substituted with \_
anyway the use of \' is already incorrect as far as I can see using psql
if I don't use the "E" at the beginning of the substring template.

Thank you in advance for any suggestion.

Cheers

    Manuele

Manuele Pesenti

unread,
Jul 15, 2019, 5:17:26 PM7/15/19
to web2py-users
Il 15/07/19 14:45, Manuele Pesenti ha scritto:
> "(housenumbers.city ILIKE '%sant\_olcese%' ESCAPE '\'))" with

I beg your pardon because of the string was passed through GET method it
was encoded and checked so the single quote was substituted by a
underscore. I solved using POST method for witch the passed string are
not encoded or checked so the passed request variable value still
contains the single quote when passed to the controller function.

Thank you for your attention anyway

    Manuele

Reply all
Reply to author
Forward
0 new messages