forked from hypermodeinc/dgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Empty datetime will fail when returning results (hypermodeinc#3169)
* types/conversion.go: dont convert datetime to datetime when empty If the stored value of datetime predicate is empty, types.Marshal will return empty when converting to binary. When we return the result the empty binary is converted to datetime, this causes time.UnmarshalBinary() to fail. * query/outputnode.go: return empty string when result is zero-time value The zero-time value is an internal values that should be exposed to the client. * types/conversion_test.go: add tests for empty values Added tests to preserve the behavior with empty values. * types/conversion.go: expand the comment so it is clear * types/conversion.go: add specific conversion checks for datetime conversions Conversion from binary to datetime should happen for value length greater than zero. Convertion from empty string to int or float results their zero value. Conversion from datetime binary value (stored) will unmarshal only if the length is correct. Fixed a panic when bool is invalid, which obscures the real reason. * types/conversion_test.go: add test for conversion edge cases The edge test cases are for unexpected values that must be handled nicely. Updated float and int tests when converting from empty string value. * types/conversion.go: add sanity check for data type assertion * types/conversion.go: remove any default value conversions and return errors instead Remove all handling of default values for types that can return error when syntax fails. Update the tests to check for behavior. * types/conversion_test.go: remove extra value in test, fix 100 char length.
- Loading branch information
1 parent
6184249
commit 6516b1d
Showing
3 changed files
with
170 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.