Re: jsonb_concat: make sure we always return a non-scalar value
От | Jim Nasby |
---|---|
Тема | Re: jsonb_concat: make sure we always return a non-scalar value |
Дата | |
Msg-id | 55F0B0A6.9030402@BlueTreble.com обсуждение исходный текст |
Ответ на | Re: jsonb_concat: make sure we always return a non-scalar value (Oskari Saarenmaa <os@ohmu.fi>) |
Список | pgsql-hackers |
On 9/9/15 12:03 PM, Oskari Saarenmaa wrote: >> andrew=# select '[1]'::jsonb || '{"a":"b"}'; >> ?column? >> ----------------- >> [1, {"a": "b"}] > > It looks wrong, but I'm not sure what's right in that case. I think > it'd make sense to just restrict concatenation to object || object, > array || array and array || scalar and document that. I doubt many > people expect their objects to turn into arrays if they accidentally > concatenate an array into it. Alternatively the behavior could depend > on the order of arguments for concatenation, array || anything -> array, > object || array -> error. That definitely doesn't sound like a good default. It might be useful to have a concat function that would concatinate anything into an array. But if we don't provide one by default users could always create their own with json__typeof() and json_build_array(). -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com
В списке pgsql-hackers по дате отправления: