mirror of
https://github.com/postgres/postgres.git
synced 2025-11-03 09:13:20 +03:00
Make jsonb casts to scalar types translate JSON null to SQL NULL.
Formerly, these cases threw an error "cannot cast jsonb null to type <whatever>". That seems less than helpful though. It's also inconsistent with the behavior of the ->> operator, which translates JSON null to SQL NULL, as do some other jsonb functions. Discussion: https://postgr.es/m/3851203.1722552717@sss.pgh.pa.us
This commit is contained in:
@@ -1540,12 +1540,25 @@ select ts_headline('[]'::jsonb, tsquery('aaa & bbb'));
|
||||
|
||||
-- casts
|
||||
select 'true'::jsonb::bool;
|
||||
select 'null'::jsonb::bool;
|
||||
select '[]'::jsonb::bool;
|
||||
select '1.0'::jsonb::float;
|
||||
select 'null'::jsonb::float;
|
||||
select '[1.0]'::jsonb::float;
|
||||
select '1.0'::jsonb::float4;
|
||||
select 'null'::jsonb::float4;
|
||||
select '[1.0]'::jsonb::float4;
|
||||
select '12345'::jsonb::int2;
|
||||
select 'null'::jsonb::int2;
|
||||
select '"hello"'::jsonb::int2;
|
||||
select '12345'::jsonb::int4;
|
||||
select 'null'::jsonb::int4;
|
||||
select '"hello"'::jsonb::int4;
|
||||
select '12345'::jsonb::int8;
|
||||
select 'null'::jsonb::int8;
|
||||
select '"hello"'::jsonb::int8;
|
||||
select '12345'::jsonb::numeric;
|
||||
select 'null'::jsonb::numeric;
|
||||
select '{}'::jsonb::numeric;
|
||||
select '12345.05'::jsonb::numeric;
|
||||
select '12345.05'::jsonb::float4;
|
||||
|
||||
Reference in New Issue
Block a user