Skip to content

Commit

Permalink
add tests for a NUMERIC column that is converted as a DOUBLE because …
Browse files Browse the repository at this point in the history
…no typmod is present
  • Loading branch information
Tishj committed May 12, 2024
1 parent b6a79e1 commit 50ba4f8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
24 changes: 24 additions & 0 deletions expected/type_support.out
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,29 @@ SELECT * FROM float8_tbl;
4.582345020342342e+20
(3 rows)

-- NUMERIC as DOUBLE
CREATE TABLE numeric_as_double(a NUMERIC);
INSERT INTO numeric_as_double SELECT a FROM (VALUES
(0.234234234),
(NULL),
(458234502034234234234.000012)
) t(a);
select pg_typeof(a) from numeric_as_double;
pg_typeof
-----------
numeric
numeric
numeric
(3 rows)

SELECT * FROM numeric_as_double;
a
------------------------------
0.234234234

458234502034234234234.000012
(3 rows)

DROP TABLE chr;
DROP TABLE small;
DROP TABLE intgr;
Expand All @@ -126,3 +149,4 @@ DROP TABLE date_tbl;
DROP TABLE timestamp_tbl;
DROP TABLE float4_tbl;
DROP TABLE float8_tbl;
DROP TABLE numeric_as_double;
11 changes: 11 additions & 0 deletions sql/type_support.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ INSERT INTO float8_tbl SELECT CAST(a AS FLOAT8) FROM (VALUES
) t(a);
SELECT * FROM float8_tbl;

-- NUMERIC as DOUBLE
CREATE TABLE numeric_as_double(a NUMERIC);
INSERT INTO numeric_as_double SELECT a FROM (VALUES
(0.234234234),
(NULL),
(458234502034234234234.000012)
) t(a);
select pg_typeof(a) from numeric_as_double;
SELECT * FROM numeric_as_double;

DROP TABLE chr;
DROP TABLE small;
DROP TABLE intgr;
Expand All @@ -66,3 +76,4 @@ DROP TABLE date_tbl;
DROP TABLE timestamp_tbl;
DROP TABLE float4_tbl;
DROP TABLE float8_tbl;
DROP TABLE numeric_as_double;

0 comments on commit 50ba4f8

Please sign in to comment.