1- import re
2-
31from ..utils import match_regexps
42
53from .database_types import *
64from .base import ThreadedDatabase , import_helper , ConnectError , QueryError
7- from .base import DEFAULT_DATETIME_PRECISION , TIMESTAMP_PRECISION_POS
5+ from .base import TIMESTAMP_PRECISION_POS
86
97SESSION_TIME_ZONE = None # Changed by the tests
108
@@ -29,7 +27,7 @@ class Oracle(ThreadedDatabase):
2927 ROUNDS_ON_PREC_LOSS = True
3028
3129 def __init__ (self , * , host , database , thread_count , ** kw ):
32- self .kwargs = dict (dsn = "%s/%s" % ( host , database ) if database else host , ** kw )
30+ self .kwargs = dict (dsn = f" { host } / { database } " if database else host , ** kw )
3331
3432 self .default_schema = kw .get ("user" )
3533
@@ -73,12 +71,12 @@ def select_table_schema(self, path: DbPath) -> str:
7371 def normalize_timestamp (self , value : str , coltype : TemporalType ) -> str :
7472 if coltype .rounds :
7573 return f"to_char(cast({ value } as timestamp({ coltype .precision } )), 'YYYY-MM-DD HH24:MI:SS.FF6')"
74+
75+ if coltype .precision > 0 :
76+ truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.FF{ coltype .precision } ')"
7677 else :
77- if coltype .precision > 0 :
78- truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.FF{ coltype .precision } ')"
79- else :
80- truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.')"
81- return f"RPAD({ truncated } , { TIMESTAMP_PRECISION_POS + 6 } , '0')"
78+ truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.')"
79+ return f"RPAD({ truncated } , { TIMESTAMP_PRECISION_POS + 6 } , '0')"
8280
8381 def normalize_number (self , value : str , coltype : FractionalType ) -> str :
8482 # FM999.9990
@@ -89,7 +87,7 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
8987
9088 def _parse_type (
9189 self ,
92- table_name : DbPath ,
90+ table_path : DbPath ,
9391 col_name : str ,
9492 type_repr : str ,
9593 datetime_precision : int = None ,
@@ -107,7 +105,7 @@ def _parse_type(
107105 return t_cls (precision = precision , rounds = self .ROUNDS_ON_PREC_LOSS )
108106
109107 return super ()._parse_type (
110- table_name , col_name , type_repr , datetime_precision , numeric_precision , numeric_scale
108+ table_path , col_name , type_repr , datetime_precision , numeric_precision , numeric_scale
111109 )
112110
113111 def offset_limit (self , offset : Optional [int ] = None , limit : Optional [int ] = None ):
0 commit comments