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

Fix grokker rules that have fields with common prefixes #571

Merged

Conversation

dtrai2
Copy link
Collaborator

@dtrai2 dtrai2 commented Apr 23, 2024

closes #564

@dtrai2 dtrai2 added the bug Something isn't working label Apr 23, 2024
@dtrai2 dtrai2 requested a review from ekneg54 April 23, 2024 12:31
@dtrai2 dtrai2 self-assigned this Apr 23, 2024
@dtrai2 dtrai2 linked an issue Apr 23, 2024 that may be closed by this pull request
Copy link
Collaborator

@ekneg54 ekneg54 left a comment

Choose a reason for hiding this comment

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

thank you for your contribution.
please consider to have a look at one minor change

Comment on lines 71 to 72
split_field = dotted_field.split(".")
if len(split_field) > 1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
split_field = dotted_field.split(".")
if len(split_field) > 1:
if "." in dotted_field:
  • if a dot is in dotted field, the length will be greater than 1
  • much cheaper operation than two method calls

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well we still need the dotted_field.split(".") in the next line. So what I could offer is something like following. But it doesn't really reduce the method calls except the change of len(...) > 1 to "." in dotted_field.

if "." in dotted_field:
    replacement = "".join(f"[{element}]" for element in dotted_field.split("."))

Copy link
Collaborator

Choose a reason for hiding this comment

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

still better 👍

@dtrai2 dtrai2 requested a review from ekneg54 April 24, 2024 10:39
@ekneg54 ekneg54 merged commit 3376751 into main Apr 24, 2024
10 checks passed
@ekneg54 ekneg54 deleted the 564-grokker-wont-allow-for-extension-of-already-existing-field branch April 24, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grokker won't allow for extension of already existing field
2 participants