This repository was archived by the owner on May 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from .database_types import *
4
4
from .base import ThreadedDatabase , import_helper , ConnectError , QueryError
5
- from .base import DEFAULT_DATETIME_PRECISION , DEFAULT_NUMERIC_PRECISION
5
+ from .base import DEFAULT_DATETIME_PRECISION , TIMESTAMP_PRECISION_POS
6
6
7
7
SESSION_TIME_ZONE = None # Changed by the tests
8
8
@@ -69,7 +69,14 @@ def select_table_schema(self, path: DbPath) -> str:
69
69
)
70
70
71
71
def normalize_timestamp (self , value : str , coltype : TemporalType ) -> str :
72
- return f"to_char(cast({ value } as timestamp({ coltype .precision } )), 'YYYY-MM-DD HH24:MI:SS.FF6')"
72
+ if coltype .rounds :
73
+ return f"to_char(cast({ value } as timestamp({ coltype .precision } )), 'YYYY-MM-DD HH24:MI:SS.FF6')"
74
+ else :
75
+ if coltype .precision > 0 :
76
+ truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.FF{ coltype .precision } ')"
77
+ else :
78
+ truncated = f"to_char({ value } , 'YYYY-MM-DD HH24:MI:SS.')"
79
+ return f"RPAD({ truncated } , { TIMESTAMP_PRECISION_POS + 6 } , '0')"
73
80
74
81
def normalize_number (self , value : str , coltype : FractionalType ) -> str :
75
82
# FM999.9990
Original file line number Diff line number Diff line change @@ -57,23 +57,24 @@ def number_to_human(n):
57
57
def _join_if_any (sym , args ):
58
58
args = list (args )
59
59
if not args :
60
- return ''
60
+ return ""
61
61
return sym .join (str (a ) for a in args if a )
62
62
63
- def remove_password_from_url (url : str , replace_with : str = "***" ) -> str :
63
+
64
+ def remove_password_from_url (url : str , replace_with : str = "***" ) -> str :
64
65
parsed = urlparse (url )
65
- account = parsed .username or ''
66
+ account = parsed .username or ""
66
67
if parsed .password :
67
- account += ':' + replace_with
68
+ account += ":" + replace_with
68
69
host = _join_if_any (":" , filter (None , [parsed .hostname , parsed .port ]))
69
70
netloc = _join_if_any ("@" , filter (None , [account , host ]))
70
71
replaced = parsed ._replace (netloc = netloc )
71
72
return replaced .geturl ()
72
73
74
+
73
75
def join_iter (joiner : Any , iterable : iter ) -> iter :
74
76
it = iter (iterable )
75
77
yield next (it )
76
78
for i in it :
77
79
yield joiner
78
80
yield i
79
-
You can’t perform that action at this time.
0 commit comments