Skip to content

Commit

Permalink
Make get_text return strings without quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
surister committed Jun 14, 2024
1 parent fccf2bc commit 13abbca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cratedb_sqlparse_py/cratedb_sqlparse/AstBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def enrich(self, stmt) -> None:

def visitTableName(self, ctx: SqlBaseParser.TableNameContext):
fqn = ctx.qname()
parts = self.get_text(fqn).replace('"', "").split(".")
parts = self.get_text(fqn).split(".")

if len(parts) == 1:
name = parts[0]
Expand All @@ -49,13 +49,13 @@ def visitGenericProperties(self, ctx: SqlBaseParser.GenericPropertiesContext):
properties = {}
interpolated_properties = {}

for property in node_properties:
key = self.get_text(property.ident())
value = self.get_text(property.expr())
for property_ in node_properties:
key = self.get_text(property_.ident())
value = self.get_text(property_.expr())

properties[key] = value

if value[0] == "$":
if value and value[0] == "$":
# It might be a interpolated value, e.g. '$1'
if value[1:].isdigit():
interpolated_properties[key] = value
Expand All @@ -66,5 +66,5 @@ def visitGenericProperties(self, ctx: SqlBaseParser.GenericPropertiesContext):
def get_text(self, node) -> t.Optional[str]:
"""Gets the text representation of the node or None if it doesn't have one"""
if node:
return node.getText()
return node.getText().replace("'", "").replace('"', "")
return node

0 comments on commit 13abbca

Please sign in to comment.