Closed nealedj closed 8 months ago
Seems reasonable. I wonder if we could make this a little more flexible so instead of returning default values for all missing fields, just return the ones that were requested and let the higher layers deal. I think this would allow for projection queries to work.
I'm not sure I understand, isn't "fields" only the ones requested, or is it all fields for the model?
You're right, I misread it.
I'm not sure what the correct behavior should be. On SQL backends, it looks like they just pass whatever was received from the DB to the model, so if there's a null in the DB, then the model gets a None.
The equivalent of that for a non-rel backend would be that if the field is not returned from the backend, then the model should also get a None. Does that make sense?
The projection query thing needs to be handled by the appengine compiler. But that's a separate issue.
The problem with that is ListFields... because saving an empty list to the datastore saves nothing, you could save an empty list, and then get back a None.
This is the reason we chose to return the default, rather than None.
Fall back to default if we read a NULL from a non-NULLable field (this is more consistent with Django+mysql behaviour if you do the same)