File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
dl_connector_ydb/dl_connector_ydb/core/base
dl_sqlalchemy_ydb/dl_sqlalchemy_ydb Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,12 @@ def _convert_bytes(value: bytes) -> str:
103
103
return value .decode ("utf-8" , errors = "replace" )
104
104
105
105
@staticmethod
106
- def _convert_interval (value : datetime .timedelta ) -> int :
107
- return int (value .total_seconds () * 1_000_000 )
106
+ def _convert_interval (value : datetime .timedelta | int ) -> int :
107
+ if value is None :
108
+ return None
109
+ if isinstance (value , datetime .timedelta ):
110
+ return int (value .total_seconds () * 1_000_000 )
111
+ return value
108
112
109
113
@staticmethod
110
114
def _convert_ts (value : int | datetime .datetime ) -> datetime .datetime :
Original file line number Diff line number Diff line change @@ -33,10 +33,12 @@ class YqlInterval(sa.types.Interval):
33
33
__visit_name__ = "interval"
34
34
35
35
def result_processor (self , dialect : sa .engine .Dialect , coltype : typing .Any ) -> typing .Any :
36
- def process (value : typing .Optional [datetime .timedelta ]) -> typing .Optional [int ]:
36
+ def process (value : typing .Optional [datetime .timedelta ] | int ) -> typing .Optional [int ]:
37
37
if value is None :
38
38
return None
39
- return int (value .total_seconds () * 1_000_000 )
39
+ if isinstance (value , datetime .timedelta ):
40
+ return int (value .total_seconds () * 1_000_000 )
41
+ return value
40
42
41
43
return process
42
44
You can’t perform that action at this time.
0 commit comments