bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
376 stars 108 forks source link

`==.` and `/=.` should use `IS NULL` if possible? #295

Open parsonsmatt opened 2 years ago

parsonsmatt commented 2 years ago

It's a bit of a footgun to write table ^. SomeField ==. val Nothing, since this expression is always equivalent to NULL in SQL due to trivalued logic.

We could instead check (somehow) if we're doing a comparison to a Nothing and change the expression to IS NULL or IS NOT NULL.

belevy commented 2 years ago

we could maybe do

Spoilers isNullValue :: IdentInfo -> SqlExpr (Value (Maybe a)) -> Bool isNullValue info (ERaw_ f) = f Never info == ("NULL", [])
parsonsmatt commented 2 years ago

:joy: I was going to make this a beginner-friendly ticket and coach/guide folks through it! But that's fine too 😄

belevy commented 2 years ago

whoops

matthewbauer commented 2 years ago

You probably meant !=. instead of /=..