Обсуждение: any chance of "like ANY (array[])" like the "= ANY (array[])" syntax?

Поиск
Список
Период
Сортировка

any chance of "like ANY (array[])" like the "= ANY (array[])" syntax?

От
Greg Stark
Дата:
I find myself wishing I had a syntax "LIKE ANY (array['foo','bar'])".

I don't see much value in the = ANY, = ALL, <> ANY, <> ALL syntax since
they're equivalent more or less to IN and NOT IN. But it could be neat if
other operators were supported.

As it turns out this isn't immediately relevant, it will only be relevant when
one day the database drivers use the binary FE protocol and support binding
arrays directly. Then I could pass an application-level array to postgresql as
an array directly.

Currently I think it would still have to be quoted which would mean I may as
well just pass a fixed maximum number of search elements anyways. Unless
there's a better option I haven't thought of.

--
greg

Re: any chance of "like ANY (array[])" like the "= ANY (array[])" syntax?

От
Tom Lane
Дата:
Greg Stark <gsstark@mit.edu> writes:
> I find myself wishing I had a syntax "LIKE ANY (array['foo','bar'])".

You do, because LIKE has an equivalent operator.

    foo ~~ ANY (array[])

            regards, tom lane

Re: any chance of "like ANY (array[])" like the "= ANY (array[])" syntax?

От
Greg Stark
Дата:
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Greg Stark <gsstark@mit.edu> writes:
> > I find myself wishing I had a syntax "LIKE ANY (array['foo','bar'])".
>
> You do, because LIKE has an equivalent operator.
>
>     foo ~~ ANY (array[])

Yippee! Thanks.

--
greg