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
177 stars 51 forks source link

`in_` and `notIn` on multiple columns #129

Open jhickner opened 8 years ago

jhickner commented 8 years ago

In SQL, a query like this is valid:

update people set active = false where (id, name) not in ((1, 'Jason'), (3, 'Fred'))

But I'm having trouble constructing that with esqueleto. Here's what I've tried:

update pairs $ p -> do
    set p [ PersonActive =. val False ]
    where_ $ 
      (p ^. PersonId, p ^. PersonName)
      `notIn`
      valList pairs

where pairs is [ (PersonId, Text) ]

But that throws a lot of errors, starting with:

    Couldn't match type ‘SqlExpr’
                   with ‘(,) (SqlExpr (E.Value (Key PersonId)))’

Is it possible to construct this type of query in esqueleto?

Thanks!

meteficha commented 8 years ago

Currently that's not possible. If you really need it, you may try playing with in_'s implementation (see here and here).