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

Commit 3230e5d

Browse files
committed
Fix for MySQL: int is now compatible with boolean
1 parent 7def8f5 commit 3230e5d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

data_diff/hashdiff_tables.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from runtype import dataclass
99

10-
from sqeleton.abcs import ColType_UUID, NumericType, PrecisionType, StringType
10+
from sqeleton.abcs import ColType_UUID, NumericType, PrecisionType, StringType, Boolean
1111

1212
from .info_tree import InfoTree
1313
from .utils import safezip
@@ -94,17 +94,19 @@ def _validate_and_adjust_columns(self, table1, table2):
9494
table1._schema[c1] = col1.replace(precision=lowest.precision, rounds=lowest.rounds)
9595
table2._schema[c2] = col2.replace(precision=lowest.precision, rounds=lowest.rounds)
9696

97-
elif isinstance(col1, NumericType):
98-
if not isinstance(col2, NumericType):
97+
elif isinstance(col1, (NumericType, Boolean)):
98+
if not isinstance(col2, (NumericType, Boolean)):
9999
raise TypeError(f"Incompatible types for column '{c1}': {col1} <-> {col2}")
100100

101101
lowest = min(col1, col2, key=attrgetter("precision"))
102102

103103
if col1.precision != col2.precision:
104104
logger.warning(f"Using reduced precision {lowest} for column '{c1}'. Types={col1}, {col2}")
105105

106-
table1._schema[c1] = col1.replace(precision=lowest.precision)
107-
table2._schema[c2] = col2.replace(precision=lowest.precision)
106+
if lowest.precision != col1.precision:
107+
table1._schema[c1] = col1.replace(precision=lowest.precision)
108+
if lowest.precision != col2.precision:
109+
table2._schema[c2] = col2.replace(precision=lowest.precision)
108110

109111
elif isinstance(col1, ColType_UUID):
110112
if not isinstance(col2, ColType_UUID):

0 commit comments

Comments
 (0)