#31872: Postgres DecimalRangeField ignores bounds
----------------------------------+--------------------------------------
Reporter: Jack Delany | Owner: (none)
Type: New feature | Status: closed
Component: contrib.postgres | Version: 3.1
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Jack Delany):
Replying to [comment:1 felixxm]:
> > x = OneModel(val=(1.0, 2.0, "[]"))
>
> Thanks for this ticket, however this syntax has never been documented,
tested or supported. Moreover I don't think we should support it because
it's not readable. If you want to specify bounds you can use range types
from `psycopg2.extras`.
>
> > I'd presume the intention is that the behavior matches the underlying
psycopg2 semantics.
>
> We added it for simplicity not to match the psycopg2 semantic.
Well two additional points.
First, is that the syntax is exactly the syntax that
psycopg2.extras.NumericRange supports, so it's not
undocumented/unsupported:
{{{
>>> from psycopg2.extras import NumericRange
>>> x=NumericRange(1.0, 2.0, '(]')
>>> x
NumericRange(1.0, 2.0, '(]')
>>> help(x)
Help on NumericRange in module psycopg2._range object:
class NumericRange(Range)
| NumericRange(lower=None, upper=None, bounds='[)', empty=False)
}}}
Second is that NumericRange objects are immutable. You can't modify them
after construction so the only way to create them is with that syntax.
So it seems to me that if you're going to allow that list/tuple input at
all it should do it correctly. You can't fix them after the fact.
The only thing that works correctly right now is to actually instantiate
and pass in a psycopg2 object as the Django value.
--
Ticket URL: <https://code.djangoproject.com/ticket/31872#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.656373eaa628644ea764dcdd4a4868e1%40djangoproject.com.