From 1e01930d6167ee44680c06b36109ef264a8784a1 Mon Sep 17 00:00:00 2001 From: snordhausen Date: Mon, 21 Oct 2024 11:21:38 +0200 Subject: [PATCH] Allow comparison of String_UUID and Text The code at https://github.com/erezsh/sqeleton/blob/8655be43096dd6610c4ed8b5f9713f9a97670e7e/sqeleton/databases/base.py#L523-L534 uses sampling to determine if a column is String_UUID. But when such a column is nullable, it depends on chance if the sample contains NULL values or not. If it does, sqeleton will use the Text type, otherwise it will use String_UUID. Thise change ensures that such columns can be compared reliably. --- reladiff/hashdiff_tables.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reladiff/hashdiff_tables.py b/reladiff/hashdiff_tables.py index af73fd6..bc631f4 100644 --- a/reladiff/hashdiff_tables.py +++ b/reladiff/hashdiff_tables.py @@ -117,7 +117,10 @@ def _validate_and_adjust_columns(self, table1, table2): elif isinstance(col1, ColType_UUID): if not isinstance(col2, ColType_UUID): - raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}") + if isinstance(col1, StringType) and isinstance(col2, StringType): + pass # Allow String_UUID to be compared to Text. + else: + raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}") elif isinstance(col1, StringType): if not isinstance(col2, StringType):