11# -*- coding: utf-8 -*-
22"""
33Syntax of PartiQL
4- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.select.html#ql-reference.select.syntax
4+ https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.select.html
55------------------
66SELECT expression [, ...]
77FROM table[.index]
3737from collections import OrderedDict
3838from .dml_sql import DmlBase , DmlFunction
3939from .common import KeyWords , Tokens
40- from .util import flatten_list
41- from pyparsing import ParseResults
4240from pyparsing import Opt , Forward , Group , ZeroOrMore , delimited_list , Regex
4341from typing import Any , Dict , List , Optional
4442
@@ -147,18 +145,13 @@ class DmlSelect(DmlBase):
147145
148146 def __init__ (self , statement : str ) -> None :
149147 super ().__init__ (statement )
150- self ._columns = list ()
151- self ._where_conditions = list ()
148+ self ._columns = []
152149 self ._is_star_column = False
153150
154151 @property
155152 def columns (self ) -> List [Optional [DmlSelectColumn ]]:
156153 return self ._columns
157154
158- @property
159- def where_conditions (self ) -> List [Optional [str ]]:
160- return self ._where_conditions
161-
162155 @property
163156 def is_star_column (self ) -> bool :
164157 return self ._is_star_column
@@ -218,7 +211,7 @@ def _construct_columns(self, columns: List[Any]) -> str:
218211 self ._columns .clear ()
219212 return "*"
220213
221- column_ = list ()
214+ column_ = []
222215 column_ .append (column ["column_name" ])
223216
224217 for rcolumn in column ["column_ops" ]:
@@ -249,43 +242,11 @@ def _construct_columns(self, columns: List[Any]) -> str:
249242 columns_ = "," .join (columns_ .keys ())
250243 return columns_
251244
252- def _construct_where_conditions (self , where_conditions : List [Any ]) -> str :
253- for condition in where_conditions :
254- if not isinstance (condition , ParseResults ):
255- self ._where_conditions .append (str (condition ))
256- else :
257- function_ = condition .get ("function" , None )
258- function_with_op_ = condition .get ("function_with_op" , None )
259- if function_ :
260- flatted_func_params = "," .join (condition ["function_params" ])
261- self ._where_conditions .append (
262- "%s(%s)" % (function_ , flatted_func_params )
263- )
264- elif function_with_op_ :
265- flatted_func_params = "," .join (condition ["function_params" ])
266- self ._where_conditions .append (
267- "%s(%s) %s %s"
268- % (
269- function_with_op_ ,
270- flatted_func_params ,
271- condition ["comparison_operators" ],
272- condition ["column_rvalue" ],
273- )
274- )
275- else :
276- where_conditions_ = condition .as_list ()
277- flatted_where = " " .join (
278- str (c ) for c in flatten_list (where_conditions_ )
279- )
280- self ._where_conditions .append (flatted_where )
281-
282- return "WHERE %s" % " " .join (self .where_conditions )
283-
284245 def _construct_raw_options (self , options : List [Any ]) -> Optional [List [Any ]]:
285246 converted_ = None
286247 for option in options :
287248 if converted_ is None :
288- converted_ = list ()
249+ converted_ = []
289250
290251 converted_ .append (" " .join (str (o ) for o in option ))
291252
@@ -295,7 +256,7 @@ def _construct_options(self, options: List[Any]) -> Optional[Dict[str, Any]]:
295256 converted_ = None
296257 for option in options :
297258 if converted_ is None :
298- converted_ = dict ()
259+ converted_ = {}
299260 option_name = option [0 ]
300261 option_value = option [1 ]
301262
0 commit comments