Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#23416 closed Bug (fixed)

Django 1.7 fails to output a CHECK constraint on PositiveIntegerFields using postgres backend

Reported by: ris Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Release blocker Keywords: postgres check constraint positiveintegerfield
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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,

Change History (5)

comment:1 Changed 5 years ago by Baptiste Mispelon

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Confirmed and traced it back to d22b291890c1736a40c0ad97448c7318df2eebb2 using git bisect.

Thanks!

comment:2 Changed 5 years ago by Marc Tamlyn

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

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

comment:3 Changed 5 years ago by Tim Graham

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:4 Changed 5 years ago by Marc Tamlyn <marc.tamlyn@…>

Resolution: fixed
Status: newclosed

In 14c8456ffe7e6388383e6fe5c3f51cd20810ea49:

Fixed #23416 -- Make sure DatabaseCreation respects checks.

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

comment:5 Changed 5 years ago by Marc Tamlyn <marc.tamlyn@…>

In 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

Note: See TracTickets for help on using tickets.
Back to Top