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 a general purpose not function #944

Closed
TheZoq2 opened this Issue Jun 11, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@TheZoq2

TheZoq2 commented Jun 11, 2017

I had a very short discussion with @sgrif about this in gitter and he asked me to open an issue for it.

Right now, there does not seem to be a way to make a query for finding all rows where an array does not contain a different array. Something to do the opposite of this:

files::table.filter(files::tags.contains(tags))

I assume adding a filter_not function that generates a WHERE NOT query would be the most general way of implementing this.

sgrif added a commit that referenced this issue Jun 11, 2017

Add a general purpose `NOT` function
I was rather surprised that we didn't already have this. I didn't stick
this in `expression/predicates.rs`, as we didn't already have a macro
for prefix operators, and I want to refactor that to add it later. I may
move this to that macro in the future, and just have the return type be
`Not<Grouped<T::Expression>>` to reduce the amount of required code
here.

We need parenthesis in the resulting SQL to ensure that it always
applies to its arguments. `not(true.and(false))` should return `true`.
However, `NOT true AND false` is equivalent to `(NOT true) AND false`.

Fixes #944.

sgrif added a commit that referenced this issue Jun 11, 2017

Add a general purpose `NOT` function
I was rather surprised that we didn't already have this. I didn't stick
this in `expression/predicates.rs`, as we didn't already have a macro
for prefix operators, and I want to refactor that to add it later. I may
move this to that macro in the future, and just have the return type be
`Not<Grouped<T::Expression>>` to reduce the amount of required code
here.

We need parenthesis in the resulting SQL to ensure that it always
applies to its arguments. `not(true.and(false))` should return `true`.
However, `NOT true AND false` is equivalent to `(NOT true) AND false`.

Fixes #944.

sgrif added a commit that referenced this issue Jun 11, 2017

Add a general purpose `NOT` function
I was rather surprised that we didn't already have this. I didn't stick
this in `expression/predicates.rs`, as we didn't already have a macro
for prefix operators, and I want to refactor that to add it later. I may
move this to that macro in the future, and just have the return type be
`Not<Grouped<T::Expression>>` to reduce the amount of required code
here.

We need parenthesis in the resulting SQL to ensure that it always
applies to its arguments. `not(true.and(false))` should return `true`.
However, `NOT true AND false` is equivalent to `(NOT true) AND false`.

Fixes #944.

@sgrif sgrif closed this in #945 Jun 11, 2017

Eijebong added a commit to Eijebong/diesel that referenced this issue Jun 11, 2017

Add a general purpose `NOT` function
I was rather surprised that we didn't already have this. I didn't stick
this in `expression/predicates.rs`, as we didn't already have a macro
for prefix operators, and I want to refactor that to add it later. I may
move this to that macro in the future, and just have the return type be
`Not<Grouped<T::Expression>>` to reduce the amount of required code
here.

We need parenthesis in the resulting SQL to ensure that it always
applies to its arguments. `not(true.and(false))` should return `true`.
However, `NOT true AND false` is equivalent to `(NOT true) AND false`.

Fixes diesel-rs#944.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment