-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Conversation
Fix for situations when numeric value equals to zero. If will not match in this cases and comparsion to None is needed.
There was a problem hiding this 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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Will you merge it? |
Fix for situations when numeric value equals to zero. If will not match in this cases and comparsion to None is needed.