Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 6a18838

Browse files
committed
fix precision fetching for pg
1 parent c13e21b commit 6a18838

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

data_diff/databases/postgresql.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,21 @@ def select_table_schema(self, path: DbPath) -> str:
191191
info_schema_path.insert(0, database)
192192

193193
return (
194-
f"SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM {'.'.join(info_schema_path)} "
195-
f"WHERE table_name = '{table}' AND table_schema = '{schema}'"
194+
f"""
195+
SELECT column_name, data_type, datetime_precision,
196+
CASE
197+
WHEN data_type = 'numeric'
198+
THEN coalesce(numeric_precision, 131072 + 16383)
199+
ELSE numeric_precision
200+
END AS numeric_precision,
201+
CASE
202+
WHEN data_type = 'numeric'
203+
THEN coalesce(numeric_scale, 16383)
204+
ELSE numeric_scale
205+
END AS numeric_scale
206+
FROM {'.'.join(info_schema_path)}
207+
WHERE table_name = '{table}' AND table_schema = '{schema}'
208+
"""
196209
)
197210

198211
def select_table_unique_columns(self, path: DbPath) -> str:

0 commit comments

Comments
 (0)