[Django] #22356: unique_together fails when referencing columns from base and child class

7 views
Skip to first unread message

Django

unread,
Mar 30, 2014, 6:29:20 AM3/30/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
----------------------------+------------------------
Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
Not sure whether this bug belongs to "System checks", "ORM" or
"Migrations", but thought I'd report it:

class Foo(models.Model):
url = models.URLField("URL", blank=True)

class Bar(Foo):
blip = models.CharField(max_length=10)
class Meta:
unique_together = (
'url',
'blip'
)

---

$ python manage.py check
System check identified no issues (0 silenced).

---

$ python manage.py makemigrations
$ python manage.py migrate

File "/usr/lib/python3.3/site-
packages/Django-1.7b1-py3.3.egg/django/db/backends/utils.py", line 61, in
execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "url" named in key does not exist

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

Django

unread,
Mar 30, 2014, 7:26:40 AM3/30/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------

Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shai):

* cc: shai (added)
* needs_better_patch: => 0
* component: Migrations => Core (System checks)
* needs_tests: => 1
* needs_docs: => 0
* stage: Unreviewed => Accepted


Comment:

This cannot work when you are using multi-table inheritance -- the two
columns are in separate tables, and you cannot place a cross-table
constraint.

This probably belongs in "system checks".

It can work if the parent is abstract.

(accepting based on report, with no attempt to reproduce)
(I am hesitant to mark it, not being familiar enough with the checks code,
but this is probably an easy-pickings ticket)

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

Django

unread,
Apr 3, 2014, 1:21:13 AM4/3/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------

Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by adrien):

I'm able to reproduce.

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

Django

unread,
Apr 3, 2014, 1:33:20 AM4/3/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------

Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by adrien):

* cc: adrien (added)


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

Django

unread,
Apr 3, 2014, 1:58:22 AM4/3/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
----------------------------+--------------------------------------

Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by adrien):

* component: Core (System checks) => Migrations


Comment:

Digging in the code, I would say this belongs to Migrations.

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

Django

unread,
Apr 3, 2014, 2:26:58 AM4/3/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------

Reporter: claus | Owner: nobody
Type: Bug | Status: new
Component: Core (System | Version:
checks) | 1.7-beta-1

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shai):

* component: Migrations => Core (System checks)


Comment:

@adrien: for this to belong in migrations, you need to point out something
that migrations could do to fix it.

Please leave this in "system checks" until you can produce an SQL snippet
that works on some database backend, and creates the expected constraint.

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

Django

unread,
Apr 14, 2014, 9:43:04 AM4/14/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------
Reporter: claus | Owner: frog32
Type: Bug | Status: assigned

Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by frog32):

* owner: nobody => frog32
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/22356#comment:6>

Django

unread,
Apr 14, 2014, 2:46:38 PM4/14/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------
Reporter: claus | Owner: frog32
Type: Bug | Status: assigned
Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 1 | Unreviewed
Needs tests: 1 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0

| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by frog32):

* has_patch: 0 => 1
* stage: Accepted => Unreviewed


Comment:

Pull request: https://github.com/django/django/pull/2548

--
Ticket URL: <https://code.djangoproject.com/ticket/22356#comment:7>

Django

unread,
Apr 14, 2014, 3:02:07 PM4/14/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------
Reporter: claus | Owner: frog32
Type: Bug | Status: assigned
Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin

Needs tests: 1 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by andrewsg):

* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/22356#comment:8>

Django

unread,
Apr 14, 2014, 5:10:21 PM4/14/14
to django-...@googlegroups.com
#22356: unique_together fails when referencing columns from base and child class
-------------------------------------+-------------------------------------
Reporter: claus | Owner: frog32
Type: Bug | Status: closed

Component: Core (System | Version:
checks) | 1.7-beta-1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 1 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

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


Comment:

In [changeset:"0bcc92c6917738caa2f08ec16d26fad62974fb47"]:
{{{
#!CommitTicketReference repository=""
revision="0bcc92c6917738caa2f08ec16d26fad62974fb47"
Fixed #22356 -- Added a check to make sure unique_together fields are
local.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22356#comment:9>

Reply all
Reply to author
Forward
0 new messages