Skip to content

Commit

Permalink
specify output alias
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu committed Feb 25, 2023
1 parent e9f013b commit cc794d2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 62 deletions.
86 changes: 43 additions & 43 deletions src/tests/regress/data/expected/jsonb.out
Original file line number Diff line number Diff line change
Expand Up @@ -5407,70 +5407,70 @@ select ts_headline('[]'::jsonb, tsquery('aaa & bbb'));
(1 row)

-- casts
select 'true'::jsonb::bool;
bool
------
select 'true'::jsonb::bool AS v;
v
---
t
(1 row)

select '[]'::jsonb::bool;
select '[]'::jsonb::bool AS v;
ERROR: cannot cast jsonb array to type boolean
select '1.0'::jsonb::float;
float8
--------
1
select '1.0'::jsonb::float AS v;
v
---
1
(1 row)

select '[1.0]'::jsonb::float;
select '[1.0]'::jsonb::float AS v;
ERROR: cannot cast jsonb array to type double precision
select '12345'::jsonb::int4;
int4
select '12345'::jsonb::int4 AS v;
v
-------
12345
(1 row)

select '"hello"'::jsonb::int4;
select '"hello"'::jsonb::int4 AS v;
ERROR: cannot cast jsonb string to type integer
select '12345'::jsonb::numeric;
numeric
---------
12345
select '12345'::jsonb::numeric AS v;
v
-------
12345
(1 row)

select '{}'::jsonb::numeric;
select '{}'::jsonb::numeric AS v;
ERROR: cannot cast jsonb object to type numeric
select '12345.05'::jsonb::numeric;
numeric
select '12345.05'::jsonb::numeric AS v;
v
----------
12345.05
(1 row)

select '12345.05'::jsonb::float4;
float4
select '12345.05'::jsonb::float4 AS v;
v
----------
12345.05
(1 row)

select '12345.05'::jsonb::float8;
float8
select '12345.05'::jsonb::float8 AS v;
v
----------
12345.05
(1 row)

select '12345.05'::jsonb::int2;
int2
select '12345.05'::jsonb::int2 AS v;
v
-------
12345
(1 row)

select '12345.05'::jsonb::int4;
int4
select '12345.05'::jsonb::int4 AS v;
v
-------
12345
(1 row)

select '12345.05'::jsonb::int8;
int8
select '12345.05'::jsonb::int8 AS v;
v
-------
12345
(1 row)
Expand All @@ -5481,32 +5481,32 @@ select '12345.0000000000000000000000000000000000000000000005'::jsonb::numeric;
12345.0000000000000000000000000000000000000000000005
(1 row)

select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4;
float4
--------
12345
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4 AS v;
v
-------
12345
(1 row)

select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8;
float8
--------
12345
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8 AS v;
v
-------
12345
(1 row)

select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2;
int2
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2 AS v;
v
-------
12345
(1 row)

select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4;
int4
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4 AS v;
v
-------
12345
(1 row)

select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8;
int8
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8 AS v;
v
-------
12345
(1 row)
Expand Down
38 changes: 19 additions & 19 deletions src/tests/regress/data/sql/jsonb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1464,23 +1464,23 @@ SELECT '["a","b","c",[1,2],null]'::jsonb -> -6;
--@ select ts_headline('[]'::jsonb, tsquery('aaa & bbb'));

-- casts
select 'true'::jsonb::bool;
select '[]'::jsonb::bool;
select '1.0'::jsonb::float;
select '[1.0]'::jsonb::float;
select '12345'::jsonb::int4;
select '"hello"'::jsonb::int4;
select '12345'::jsonb::numeric;
select '{}'::jsonb::numeric;
select '12345.05'::jsonb::numeric;
select '12345.05'::jsonb::float4;
select '12345.05'::jsonb::float8;
select '12345.05'::jsonb::int2;
select '12345.05'::jsonb::int4;
select '12345.05'::jsonb::int8;
select 'true'::jsonb::bool AS v;
select '[]'::jsonb::bool AS v;
select '1.0'::jsonb::float AS v;
select '[1.0]'::jsonb::float AS v;
select '12345'::jsonb::int4 AS v;
select '"hello"'::jsonb::int4 AS v;
select '12345'::jsonb::numeric AS v;
select '{}'::jsonb::numeric AS v;
select '12345.05'::jsonb::numeric AS v;
select '12345.05'::jsonb::float4 AS v;
select '12345.05'::jsonb::float8 AS v;
select '12345.05'::jsonb::int2 AS v;
select '12345.05'::jsonb::int4 AS v;
select '12345.05'::jsonb::int8 AS v;
--@ select '12345.0000000000000000000000000000000000000000000005'::jsonb::numeric;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4 AS v;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8 AS v;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2 AS v;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4 AS v;
select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8 AS v;

0 comments on commit cc794d2

Please sign in to comment.