From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Merlin Moncure <mmoncure(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: json api WIP patch |
Date: | 2013-01-15 19:04:24 |
Message-ID: | 20130115190424.GB32407@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 14, 2013 at 07:52:56PM -0500, Andrew Dunstan wrote:
>
> On 01/14/2013 07:36 PM, Merlin Moncure wrote:
> >While testing this I noticed that integer based 'get' routines are
> >zero based -- was this intentional? Virtually all other aspects of
> >SQL are 1 based:
> >
> >postgres=# select json_get('[1,2,3]', 1);
> > json_get
> >----------
> > 2
> >(1 row)
> >
> >postgres=# select json_get('[1,2,3]', 0);
> > json_get
> >----------
> > 1
> >(1 row)
>
> Yes. it's intentional. SQL arrays might be 1-based by default, but
> JavaScript arrays are not. JsonPath and similar gadgets treat the
> arrays as zero-based. I suspect the Json-using community would not
> thank us for being overly SQL-centric on this - and I say that as
> someone who has always thought zero based arrays were a major design
> mistake, responsible for countless off-by-one errors.
Perhaps we could compromise by making arrays 0.5-based.
Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2013-01-15 19:07:37 | Re: unlogged tables vs. GIST |
Previous Message | Tom Lane | 2013-01-15 19:03:41 | Re: Patches for TODO item: Avoid truncating empty OCDR temp tables on COMMIT |