File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ def sql(self):
8989
9090
9191class DoubleQuotedStringLiteral (SqlTemplatingSymbol ):
92- regex = re .compile (r'"(?:\\.| [^"\n] )*"' )
92+ regex = re .compile (r'"[^"\\]* (?:\\.[^"\\]* )*"' )
9393
9494 def sql (self ):
9595 return duckdb_escape_literal (self .name [1 :- 1 ])
@@ -102,6 +102,13 @@ def sql(self):
102102 return duckdb_escape_identifier (self .name )
103103
104104
105+ class BacktickQuotedLabel (SqlTemplatingSymbol ):
106+ regex = re .compile (r"`(?:\\.|[^`\n])*`" )
107+
108+ def sql (self ):
109+ return duckdb_escape_identifier (self .name [1 :- 1 ])
110+
111+
105112class SqlTemplatingList (pypeg2 .List ):
106113 before = ""
107114 between = ""
@@ -122,7 +129,7 @@ class FunctionCall(pypeg2.Concat):
122129
123130 def sql (self ):
124131 func_name = str (self [0 ].name ).upper ()
125- func_params = ", " .join (s .sql () for s in self [1 :])
132+ func_params = "," .join (s .sql () for s in self [1 :])
126133
127134 if func_name in LIST_OPS :
128135 return f"LIST_{ func_name } ([{ func_params } ])"
@@ -136,6 +143,7 @@ class Value(pypeg2.Concat):
136143 BooleanLiteral ,
137144 NullLiteral ,
138145 Label ,
146+ BacktickQuotedLabel ,
139147 DecimalLiteral ,
140148 IntegerLiteral ,
141149 SingleQuotedStringLiteral ,
Original file line number Diff line number Diff line change 2323
2424code_2 = "__filter = bar + baz != 11"
2525
26- code_3 = "qux = foo + bar + baz\n \n foo = None\n \n bar = None if qux else 0"
26+ code_3 = "qux = foo + bar + baz\n \n foo = None\n \n bar = 1 if qux else 0"
2727
2828
2929def test_expr_1 ():
You can’t perform that action at this time.
0 commit comments