prowdsponsor / esqueleto

Bare bones, type-safe EDSL for SQL queries on persistent backends.
http://hackage.haskell.org/package/esqueleto
BSD 3-Clause "New" or "Revised" License
178 stars 51 forks source link

Weird behaviour with Boolean values in where clause #112

Closed rubenmoor closed 9 years ago

rubenmoor commented 9 years ago

Possibly related to this question on stackoverflow.

The following query resulted in an empty list, even though I expected values (i.e. my database contains ordinates that have the field IsScopeFilter set to True):

runDb . select . from $ (expression `LeftOuterJoin` ordinate) -> do
  on $ ordinate ?. OrdinateFkExpression ==. just (expression ^. ExpressionId)
  where_ $ ordinate ?. OrdinateIsScopeFilter ==. just (val True)
  return (expression, ordinate)

Inspired by a former experience (documented in the stackoverflow question) I changed it to

runDb . select . from $ (expression `LeftOuterJoin` ordinate) -> do
  on $ ordinate ?. OrdinateFkExpression ==. just (expression ^. ExpressionId)
  where_ $ not_ (ordinate ?. OrdinateIsScopeFilter ==. just (val False))
  return (expression, ordinate)

and it works: I get those ordinates, and only those, which have IsScopeFilter set to True.

Any ideas what might be going on here?

Edit: I'm working on a Sqlite3 backend.

meteficha commented 9 years ago

Looks like a SQLite bug. Can you try to reproduce it using the SQLite REPL?

rubenmoor commented 9 years ago

I have to withdraw this issue, until I have tested it further. It might be a different problem altogether, related to this question on stackoverflow.