Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements to parsing when using normalize_names=True. #228

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

cfhowes
Copy link
Contributor

@cfhowes cfhowes commented Jan 11, 2024

I found some issues when using normalize_names=True that I wanted to fix:

  • types like decimal(21)[] would have the final [] removed since it was parsed as its own id by the parser.
  • complex types with quotes and dots would convert from "complex"."type" to complex . type would was surprising to other tools (omymodels...)

@@ -238,7 +238,7 @@ def p_id(self, p):
delimiters_to_end = ["`", '"', "]"]
p[0] = p[1]

if self.normalize_names:
if self.normalize_names and len(p[0]) > 2:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was causing [] to be removed, which are needed in statements like decimal(21)[]

@@ -221,7 +221,7 @@ def process_type(self, _type: Union[str, List], p_list: List, p: List) -> str:
p[0] = {"property": {"distkey": True}}
_type = _type.split("distkey")[0]

_type = _type.strip().replace('" . "', '"."')
_type = _type.strip().replace(" . ", ".")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason to want to keep the space around the dots if the strings are unquoted, so i simplified to this. This then allows the PR i'm about to make to omymodels pass existing tests....

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, looks like it was 'historical context'

@xnuinside
Copy link
Owner

@cfhowes thanks for PR! merged

@xnuinside xnuinside merged commit 9cff297 into xnuinside:main Jan 11, 2024
8 checks passed
@xnuinside
Copy link
Owner

@cfhowes released version 1.0.1

@cfhowes cfhowes deleted the normalize_names_improvements branch January 11, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants