[Django] #23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields using postgres backend

4 views
Skip to first unread message

Django

unread,
Sep 4, 2014, 8:42:15 AM9/4/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: postgres check
Severity: Normal | constraint positiveintegerfield
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
As title says.

In models.py:

{{{
maximum_percentage = models.PositiveIntegerField ( null = True , blank
= True )
}}}

sqlall line from django 1.6:

{{{
"maximum_percentage" integer CHECK ("maximum_percentage" >= 0),
}}}

sqlall line from django 1.7:

{{{
"maximum_percentage" integer,
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23416>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 4, 2014, 8:43:15 AM9/4/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Release blocker | Triage Stage: Accepted
Keywords: postgres check | Needs documentation: 0
constraint positiveintegerfield | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* severity: Normal => Release blocker
* needs_tests: => 0
* needs_docs: => 0


Comment:

Confirmed and traced it back to d22b291890c1736a40c0ad97448c7318df2eebb2
using git bisect.

Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/23416#comment:1>

Django

unread,
Sep 4, 2014, 11:37:44 AM9/4/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Release blocker | Triage Stage: Accepted
Keywords: postgres check | Needs documentation: 0
constraint positiveintegerfield | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by mjtamlyn):

Added a PR https://github.com/django/django/pull/3161

It is worth noting that if you are using migrations this will not happen.

--
Ticket URL: <https://code.djangoproject.com/ticket/23416#comment:2>

Django

unread,
Sep 4, 2014, 1:33:42 PM9/4/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Release blocker | Triage Stage: Ready for
Keywords: postgres check | checkin
constraint positiveintegerfield | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23416#comment:3>

Django

unread,
Sep 6, 2014, 2:01:31 PM9/6/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) | Resolution: fixed

Severity: Release blocker | Triage Stage: Ready for
Keywords: postgres check | checkin
constraint positiveintegerfield | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Marc Tamlyn <marc.tamlyn@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"14c8456ffe7e6388383e6fe5c3f51cd20810ea49"]:
{{{
#!CommitTicketReference repository=""
revision="14c8456ffe7e6388383e6fe5c3f51cd20810ea49"
Fixed #23416 -- Make sure DatabaseCreation respects checks.

Migrations respected Field.db_parameters()['check'], but
DatabaseCreation was still using just Field.db_type().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23416#comment:4>

Django

unread,
Sep 6, 2014, 2:03:14 PM9/6/14
to django-...@googlegroups.com
#23416: Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields
using postgres backend
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Ready for
Keywords: postgres check | checkin
constraint positiveintegerfield | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Marc Tamlyn <marc.tamlyn@…>):

In [changeset:"48e10710074a06584b6f8331a6e74492be5acf18"]:
{{{
#!CommitTicketReference repository=""
revision="48e10710074a06584b6f8331a6e74492be5acf18"
[1.7.x] Fixed #23416 -- Make sure DatabaseCreation respects checks.

Migrations respected Field.db_parameters()['check'], but
DatabaseCreation was still using just Field.db_type().

Backport of 14c8456 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23416#comment:5>

Reply all
Reply to author
Forward
0 new messages