TypeError while init RawStmt from query parse tree dict which has A_Star.
Typepluto opened this issue · 2 comments
Typepluto commented
Description
Encounter TypeError: A_Star.__init__() takes 1 positional argument but 2 were given
while init RawStmt from query parse tree Dict which has A_Star.
Error code
from pglast.parser import parse_sql
from pglast.ast import RawStmt
query = """SELECT * FROM Customers"""
root = parse_sql(query)
print(RawStmt(root[0]()))
Error message
TypeError Traceback (most recent call last)
Cell In[6], line 3
1 query = """SELECT * FROM Customers"""
2 root = parse_sql(query)
----> 3 print(RawStmt(root[0]()))
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:3225, in RawStmt.__init__(self, stmt, stmt_location, stmt_len)
3220 def __init__(self, stmt=None, stmt_location=None, stmt_len=None): # pragma: no cover # noqa: E501
3221 if ((stmt is not None
3222 and stmt_location is stmt_len is None # noqa: E501
3223 and isinstance(stmt, dict)
3224 and '@' in stmt)):
-> 3225 super().__init__(stmt)
3226 else:
3227 self.stmt = stmt
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:77, in Node.__init__(self, data)
75 if v is not None:
76 if isinstance(v, dict) and '@' in v:
---> 77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:3497, in SelectStmt.__init__(self, distinctClause, intoClause, targetList, fromClause, whereClause, groupClause, groupDistinct, havingClause, windowClause, valuesLists, sortClause, limitOffset, limitCount, limitOption, lockingClause, withClause, op, all, larg, rarg)
3492 def __init__(self, distinctClause=None, intoClause=None, targetList=None, fromClause=None, whereClause=None, groupClause=None, groupDistinct=None, havingClause=None, windowClause=None, valuesLists=None, sortClause=None, limitOffset=None, limitCount=None, limitOption=None, lockingClause=None, withClause=None, op=None, all=None, larg=None, rarg=None): # pragma: no cover # noqa: E501
3493 if ((distinctClause is not None
3494 and intoClause is targetList is fromClause is whereClause is groupClause is groupDistinct is havingClause is windowClause is valuesLists is sortClause is limitOffset is limitCount is limitOption is lockingClause is withClause is op is all is larg is rarg is None # noqa: E501
3495 and isinstance(distinctClause, dict)
3496 and '@' in distinctClause)):
-> 3497 super().__init__(distinctClause)
3498 else:
3499 self.distinctClause = distinctClause
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:79, in Node.__init__(self, data)
77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
---> 79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
81 setattr(self, a, v)
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:79, in <genexpr>(.0)
77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
---> 79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
81 setattr(self, a, v)
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:3337, in ResTarget.__init__(self, name, indirection, val, location)
3332 def __init__(self, name=None, indirection=None, val=None, location=None): # pragma: no cover # noqa: E501
3333 if ((name is not None
3334 and indirection is val is location is None # noqa: E501
3335 and isinstance(name, dict)
3336 and '@' in name)):
-> 3337 super().__init__(name)
3338 else:
3339 self.name = name
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:77, in Node.__init__(self, data)
75 if v is not None:
76 if isinstance(v, dict) and '@' in v:
---> 77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:1254, in ColumnRef.__init__(self, fields, location)
1249 def __init__(self, fields=None, location=None): # pragma: no cover # noqa: E501
1250 if ((fields is not None
1251 and location is None # noqa: E501
1252 and isinstance(fields, dict)
1253 and '@' in fields)):
-> 1254 super().__init__(fields)
1255 else:
1256 self.fields = fields
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:79, in Node.__init__(self, data)
77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
---> 79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
81 setattr(self, a, v)
File ~/.local/lib/python3.10/site-packages/pglast/ast.py:79, in <genexpr>(.0)
77 v = G[v['@']](v)
78 elif isinstance(v, (tuple, list)):
---> 79 v = tuple(G[i['@']](i) if isinstance(i, dict) and '@' in i else i
80 for i in v)
81 setattr(self, a, v)
TypeError: A_Star.__init__() takes 1 positional argument but 2 were given
lelit commented
Thank you for the report, I will investigate as time permits.
lelit commented
Will release 5.6 in the next days.