Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upfoo.is_null() is not the same as foo.eq(None) #1306
Comments
icefoxen
changed the title from
fo.is_null() is not the same as foo.eq(None)
to
foo.is_null() is not the same as foo.eq(None)
Nov 16, 2017
This comment has been minimized.
|
Making this change would mean that |
sgrif
closed this
Jan 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
icefoxen commentedNov 16, 2017
•
edited
Setup
I have a model something like this:
Versions
Problem Description
I want to get all the
Things with a particular data value and no optional data, so I wrote:But, it never succeeds even when there is data I would expect to match. Instead, to do this query I have to write:
It does appear that this is perfectly consistent with SQL (though if there's implementation-defined variations here I don't know anything about it), since SQL NULL is not equal to any value: https://stackoverflow.com/questions/1833949/why-is-null-not-equal-to-null-false#1833989
But, it is extremely inconsistent with Rust and its representation of
Optionfor "missing data". SQL says NULL is never equal to anything including itself, similar to floating point NaN's. But Rust says that anOption<T>::Noneis equal to any otherOption<T>::None. I sort of feel that if you're going to use SQL semantics, you should define a separate type thanOptionwith explicitly different behavior for this, so it doesn't look like it SHOULD obey Rust semantics. Given thatoptional_data.eq(None)is NEVER true, it seems like it should be impossible to say.Thank you!