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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 10:58 AM, Alexander Farber wrote: I see, thank you for your comments, David and Adrian. In the "tiles" column actually save either the JSON array of tiles - when the user plays them Or a string (which is jsonb too) concatenated of letters - when the user swaps the letters. Ma

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

2018-03-02 Thread David G. Johnston
On Fri, Mar 2, 2018 at 11:58 AM, Alexander Farber < alexander.far...@gmail.com> wrote: > I see, thank you for your comments, David and Adrian. > > In the "tiles" column actually save either the JSON array of tiles - when > the user plays them > > Or a string (which is jsonb too) concatenated of le

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

2018-03-02 Thread Alexander Farber
I see, thank you for your comments, David and Adrian. In the "tiles" column actually save either the JSON array of tiles - when the user plays them Or a string (which is jsonb too) concatenated of letters - when the user swaps the letters. Maybe I should rethink my table structure (I just want t

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 10:43 AM, Alexander Farber wrote: # select * from words_moves where gid=609 limit 3; -[ RECORD 1 ]

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

2018-03-02 Thread David G. Johnston
On Fri, Mar 2, 2018 at 11:48 AM, Alexander Farber < alexander.far...@gmail.com> wrote: > Oops, I've got strings there too - when swapping instead of playing tiles: > > ​You should probably add: jsonb_array_length(tiles) > 0 as a check constraint on column ​ David J.

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

2018-03-02 Thread Alexander Farber
Oops, I've got strings there too - when swapping instead of playing tiles: # select * from words_moves where gid=609 and action <> 'play'; mid | action | gid | uid |played | tiles | score --++-+--+---+--+---

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

2018-03-02 Thread Alexander Farber
# select * from words_moves where gid=609 limit 3; -[ RECORD 1 ]---

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

2018-03-02 Thread Alexander Farber
Good evening - On Fri, Mar 2, 2018 at 7:11 PM, Adrian Klaver wrote: > >> 2018-03-02 15:30:33.646 CET [16693] LOG: duration: 0.058 ms bind >> : 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

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 10:04 AM, David G. Johnston wrote: On Friday, March 2, 2018, Adrian Klaver > 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 : SELECT out_uid  AS uid,  out_fcm

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

2018-03-02 Thread David G. Johnston
On Friday, March 2, 2018, Adrian Klaver 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 > : 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

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 06:42 AM, Alexander Farber wrote: Hi Adrian, I 100% agree that nobody except me should debug my huge stored function, but if you look at my PostgreSQL 10.3 log - Another thought, in : 2018-03-02 15:30:33.646 CET [16693] LOG: duration: 0.058 ms bind : SELECT out_uid AS uid,

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 06:42 AM, Alexander Farber wrote: Hi Adrian, I 100% agree that nobody except me should debug my huge stored function, but if you look at my PostgreSQL 10.3 log - Which proves what has already been proven, that at least some of the data is correct. The issue is data that is not

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

2018-03-02 Thread Alexander Farber
Hi Adrian, I 100% agree that nobody except me should debug my huge stored function, but if you look at my PostgreSQL 10.3 log - On Fri, Mar 2, 2018 at 3:31 PM, Adrian Klaver wrote: > > The little gray cells are not awake enough to work through the below:) If > it where me I would first confirm t

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 06:14 AM, Alexander Farber wrote: Hi Adrian, thank you for the reply - #  select mid, jsonb_array_length(tiles) from words_moves where gid=609; ERROR:  22023: cannot get array length of a scalar LOCATION:  jsonb_array_length, jsonfuncs.c:1579

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

2018-03-02 Thread Alexander Farber
And here is how I call my stored function - https://gist.github.com/afarber/88a832a1b90a8940764ad69b2b761914 - why wouldn't it store a jsonb array in the tiles column of words_moves table? 2018-03-02 15:29:42.644 CET [16693] LOG: statement: DISCARD ALL 2018-03-02 15:29:42.644 CET [16693] LOG:

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

2018-03-02 Thread Alexander Farber
Hi Adrian, thank you for the reply - On Fri, Mar 2, 2018 at 3:05 PM, Adrian Klaver wrote: > On 03/02/2018 05:52 AM, Alexander Farber wrote: > >> >> in PostgreSQL 10.3 I have the following table with a jsonb column: >> >> # \d words_moves; >> Table "public.w

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

2018-03-02 Thread Adrian Klaver
On 03/02/2018 05:52 AM, Alexander Farber wrote: Good afternoon, in PostgreSQL 10.3 I have the following table with a jsonb column: #  \d words_moves;                                      Table "public.words_moves"  Column |           Type           | Collation | Nullable |     D

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

2018-03-02 Thread Alexander Farber
Good afternoon, in PostgreSQL 10.3 I have the following table with a jsonb column: # \d words_moves; Table "public.words_moves" Column | Type | Collation | Nullable | Default +--+---+--+