diff --git a/singer_sdk/connectors/sql.py b/singer_sdk/connectors/sql.py index b00b47252a..073f7e62db 100644 --- a/singer_sdk/connectors/sql.py +++ b/singer_sdk/connectors/sql.py @@ -839,7 +839,7 @@ def get_object_names( view_names = [] return [(t, False) for t in table_names] + [(v, True) for v in view_names] - def discover_catalog_entry_sql_datatype( # noqa: PLR6301 + def _sa_type_to_str( # noqa: PLR6301 self, data_type: sa.types.TypeEngine, ) -> str: @@ -908,6 +908,7 @@ def discover_catalog_entry( # Initialize columns list table_schema = th.PropertiesList() + datatypes = {} for column_def in inspected.get_columns(table_name, schema=schema_name): column_name = column_def["name"] is_nullable = column_def.get("nullable", False) @@ -920,13 +921,9 @@ def discover_catalog_entry( required=column_name in key_properties if key_properties else False, ), ) - schema = table_schema.to_dict() + datatypes[column_def["name"]] = self._sa_type_to_str(column_def["type"]) - sql_datatypes = {} - for column_def in inspected.get_columns(table_name, schema=schema_name): - sql_datatypes[str(column_def["name"])] = ( - self.discover_catalog_entry_sql_datatype(column_def["type"]) - ) + schema = table_schema.to_dict() # Initialize available replication methods addl_replication_methods: list[str] = [""] # By default an empty list. @@ -952,7 +949,7 @@ def discover_catalog_entry( replication_method=replication_method, key_properties=key_properties, valid_replication_keys=None, # Must be defined by user - sql_datatypes=sql_datatypes, + sql_datatypes=datatypes, ), database=None, # Expects single-database context row_count=None,