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

Consider nil..nil range as nil #247

Merged
merged 1 commit into from
Jan 15, 2021
Merged

Consider nil..nil range as nil #247

merged 1 commit into from
Jan 15, 2021

Conversation

DanAndreasson
Copy link
Contributor

Currently range: nil..nil always return zero results as the query includes WHERE ("users"."created_at" >= NULL). This PR changes so that a nil..nil range is considered as "without begin and without end".

It makes it easier to compose queries such as

User.group_by_year(:created_at, range: starts_at..ends_at).count

where starts_at and ends_at is both optional

@ankane ankane merged commit 1ccdc8d into ankane:master Jan 15, 2021
@ankane
Copy link
Owner

ankane commented Jan 15, 2021

Looks great (and is the same behavior as Active Record's where). Thanks @DanAndreasson!

@DanAndreasson DanAndreasson deleted the feature/consider-nil-ranges-as-nil branch January 15, 2021 06:50
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