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

Add &, |, %, and ~ operators #118

Open potomak opened 8 years ago

potomak commented 8 years ago

See also http://www.postgresql.org/docs/9.4/static/functions-math.html.

meteficha commented 8 years ago

Thanks for the PR!

potomak commented 8 years ago

I'm adding | and ~. To support ~ I'm creating an helper function unsafeSqlUnOp, similar to unsafeSqlBinOp.

potomak commented 8 years ago

I added |, ~, and unsafeSqlUnOp. Do you think it would be fine to implement the NOT operator in terms of unsafeSqlUnOp?

meteficha commented 8 years ago

Hmm, the bitwise not will have to be used as (~.) foo, right? I haven't tried but I don't think ~. foo will work. Can you rename it to bitwiseNot to avoid confusion?

Yeah, implementing not_ with unsafeSqlUnOp would be fine! We'll lose the more specific error, but who's not_ing a primary key anyway? :)

potomak commented 8 years ago

Yes, I don't think ~. foo would work and I had the same concern about the usage as (~.) foo. The bitwiseNot function name makes more sense even if it's not consistent with all the other bitwise operators.

I will

  1. rename (~.) to bitwiseNot;
  2. implement not_ with unsafeSqlUnOp.