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 firestore _utils.py #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

folkien
Copy link

@folkien folkien commented Oct 9, 2023

Fix for situations when numeric value equals to zero. If will not match in this cases and comparsion to None is needed.

Fix for situations when numeric value equals to zero. If will not match in this cases and comparsion to None is needed.
Copy link

@github-actions github-actions bot 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 @folkien , for contributing to this project, your support is much appreciated. A project committer will shortly review your contribution.

@@ -76,13 +76,13 @@ def _decode_datastore(value):
elif value.get('booleanValue') is not None:
return bool(value['booleanValue'])

elif value.get('bytesValue'):
elif value.get('bytesValue') is not None:
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please provide me an example, where this fails if is not None is note used here?

Copy link
Author

Choose a reason for hiding this comment

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

Simple.

If value.get() returns integer 0 or float 0.0 then you will miss casting to int or float and returning proper value. Unfortunately values equal to zero are treated equal to False. But in this case this is a problem because we can store zero value inside Firestore and zero is also valid integer number. So it's better to check always with None and treat every not None value as valid.

Copy link
Owner

Choose a reason for hiding this comment

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

I believe you didn't understand my question. For integer and double, your logic is correct. But does the same apply for bytes? My question was specific to bytes, thus that's the line where I commented.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, thanks!

True, probably for bytes it's not needed.

@folkien
Copy link
Author

folkien commented Apr 12, 2024

Will you merge it?

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