Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar - Mailing list pgsql-general

From Alexander Farber
Subject Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar
Date
Msg-id CAADeyWiKK7OX2JrLvBDm1WxEZJgGUmQt-bgwnJjqGcvcu3t=HA@mail.gmail.com
Whole thread Raw
In response to Re: jsonb_array_length: ERROR: 22023: cannot get array length of ascalar  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar
List pgsql-general
Good evening -

On Fri, Mar 2, 2018 at 7:11 PM, Adrian Klaver <adrian.klaver@aklaver.com> 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?


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.


that argument comes over Websocket - either from my Android app, 
or from my HTML5 game at https://slova.de/words/Words.js (just an array of objects, stringified):

                                        var tiles = [];
                                        for (var i = boardTiles.length - 1; i >= 0; i--) {
                                                var tile = boardTiles[i];
                                                tiles.push({
                                                        letter: tile.letter,
                                                        value:  tile.value,
                                                        col:    tile.col,
                                                        row:    tile.row
                                                });
                                        }

                                        var play = {
                                                social:  SOCIAL,
                                                sid:     SID,
                                                auth:    AUTH,
                                                action:  'play',
                                                gid:     gid,
                                                tiles:   tiles
                                        };
                                        ws.send(JSON.stringify(play));

Regards
Alex
 

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: jsonb_array_length: ERROR: 22023: cannot get array length of ascalar
Next
From: Alexander Farber
Date:
Subject: Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar