diff --git a/data_diff/databases/mysql.py b/data_diff/databases/mysql.py index 1ee04460..72665dee 100644 --- a/data_diff/databases/mysql.py +++ b/data_diff/databases/mysql.py @@ -8,6 +8,7 @@ Float, Decimal, Integer, + JSON, Text, TemporalType, FractionalType, @@ -68,6 +69,8 @@ class Dialect(BaseDialect): "tinytext": Text, # Boolean "boolean": Boolean, + # JSON + "json": JSON, } def quote(self, s: str) -> str: diff --git a/data_diff/utils.py b/data_diff/utils.py index 1d1405fd..5c0ab2d0 100644 --- a/data_diff/utils.py +++ b/data_diff/utils.py @@ -513,6 +513,13 @@ def diff_int_dynamic_color_template(diff_value: int) -> str: def _jsons_equiv(a: str, b: str): + # Treat Python None (DB null) as the JSON null literal so that a NULL on + # the MySQL side matches a 'null' string produced by TO_JSON_STRING(NULL) + # on the BigQuery side (or any other DB that serializes NULL as 'null'). + if a is None: + a = "null" + if b is None: + b = "null" try: return json.loads(a) == json.loads(b) except (ValueError, TypeError, json.decoder.JSONDecodeError): # not valid jsons