Skip to content

Commit

Permalink
Fix #246 - convert ubigint to decimal(20,0) instead of to double to a…
Browse files Browse the repository at this point in the history
…void loss of precision
  • Loading branch information
Mytherin committed Sep 3, 2024
1 parent d0e0115 commit 2c94902
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/postgres_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ LogicalType PostgresUtils::ToPostgresType(const LogicalType &input) {
case LogicalTypeId::UINTEGER:
return LogicalType::BIGINT;
case LogicalTypeId::UBIGINT:
return LogicalType::DECIMAL(20, 0);
case LogicalTypeId::HUGEINT:
return LogicalType::DOUBLE;
default:
Expand Down
27 changes: 27 additions & 0 deletions test/sql/storage/attach_ubigint.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# name: test/sql/storage/attach_ubigint.test
# description: Test inserting/querying UBIGINT
# group: [storage]

require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)

statement ok
USE s;

statement ok
CREATE OR REPLACE TABLE ubigints(u UBIGINT);

statement ok
INSERT INTO ubigints VALUES (1394265502879208448);

query I
SELECT u::VARCHAR FROM ubigints
----
1394265502879208448

0 comments on commit 2c94902

Please sign in to comment.