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

Commit e53d08d

Browse files
committed
Oracle: Added support for schemas (Issue #115)
1 parent 0fe259d commit e53d08d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

data_diff/databases/oracle.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Oracle(ThreadedDatabase):
1818
def __init__(self, host, port, user, password, *, database, thread_count, **kw):
1919
assert not port
2020
self.kwargs = dict(user=user, password=password, dsn="%s/%s" % (host, database), **kw)
21+
22+
self.default_schema = user
23+
2124
super().__init__(thread_count=thread_count)
2225

2326
def create_connection(self):
@@ -45,13 +48,11 @@ def to_string(self, s: str):
4548
return f"cast({s} as varchar(1024))"
4649

4750
def select_table_schema(self, path: DbPath) -> str:
48-
if len(path) > 1:
49-
raise ValueError("Unexpected table path for oracle")
50-
(table,) = path
51+
schema, table = self._normalize_table_path(path)
5152

5253
return (
5354
f"SELECT column_name, data_type, 6 as datetime_precision, data_precision as numeric_precision, data_scale as numeric_scale"
54-
f" FROM USER_TAB_COLUMNS WHERE table_name = '{table.upper()}'"
55+
f" FROM ALL_TAB_COLUMNS WHERE table_name = '{table.upper()}' AND owner = '{schema.upper()}'"
5556
)
5657

5758
def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:

0 commit comments

Comments
 (0)