File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -109,21 +109,24 @@ def _build_formatted_time(
109
109
exp_class : t .Type [E ], full_format_mapping : t .Optional [bool ] = None
110
110
) -> t .Callable [[t .List ], E ]:
111
111
def _builder (args : t .List ) -> E :
112
- assert len (args ) == 2
113
-
114
- return exp_class (
115
- this = exp .cast (args [1 ], exp .DataType .Type .DATETIME2 ),
116
- format = exp .Literal .string (
112
+ fmt = seq_get (args , 0 )
113
+ if isinstance (fmt , exp .Expression ):
114
+ fmt = exp .Literal .string (
117
115
format_time (
118
- args [ 0 ] .name .lower (),
116
+ fmt .name .lower (),
119
117
(
120
118
{** TSQL .TIME_MAPPING , ** FULL_FORMAT_TIME_MAPPING }
121
119
if full_format_mapping
122
120
else TSQL .TIME_MAPPING
123
121
),
124
122
)
125
- ),
126
- )
123
+ )
124
+
125
+ this = seq_get (args , 1 )
126
+ if isinstance (this , exp .Expression ):
127
+ this = exp .cast (this , exp .DataType .Type .DATETIME2 )
128
+
129
+ return exp_class (this = this , format = fmt )
127
130
128
131
return _builder
129
132
You can’t perform that action at this time.
0 commit comments