Re: express composite type literal as text

Поиск
Список
Период
Сортировка
От Eric Hanson
Тема Re: express composite type literal as text
Дата
Msg-id CACnWs=X8zDyoO4M5X7AduB_mSw6Uw6cOSZ-ZismN2rK0E420nQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: express composite type literal as text  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: express composite type literal as text  (Andrew Sullivan <ajs@crankycanuck.ca>)
Re: [BUGS] express composite type literal as text  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Sun, Feb 22, 2015 at 11:47 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Eric Hanson <elhanson@gmail.com> writes:
> How do I express a composite type literal as text?

The rules are given in the manual ...

> I can't use the ROW() notation, because all values need to be represented
> as text over a REST api.  But I can't seem to get the text-based syntax to
> work:

> select * from on_hand where item='("fuzzy dice",42,1.99)';

> yeilds

> ERROR:  input of anonymous composite types is not implemented

That message isn't telling you that you've got a problem with the data
syntax, it's telling you that you need to cast the literal to a named
composite data type.  This works:

# select * from on_hand where item='("fuzzy dice",42,1.99)'::inventory_item;
          item          | count
------------------------+-------
 ("fuzzy dice",42,1.99) |  1000
(1 row)

Now, I'm not too sure *why* it's making you do that --- seems like the
default assumption ought to be that the literal is the same type as
the variable it's being compared to.  Perhaps there's a bug in there,
or perhaps there's no easy way to avoid this requirement.  But that's
what the requirement is today.

Got it.  Ok, I'm reporting this as a bug.  Is this a bug?  Being able to always express literals as text is a really valuable assumption to be able to rely on.

Thanks,
Eric

В списке pgsql-general по дате отправления:

Предыдущее
От: Eric Hanson
Дата:
Сообщение: Re: express composite type literal as text
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: express composite type literal as text