Unable to remove property from JSON field

I'm trying to remove a JSON property. using the - syntax, but it's not working on a supabase instance. It works on other postgres instances, it just seems to be an issue with a supabase instance:
SELECT '{"a": {"key":"value"}, "b": 2, "c": true}'::jsonb - 'a';
SELECT '{"a": {"key":"value"}, "b": 2, "c": true}'::jsonb - 'a';
Which gives me this error:
[22P02] ERROR: invalid input syntax for type json Detail: Token "a" is invalid.
14 Replies
vick
vick9mo ago
"Works for me"
% psql $PG_DEV
Timing is on.
Expanded display is used automatically.
psql (15.10 (Homebrew), server 15.6)
Type "help" for help.

postgres=> SELECT '{"a": {"key":"value"}, "b": 2, "c": true}'::jsonb - 'a';
?column?
---------------------
{"b": 2, "c": true}
(1 row)

Time: 18.222 ms
postgres=>
% psql $PG_DEV
Timing is on.
Expanded display is used automatically.
psql (15.10 (Homebrew), server 15.6)
Type "help" for help.

postgres=> SELECT '{"a": {"key":"value"}, "b": 2, "c": true}'::jsonb - 'a';
?column?
---------------------
{"b": 2, "c": true}
(1 row)

Time: 18.222 ms
postgres=>
Tried both local dev instance and a cloud hosted instance.
LordZardeck
LordZardeckOP9mo ago
weird
No description
garyaustin
garyaustin9mo ago
No description
LordZardeck
LordZardeckOP9mo ago
So weird, what could be different?
LordZardeck
LordZardeckOP9mo ago
No description
LordZardeck
LordZardeckOP9mo ago
No description
LordZardeck
LordZardeckOP9mo ago
could any of that cause problems?
garyaustin
garyaustin9mo ago
I've check on 3 instances in time (different releases of SB postgres) and all work.
LordZardeck
LordZardeckOP9mo ago
so weird
garyaustin
garyaustin9mo ago
Not sure why it would matter but are you using orioledb option? Have you retyped in your query or was it copy pasted? Is this a recent instance? But once again can't imagine that being broken in life of SB versions.
LordZardeck
LordZardeckOP9mo ago
I remember having issues with this in the past and always just fell back to using #- '{a}'. what is orioledb? And I hand-typed it
garyaustin
garyaustin9mo ago
It is a very new alpha low level postgres database storage option available when you create your instance.
LordZardeck
LordZardeckOP9mo ago
yeah, i doubt it since this issue has been around for a while
garyaustin
garyaustin9mo ago
When was the last time you upgraded the postgres on this instance? Spin up a new instance and test it.

Did you find this page helpful?