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

Commit bb12581

Browse files
authored
Merge pull request #132 from datafold/more_string_types
[MySQL] Added varbinary
2 parents 16d6c7c + e78b2e4 commit bb12581

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

data_diff/databases/mysql.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class MySQL(ThreadedDatabase):
2424
# Text
2525
"varchar": Text,
2626
"char": Text,
27+
"varbinary": Text,
28+
"binary": Text,
2729
}
2830
ROUNDS_ON_PREC_LOSS = True
2931

@@ -66,3 +68,6 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
6668

6769
def normalize_number(self, value: str, coltype: FractionalType) -> str:
6870
return self.to_string(f"cast({value} as decimal(38, {coltype.precision}))")
71+
72+
def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
73+
return f"CAST(TRIM({value}) AS char)"

tests/test_database_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def __iter__(self):
234234
"uuid": [
235235
"varchar(100)",
236236
"char(100)",
237+
"varbinary(100)",
237238
],
238239
},
239240
db.BigQuery: {
@@ -430,6 +431,8 @@ def _insert_to_table(conn, table, values, type):
430431
value = str(sample)
431432
elif isinstance(sample, datetime) and isinstance(conn, (db.Presto, db.Oracle)):
432433
value = f"timestamp '{sample}'"
434+
elif isinstance(sample, bytearray):
435+
value = f"'{sample.decode()}'"
433436
else:
434437
value = f"'{sample}'"
435438

0 commit comments

Comments
 (0)