From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Hannu Krosing <hannu(at)krosing(dot)net> |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: json api WIP patch |
Date: | 2013-02-05 07:09:39 |
Message-ID: | CAFj8pRCxzarTmRf58O=dZOxonw7wMJMBLgK3gMwst9uyj8n1+g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2013/2/5 Hannu Krosing <hannu(at)krosing(dot)net>:
> On 01/31/2013 11:20 PM, Andrew Dunstan wrote:
>>
>>
>> I'm happy to take opinions about this, and I expected
>> some bikeshedding, but your reaction is contrary to
>> everything others have told me. Mostly they love the operators.
>
> What I would really like is if we extended postgresql core and made
> a few more constructs definable as overloadable operator:
>
> 1) array / dictionary element lookup
> a[b]
> CREATE OPERATOR [] (...)
>
> 2) attribute lookup
> a.b
> CREATE OPERATOR . (...)
>
> then you could make json lookups either step-by-step using
>
> CREATE OPERATOR [] (
> PROCEDURE = json_array_lookup, LEFTARG = json, RIGHTARG = int)
>
> and
>
> CREATE OPERATOR [] (
> PROCEDURE = json_dict_lookup, LEFTARG = json, RIGHTARG = text)
>
> fourthname = myjson[4]['name']
>
>
> or perhaps a single
>
>
> CREATE OPERATOR [] (
> PROCEDURE = json_deep_lookup, LEFTARG = json, RIGHTARG = VARIADIC "any")
>
> fourthname = myjson[4, 'name']
>
it is near to full collection implementation - and can be nice to have
it. For this moment we should to return to this topic.
My preference is using well named functions (prefer it against
operator) and operator that are not in collision with current ANSI SQL
I don't see any nice on design select
myjson->>'{"authors",0,"name"}'::text[]; - more it is ugly as
dinosaurs
better and more usual
myjson['authors']['0']['name']
or
myjson['authors/0/name']
Regards
Pavel
>
> though I suspect that we do not support type VARIADIC "any" in operator
> definitions
>
> ---------
> Hannu
>
>
>
>> I guess that '~>' and '~>>' would work as well as '->' and '->>'.
>>
>>
>> cheers
>>
>> andrew
>>
>>
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2013-02-05 07:48:54 | Re: pgsql: Stamp 9.1.8. |
Previous Message | Pavel Stehule | 2013-02-05 06:50:26 | Re: proposal: ANSI SQL 2011 syntax for named parameters |