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

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: 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 20:26:18
Message-ID: 9f14c950-b175-2765-1b8b-6105ea6c6f2a@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.
>
> Maybe I should rethink my table structure (I just want to "log" all
> plays, swaps, skips, resigns in the words_moves table)...

Or make the string the value of an array:

[{"swap": "ТСНЦУЭ"}]

so you are not changing the inner JSON in the field.

>
> Or maybe I should always check for the "action" column first (acts as
> enum) - before accessing "tiles" column....
>
> Regrads
> Alex
>

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andres Freund 2018-03-02 20:36:41 Re: PQConsumeinput stuck on recv
Previous Message David Steele 2018-03-02 19:55:02 Re: Is there a continuous backup for pg ?