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

fixed viewing storage_map.column_value_mapping settings of a table #6

Merged

Conversation

agustinhydrolix
Copy link
Collaborator

Fixed error 'children' when displaying table settings

@agustinhydrolix agustinhydrolix added the bug Something isn't working label Sep 26, 2023
@agustinhydrolix agustinhydrolix self-assigned this Sep 26, 2023
Copy link
Collaborator

@hdxscott hdxscott left a comment

Choose a reason for hiding this comment

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

Your code seems fine, but the pre-existing code, such as the _get_dotted_key_from_dict function, is relying on KeyErrors for flow control. That's exactly what I was talking about with using .get instead of [].

What not to do:

try:
    value_we_want = dictionary["key"]
except KeyError:
    do_something_when_key_not_found_in_dict()

Much nicer:

value_we_want = dictionary.get("key", None)
if value_we_want is None:
    do_something_when_key_not_found()

The best:

value_we_want = dictionary.get("key", "default_value")

@agustinhydrolix
Copy link
Collaborator Author

agustinhydrolix commented Sep 26, 2023

In that particular case, when uses _get_dotted_key_from_dict the key is something like

nested_key = 'settings.storage_map.column_name'

That is a nested key and I cannot execute

dict.get(<nested_key>, default_value)

@agustinhydrolix agustinhydrolix merged commit 3467bb0 into dev Sep 26, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants