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

Commit 4ac3e9f

Browse files
committed
Fix current_timestamp for Oracle
1 parent 56f92cf commit 4ac3e9f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

data_diff/sqeleton/databases/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class BaseDialect(AbstractDialect):
124124
SUPPORTS_INDEXES = False
125125
TYPE_CLASSES: Dict[str, type] = {}
126126

127+
PLACEHOLDER_TABLE = None # Used for Oracle
128+
127129
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None):
128130
if offset:
129131
raise NotImplementedError("No support for OFFSET in query")

data_diff/sqeleton/databases/oracle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Dialect(BaseDialect, Mixin_Schema):
8686
"VARCHAR2": Text,
8787
}
8888
ROUNDS_ON_PREC_LOSS = True
89+
PLACEHOLDER_TABLE = "DUAL"
8990

9091
def quote(self, s: str):
9192
return f'"{s}"'
@@ -152,6 +153,9 @@ def parse_type(
152153
def set_timezone_to_utc(self) -> str:
153154
return "ALTER SESSION SET TIME_ZONE = 'UTC'"
154155

156+
def current_timestamp(self) -> str:
157+
return "LOCALTIMESTAMP"
158+
155159

156160
class Oracle(ThreadedDatabase):
157161
dialect = Dialect()

data_diff/sqeleton/queries/ast_classes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@ def compile(self, parent_c: Compiler) -> str:
601601

602602
if self.table:
603603
select += " FROM " + c.compile(self.table)
604+
elif c.dialect.PLACEHOLDER_TABLE:
605+
select += f" FROM {c.dialect.PLACEHOLDER_TABLE}"
606+
604607

605608
if self.where_exprs:
606609
select += " WHERE " + " AND ".join(map(c.compile, self.where_exprs))

0 commit comments

Comments
 (0)