I’m just getting started with Dgraph, but I’m hitting some behavior I don’t understand.
The gist of it is that if you create a predicate of type
datetime and try to store the date
0001-01-01T00:00:00Z, the value will store as an empty string
"". That value doesn’t seem to be a validate
datetime, so it seems like it should (1) error if that value for a date isn’t acceptable, (2) treat it as though the predicate were omitted entirely, or (3) store it as is. Is there a reason or documentation for the current behavior?
I ran into this when doing my first interaction with Dgraph using the Go client. I queried for a node, made an update to an unrelated predicate, and then mutated it. when running the program a second time, part the submits the query and then unmarshals it back into my struct resulted in a json error which wasn’t there the first time the node was fetched:
parsing time """" as ""2006-01-02T15:04:05Z07:00"": cannot parse """ as "2006". The problem was that the result now contained an empty string for a date value instead of omitting the field completely, as was the case the first time though before my mutate saved an empty string.
For this specific use case I could work around this by using pointers to
time.Time values, which may be the right approach anyway. But I’d still like to figure out exactly what’s going on here.