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

Commit abf3d51

Browse files
committed
Tests: Fix MySQL tests (timezone issues)
1 parent 683b247 commit abf3d51

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

data_diff/databases/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ def query(self, sql_ast: Union[Expr, Generator], res_type: type = list):
267267
if res is None: # May happen due to sum() of 0 items
268268
return None
269269
return int(res)
270+
elif res_type is datetime:
271+
res = _one(_one(res))
272+
return res # XXX parse timestamp?
270273
elif res_type is tuple:
271274
assert len(res) == 1, (sql_code, res)
272275
return res[0]

tests/test_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def setUp(self) -> None:
3737

3838
src_table = table(table_src_name, schema={"id": int, "datetime": datetime, "text_comment": str})
3939
self.conn.query(src_table.create())
40-
self.now = now = arrow.get(datetime.now())
40+
41+
self.conn.query("SET @@session.time_zone='+00:00'")
42+
db_time = self.conn.query("select now()", datetime)
43+
self.now = now = arrow.get(db_time)
4144

4245
rows = [
4346
(now, "now"),

0 commit comments

Comments
 (0)