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

Commit 6c7f05d

Browse files
committed
Fixes for oracle
1 parent 7831bc7 commit 6c7f05d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

data_diff/databases/oracle.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .base import ThreadedDatabase, import_helper, ConnectError, QueryError
55
from .base import DEFAULT_DATETIME_PRECISION, DEFAULT_NUMERIC_PRECISION
66

7+
SESSION_TIME_ZONE = None # Changed by the tests
78

89
@import_helper("oracle")
910
def import_oracle():
@@ -34,7 +35,10 @@ def __init__(self, *, host, database, thread_count, **kw):
3435
def create_connection(self):
3536
self._oracle = import_oracle()
3637
try:
37-
return self._oracle.connect(**self.kwargs)
38+
c = self._oracle.connect(**self.kwargs)
39+
if SESSION_TIME_ZONE:
40+
c.cursor().execute(f"ALTER SESSION SET TIME_ZONE = '{SESSION_TIME_ZONE}'")
41+
return c
3842
except Exception as e:
3943
raise ConnectError(*e.args) from e
4044

tests/test_database_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from parameterized import parameterized
1313

1414
from data_diff import databases as db
15-
import data_diff.databases.postgresql as postgresql
15+
from data_diff.databases import postgresql, oracle
1616
from data_diff.utils import number_to_human
1717
from data_diff.diff_tables import TableDiffer, TableSegment, DEFAULT_BISECTION_THRESHOLD
1818
from .common import CONN_STRINGS, N_SAMPLES, N_THREADS, BENCHMARK, GIT_REVISION, random_table_suffix
@@ -21,7 +21,7 @@
2121
CONNS = {k: db.connect_to_uri(v, N_THREADS) for k, v in CONN_STRINGS.items()}
2222

2323
CONNS[db.MySQL].query("SET @@session.time_zone='+00:00'", None)
24-
postgresql.SESSION_TIME_ZONE = 'UTC'
24+
oracle.SESSION_TIME_ZONE = postgresql.SESSION_TIME_ZONE = 'UTC'
2525

2626

2727
class PaginatedTable:

0 commit comments

Comments
 (0)