99
1010from data_diff .utils import is_uuid , safezip
1111from .database_types import (
12- ColType_UUID ,
1312 AbstractDatabase ,
1413 ColType ,
1514 Integer ,
1615 Decimal ,
1716 Float ,
17+ ColType_UUID ,
18+ Native_UUID ,
19+ String_UUID ,
1820 TemporalType ,
1921 UnknownColType ,
2022 Text ,
@@ -162,7 +164,7 @@ def _parse_type(
162164 )
163165 )
164166
165- elif issubclass (cls , Text ):
167+ elif issubclass (cls , ( Text , Native_UUID ) ):
166168 return cls ()
167169
168170 raise TypeError (f"Parsing { type_repr } returned an unknown type '{ cls } '." )
@@ -198,7 +200,7 @@ def _refine_coltypes(self, table_path: DbPath, col_dict: Dict[str, ColType]):
198200 if not text_columns :
199201 return
200202
201- fields = [self .normalize_uuid (c , ColType_UUID ()) for c in text_columns ]
203+ fields = [self .normalize_uuid (c , String_UUID ()) for c in text_columns ]
202204 samples_by_row = self .query (Select (fields , TableName (table_path ), limit = 16 ), list )
203205 if not samples_by_row :
204206 logger .warning (f"Table { table_path } is empty." )
@@ -216,7 +218,7 @@ def _refine_coltypes(self, table_path: DbPath, col_dict: Dict[str, ColType]):
216218 )
217219 else :
218220 assert col_name in col_dict
219- col_dict [col_name ] = ColType_UUID ()
221+ col_dict [col_name ] = String_UUID ()
220222
221223 # @lru_cache()
222224 # def get_table_schema(self, path: DbPath) -> Dict[str, ColType]:
@@ -241,7 +243,9 @@ def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None
241243 return f"LIMIT { limit } "
242244
243245 def normalize_uuid (self , value : str , coltype : ColType_UUID ) -> str :
244- return f"TRIM({ value } )"
246+ if isinstance (coltype , String_UUID ):
247+ return f"TRIM({ value } )"
248+ return self .to_string (value )
245249
246250
247251class ThreadedDatabase (Database ):
0 commit comments