Re: json api WIP patch - Mailing list pgsql-hackers

From Gavin Flower
Subject Re: json api WIP patch
Date
Msg-id 50F5CB6E.9070400@archidevsys.co.nz
Whole thread Raw
In response to Re: json api WIP patch  (David Fetter <david@fetter.org>)
List pgsql-hackers
<div class="moz-cite-prefix">On 16/01/13 08:04, David Fetter wrote:<br /></div><blockquote
cite="mid:20130115190424.GB32407@fetter.org"type="cite"><pre wrap="">On Mon, Jan 14, 2013 at 07:52:56PM -0500, Andrew
Dunstanwrote:
 
</pre><blockquote type="cite"><pre wrap="">
On 01/14/2013 07:36 PM, Merlin Moncure wrote:
</pre><blockquote type="cite"><pre wrap="">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)
</pre></blockquote><pre wrap="">
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.
</pre></blockquote><pre wrap="">
Perhaps we could compromise by making arrays 0.5-based.

Cheers,
David.
</pre></blockquote><font size="-1">I think that <font size="-1">is far to rational, perhaps the reciprocal of the
goldenratio<font size="-1"> (0.618033...)</font> </font></font>would be more appropriate?<br /><br /> I used to be
insistentthat arrays should start with 1, now I find starting at 0 far more natural - because evrytime you start an
arrayat 1, the computer has to subtract 1 in order to calculate the entry.  Also both Java & C are zero based.<br
/><br/> I first learnt FORTRAN IV which is 1 based, had a shock when I was learning Algol and found it was 0 based -
manymoons ago...<br /><br />  <br /> Cheers,<br /> Gavin<br /> 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: unlogged tables vs. GIST
Next
From: Magnus Hagander
Date:
Subject: Re: [BUGS] BUG #7809: Running pg_dump on slave w/ streaming replication fails if there are unlogged tables