Re: [GENERAL] JSON objects merge using || operator

2016-12-21 Thread Tom Lane
=?UTF-8?Q?Micka=C3=ABl_Le_Baillif?= writes: > Do you have any reason for giving the same precedence on those operators ? > A small survey among my colleagues and friends tends to believe that our > human brain implicitly gives a greater priority to the '->' operator. PG's operator precedence rule

Re: [GENERAL] JSON objects merge using || operator

2016-12-21 Thread Mickaël Le Baillif
Le lun. 19 déc. 2016 à 18:52, Tom Lane a écrit : > Since the Postgres parser doesn't have any special knowledge about > the meaning of the -> and || operators, it gives them the same precedence > Thanks for clarifying the situation here. Do you have any reason for giving the same precedence on

Re: [GENERAL] JSON objects merge using || operator

2016-12-19 Thread Tom Lane
=?UTF-8?Q?Micka=C3=ABl_Le_Baillif?= writes: > Let's take a look at this example : > with data as ( > select '{ > "nested1": {"lvl1_k1": "v1"}, > "nested2": {"lvl2_k1":234, "lvl2_k2": "test"} > }'::jsonb as extra_values, > '{"aaa": 12}'::jsonb as j1,

[GENERAL] JSON objects merge using || operator

2016-12-19 Thread Mickaël Le Baillif
Hello, I've encountered a disturbing behaviour using the || operator on two jsonb objects extracted from subfields of a common jsonb object. Let's take a look at this example : with data as ( select '{ "nested1": {"lvl1_k1": "v1"}, "nested2": {"lvl2_k1":234, "lvl2_k