Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions data_diff/databases/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .database_types import *
from .base import ThreadedDatabase, import_helper, ConnectError, QueryError
from .base import DEFAULT_DATETIME_PRECISION, DEFAULT_NUMERIC_PRECISION
from .base import DEFAULT_DATETIME_PRECISION, TIMESTAMP_PRECISION_POS

SESSION_TIME_ZONE = None # Changed by the tests

Expand Down Expand Up @@ -69,7 +69,14 @@ def select_table_schema(self, path: DbPath) -> str:
)

def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
return f"to_char(cast({value} as timestamp({coltype.precision})), 'YYYY-MM-DD HH24:MI:SS.FF6')"
if coltype.rounds:
return f"to_char(cast({value} as timestamp({coltype.precision})), 'YYYY-MM-DD HH24:MI:SS.FF6')"
else:
if coltype.precision > 0:
truncated = f"to_char({value}, 'YYYY-MM-DD HH24:MI:SS.FF{coltype.precision}')"
else:
truncated = f"to_char({value}, 'YYYY-MM-DD HH24:MI:SS.')"
return f"RPAD({truncated}, {TIMESTAMP_PRECISION_POS+6}, '0')"

def normalize_number(self, value: str, coltype: FractionalType) -> str:
# FM999.9990
Expand Down
11 changes: 6 additions & 5 deletions data_diff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,24 @@ def number_to_human(n):
def _join_if_any(sym, args):
args = list(args)
if not args:
return ''
return ""
return sym.join(str(a) for a in args if a)

def remove_password_from_url(url: str, replace_with: str="***") -> str:

def remove_password_from_url(url: str, replace_with: str = "***") -> str:
parsed = urlparse(url)
account = parsed.username or ''
account = parsed.username or ""
if parsed.password:
account += ':' + replace_with
account += ":" + replace_with
host = _join_if_any(":", filter(None, [parsed.hostname, parsed.port]))
netloc = _join_if_any("@", filter(None, [account, host]))
replaced = parsed._replace(netloc=netloc)
return replaced.geturl()


def join_iter(joiner: Any, iterable: iter) -> iter:
it = iter(iterable)
yield next(it)
for i in it:
yield joiner
yield i