[GENERAL] Re: Is it possible to specify an ESCAPE for a wildcard search usingLIKE ANY (...) - Mailing list pgsql-general

From Thomas Kellerer
Subject [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcard search usingLIKE ANY (...)
Date
Msg-id o5l3l8$8hd$1@blaine.gmane.org
Whole thread Raw
In response to Re: [GENERAL] Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcardsearch using LIKE ANY (...)
List pgsql-general
Tom Lane schrieb am 17.01.2017 um 13:41:
> Thomas Kellerer <spam_eater@gmx.net> writes:
>> So my question is: Is there any way to specify an alternate wildcard escape when using LIKE ANY (..)?
>
> No, not with ESCAPE.  [ manfully resists temptation to run down SQL
> committee's ability to design composable syntax ... oops ]
>
> You could do what PG does under the hood, which is to run the pattern
> through like_escape():
>
>  select *
>    from some_table
>    where name like any (array[like_escape('foo_bar%', '/'),
>                               like_escape('bar_foo%', '/')]);
>
> If that seems too verbose, maybe build a function to apply like_escape
> to each member of an array.

OK, thanks.

I was trying to avoid to actually change the input list, but apparently there is no other way.




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Next
From: Vik Fearing
Date:
Subject: Re: [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcardsearch using LIKE ANY (...)