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

#not_in with a range should respect proper precedence #331

Merged
merged 1 commit into from Oct 24, 2014

Conversation

sgrif
Copy link

@sgrif sgrif commented Oct 24, 2014

Currently, doing

relation[:id].not_eq(4).and(relation[:id].not_in(1..3))

will generate

"id" != 4 AND "id" < 1 OR "id" > 3

Which would incorrectly include records with an id of 4, as the OR
statement has higher precidence than the AND statement. The or
method on Node properly groups the statement in parenthesis.

Currently, doing

```ruby
relation[:id].not_eq(4).and(relation[:id].not_in(1..3))
```

will generate

```sql
"id" != 4 AND "id" < 1 OR "id" > 3
```

Which would incorrectly include records with an id of 4, as the OR
statement has higher precidence than the AND statement. The `or`
method on `Node` properly groups the statement in parenthesis.
sgrif added a commit that referenced this pull request Oct 24, 2014
`#not_in` with a range should respect proper precedence
@sgrif sgrif merged commit 2347f15 into rails:master Oct 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant