Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

potomak
Copy link

@potomak potomak commented Nov 28, 2015

@meteficha
Copy link
Member

Thanks for the PR!

  • Please add | and ~ operators as well.
  • Please add /Since: 2.4.2/ to the Haddocks of the new operators.

@potomak
Copy link
Author

potomak commented Dec 6, 2015

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

@potomak
Copy link
Author

potomak commented Dec 7, 2015

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

@meteficha
Copy link
Member

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
Copy link
Author

potomak commented Dec 7, 2015

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.

Introducing also `unsafeSqlUnOp`, used to apply unary SQL operators such
`~`. The implementation is a more generic version of `not_`.
It's not common to use operators for unary operations, so let's use an
alphanumeric function name instead.
The only negative effect of this update is that we're going to get a more
generic error message.
@potomak potomak changed the title Add & and % operators Add &, |, %, and ~ operators Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants