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

Range fields should accept scalar values when querying #149

Closed
jarshwah opened this issue Mar 28, 2024 · 0 comments · Fixed by #150
Closed

Range fields should accept scalar values when querying #149

jarshwah opened this issue Mar 28, 2024 · 0 comments · Fixed by #150

Comments

@jarshwah
Copy link
Contributor

93c37c9 assumes that a range should always be passed when querying a range field, but that's not the case, particularly when performing a contains query:

Model.objects.filter(period__contains=datetime.datetime(2024, 3, 1))
# TypeError(FiniteDateTimeRangeField may only accept FiniteDatetimeRange objects)

We're too aggressive with the type checking. Django fields are a lot less strict, allowing ranges, tuples, and scalar values: https://github.com/django/django/blob/944745afe2ec45aed30cef799c250107f1364ca7/django/contrib/postgres/fields/ranges.py#L89-L96

We should just follow along, but perhaps prevent the case of using tuples, because the bounds are not well defined in that case.

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 a pull request may close this issue.

1 participant