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

Commit 95e1b8e

Browse files
committed
Use underlying type of domain type when defined
This fixes issues with primary keys being defined using domain types, and deselected by default. E.g. for a domain type `email_domain` with base type `text`, the `data_type` column will now be `text` rather than `email_domain`.
1 parent c0eb14e commit 95e1b8e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tap_postgres/discovery_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def produce_table_info(conn, filter_schemas=None, tables: Optional[List[str]] =
6464
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor, name='stitch_cursor') as cur:
6565
cur.itersize = post_db.CURSOR_ITER_SIZE
6666
table_info = {}
67-
# SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END
6867
sql = """
6968
SELECT
7069
pg_class.reltuples::BIGINT AS approximate_row_count,
@@ -73,7 +72,7 @@ def produce_table_info(conn, filter_schemas=None, tables: Optional[List[str]] =
7372
pg_class.relname AS table_name,
7473
attname AS column_name,
7574
i.indisprimary AS primary_key,
76-
format_type(a.atttypid, NULL::integer) AS data_type,
75+
format_type(CASE WHEN pgt.typtype = 'd' THEN pgt.typbasetype ELSE a.atttypid END, NULL::integer) AS data_type,
7776
information_schema._pg_char_max_length(CASE WHEN COALESCE(subpgt.typtype, pgt.typtype) = 'd'
7877
THEN COALESCE(subpgt.typbasetype, pgt.typbasetype) ELSE COALESCE(subpgt.oid, pgt.oid)
7978
END,

0 commit comments

Comments
 (0)