Execute this:

select jsonb_pretty(jsonb_build_object(
  'a'::varchar, 1.7::numeric,
  'b'::varchar, 'dog'::varchar,
  'c'::varchar, true::boolean

It produces the result that I expect:

 {              +
     "a": 1.7,  +
     "b": "dog",+
     "c": true  +

Notice that the numeric, text, and boolean primitive values are properly 
rendered with the text value double-quoted and the numeric and boolean values 

Now execute this supposed functional equivalent:

select jsonb_pretty(jsonb_object(
  '{a, 17, b, "dog", c, true}'::varchar[]

It is meant to be a nice alternative when you want to build an object (rather 
than an array) because the syntax is less verbose.

However, it gets the wrong answer, thus:

 {              +
     "a": "17", +
     "b": "dog",+
     "c": "true"+

Now, the numeric value and the boolean value are double-quoted—in other words, 
they have been implicitly converted to JSON primitive text values.

Do you agree that this is a bug?

Notice that I see this behavior in vanilla PostgreSQL 11.2 and in YugabyteDB 
Version See this blogpost:

“Distributed PostgreSQL on a Google Spanner Architecture—Query Layer”

YugabyteDB uses the PostgreSQL source code for its SQL upper half.

Regards, Bryn Llewellyn, Yugabyte

Reply via email to