{{{
constraints = (
m.CheckConstraint(check=m.Q(precipitation_probability__contained_by=NumericRange(0,
101)), name='precipitation_percent_range'),
)
}}}
resulted in the following error (full traceback attached):
django.db.utils.ProgrammingError: syntax error at or near "object"
LINE 1: ...obability" <@ <psycopg2._range.NumberRangeAdapter object at ...
The attached patch fixes the issue for me.
--
Ticket URL: <https://code.djangoproject.com/ticket/30258>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "exception" added.
traceback
* Attachment "schema.diff" added.
patch
* status: new => assigned
* owner: nobody => Simon Charette
* version: master => 2.2
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:1>
Comment (by Simon Charette):
Thanks for your report and patch, I turned it into a
[https://github.com/django/django/pull/11086 PR].
Happy to give you attribution if you can provide an email alias.
On a different subject this patch unveiled what I believe is a design flaw
with `Index` and `Constraint`'s `create_sql` and `remove_sql` methods.
They should return a tuple of SQL and a parms instead of a ''baked'' SQL
string so we can let the backend deal with the escaping itself. I'll spin
up a different PR that does just that.
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:2>
Comment (by Simon Charette):
I gave the `create_sql`/`constraint_sql` methods returning `(sql, params)`
[https://github.com/charettes/django/pull/new/constraint-index-sql a go]
but it would require a non-trivial refactor of `deferred_sql`. I still
think it would be worthy to make and might even be required in the future
to handle the quoting on backends that don't expose low level quoting
facilities like `psycopg2` does. The number of reports regarding similar
crashes now that `CheckConstraint`, `UniqueConstraint(condition)`, and
`Index(condition)` are out there will be good indicator of whether or not
this is required.
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:3>
Comment (by Carlton Gibson):
Hey Simon, thanks for pulling this into the PR!
> I still think it would be worthy to make ...
Fancy creating a separate ticket (at your leisure)? 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"386d89ab55e620440d30590a8a104fe6d5eef830" 386d89a]:
{{{
#!CommitTicketReference repository=""
revision="386d89ab55e620440d30590a8a104fe6d5eef830"
Fixed #30258 -- Adjusted postgres schema value quoting of ranges.
Thanks Tilman Koschnick for the report and patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"883d87074dd916224e2436ecc3dad8dd80e87c16" 883d870]:
{{{
#!CommitTicketReference repository=""
revision="883d87074dd916224e2436ecc3dad8dd80e87c16"
[2.2.x] Fixed #30258 -- Adjusted postgres schema value quoting of ranges.
Thanks Tilman Koschnick for the report and patch.
Backport of 386d89ab55e620440d30590a8a104fe6d5eef830 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:6>
Comment (by Tilman Koschnick):
Hi, thanks for looking into this, and getting the fix into rc1!
--
Ticket URL: <https://code.djangoproject.com/ticket/30258#comment:7>