Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar
Date: 2018-03-02 18:11:06
Message-ID: 796da8b2-f538-a753-f3ed-ad69f3374308@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/02/2018 10:04 AM, David G. Johnston wrote:
> On Friday, March 2, 2018, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
>
> On 03/02/2018 06:42 AM, Alexander Farber wrote:
>
>
>
> 2018-03-02 15:30:33.646 CET [16693] LOG:  duration: 0.058 ms  bind
> <unnamed>: SELECT out_uid  AS uid,  out_fcm  AS fcm,  out_apns AS
> apns, out_adm  AS adm,  out_body AS body  FROM
> words_play_game($1::int, $2::int, $3::jsonb)
>
> where is $3::jsonb coming from?
>
>
> Java prepared statement I think, using setString.

I was thinking more about the ultimate source of the data. The
words_play_game() function, AFAICT, just passes the jsonb from input
into the word_moves table. If that is the case the problem may occur
further upstream where the jsonb array is actually built.

>
> Not at computer right now but what does:
>
> '[1,2,3]'::text::jsonb result in compared to '[1,2,3]'::jsonb ?
>
> Because the system think your array-looking string is actually just a
> scalar that happens to have a leading [ and a trailing ]
>
> David J.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2018-03-02 18:37:54 Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar
Previous Message David G. Johnston 2018-03-02 18:04:02 Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar