pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedjsonb merge with update ... on conflict do
3+ messages / 2 participants
[nested] [flat]
* jsonb merge with update ... on conflict do
@ 2021-06-01 11:53 Eugene Pazhitnov <pazhitnov@gmail.com>
2021-06-01 11:58 ` Re: jsonb merge with update ... on conflict do Sergei Kornilov <sk@zsrv.org>
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Pazhitnov @ 2021-06-01 11:53 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
Hi guys!
Is it a bug or do I miss something?
$ psql xbox -X
psql (13.2 (Ubuntu 13.2-1.pgdg20.04+1))
Type "help" for help.
xbox=> create temp table test(id int primary key, price jsonb);
CREATE TABLE
xbox=> insert into test values(1,'{"RU":10}');
INSERT 0 1
xbox=> select * from test;
id | price
----+------------
1 | {"RU": 10}
(1 row)
xbox=> insert into test values(1,'{"CA":20}') on conflict(id) do update set
price=EXCLUDED.price || '{"CA":20}'::jsonb;
INSERT 0 1
xbox=> select * from test;
id | price
----+------------
1 | {"CA": 20}
(1 row)
xbox=> \q
$
*Expected*:
{"CA":20,"RU":10}
--
Evgeny Pazhitnov
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: jsonb merge with update ... on conflict do
2021-06-01 11:53 jsonb merge with update ... on conflict do Eugene Pazhitnov <pazhitnov@gmail.com>
@ 2021-06-01 11:58 ` Sergei Kornilov <sk@zsrv.org>
2021-06-01 12:18 ` Re: jsonb merge with update ... on conflict do Eugene Pazhitnov <pazhitnov@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Kornilov @ 2021-06-01 11:58 UTC (permalink / raw)
To: Eugene Pazhitnov <pazhitnov@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hello
You meant
... do update set price=test.price || '{"CA":20}'::jsonb;
? Or possibly
... do update set price=test.price || EXCLUDED.price;
?
In other words, why did you expect the result {"CA":20,"RU":10} ?
regards, Sergei
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: jsonb merge with update ... on conflict do
2021-06-01 11:53 jsonb merge with update ... on conflict do Eugene Pazhitnov <pazhitnov@gmail.com>
2021-06-01 11:58 ` Re: jsonb merge with update ... on conflict do Sergei Kornilov <sk@zsrv.org>
@ 2021-06-01 12:18 ` Eugene Pazhitnov <pazhitnov@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Eugene Pazhitnov @ 2021-06-01 12:18 UTC (permalink / raw)
To: Sergei Kornilov <sk@zsrv.org>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Thanks a lot, Sergei! My fault. Works like a charm now.
вт, 1 июн. 2021 г. в 14:58, Sergei Kornilov <sk@zsrv.org>:
> Hello
> You meant
>
> ... do update set price=test.price || '{"CA":20}'::jsonb;
>
> ? Or possibly
>
> ... do update set price=test.price || EXCLUDED.price;
>
> ?
> In other words, why did you expect the result {"CA":20,"RU":10} ?
>
> regards, Sergei
>
--
Evgeny Pazhitnov
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-06-01 12:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 11:53 jsonb merge with update ... on conflict do Eugene Pazhitnov <pazhitnov@gmail.com>
2021-06-01 11:58 ` Sergei Kornilov <sk@zsrv.org>
2021-06-01 12:18 ` Eugene Pazhitnov <pazhitnov@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox