Re: [Django] #12728: loadata/flush issues given GenericRelation, model inheritance and postgres

13 views
Skip to first unread message

Django

unread,
May 1, 2012, 9:35:54 AM5/1/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by chrischambers):

* cc: magma.chambers@… (added)


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

Django

unread,
May 24, 2012, 9:35:06 AM5/24/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by ukch):

* cc: joel@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:10>

Django

unread,
Jul 30, 2012, 1:19:20 PM7/30/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by lorinh):

Note: This bug causes an
[https://github.com/stephenmcd/mezzanine/issues/345 issue in Mezzanine], a
Django-based CMS.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:11>

Django

unread,
Jul 30, 2012, 1:52:16 PM7/30/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by lorinh):

It looks like
[https://github.com/django/django/blob/1.4/django/db/backends/postgresql_psycopg2/operations.py#L136
the code in question] assumes that the table has a column called "id", the
query is hard-coded with 'id' in it:

{{{
if not f.rel.through:
output.append("%s
setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s
null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_TABLE(qn(f.m2m_db_table())),
style.SQL_FIELD('id'),
style.SQL_FIELD(qn('id')),
style.SQL_FIELD(qn('id')),
style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(qn(f.m2m_db_table()))))
}}}

However, if the model uses multi-table inheritance, the table won't have
an 'id' field.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:12>

Django

unread,
Jul 30, 2012, 3:23:28 PM7/30/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by lorinh):

Submitted a pull request here: https://github.com/django/django/pull/238

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:13>

Django

unread,
Jul 30, 2012, 4:24:19 PM7/30/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 1 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

Can you add a failing testcase in `fixtures_regress.tests`?

I'm also asking myself if this could be related to #7565 somehow. See
[https://github.com/django/django/blob/master/tests/regressiontests/fixtures_regress/tests.py#L187-L200
fixtures_regress.tests.TestFixtures.test_pg_sequence_resetting_checks]

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:14>

Django

unread,
Jul 31, 2012, 8:36:21 AM7/31/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by lorinh):

* cc: lorin@… (added)
* needs_tests: 1 => 0


Comment:

I added a failing test case by
[https://github.com/nimbis/django/commit/41c0a33bdabd567159da96626a6e5373691cacca
modifying one of the existing test models] so that the
backends.!SequenceResetTest will now fail unless the patch is applied.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:15>

Django

unread,
Sep 29, 2012, 10:11:32 AM9/29/12
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 0
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by lorinh):

My original pull request was against the wrong branch in the django
repository. This new pull request is against the master branch:
https://github.com/django/django/pull/408

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:16>

Django

unread,
Feb 8, 2013, 6:32:29 PM2/8/13
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
psycopg2.ProgrammingError, | Needs documentation: 0
GenericRelation | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0

Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


Comment:

Patch applies cleanly and tests with postgresql_psycopg2 backend pass.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:17>

Django

unread,
May 17, 2013, 12:29:58 PM5/17/13
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 1

GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* cc: timograham@… (added)
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted


Comment:

I could be mistaken, but it looks like the regression test doesn't seem to
fail without the patch applied anymore (the patch also needs to be updated
for the move of tests/regressiontests/backends/models.py to
tests/backends/models.py).

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:18>

Django

unread,
May 24, 2013, 7:59:06 AM5/24/13
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 1
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by timo):

Confirmed the new test no longer fails as of
97774429aeb54df4c09895c07cd1b09e70201f7d (#19385). I didn't investigate
this further to see if the underlying issue is fixed or if this is still
an issue and just needs a new test.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:19>

Django

unread,
Jul 16, 2013, 12:19:50 PM7/16/13
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 1
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by jtbandes@…):

I believe it stopped being an issue because GenericRel is no longer a
subclass of ManyToManyRel:

https://github.com/django/django/blob/1.5/django/contrib/contenttypes/generic.py#L370
https://github.com/django/django/blob/1.5/django/db/models/options.py#L174
vs.
https://github.com/django/django/blob/1.6b1/django/contrib/contenttypes/generic.py#L376
https://github.com/django/django/blob/1.6b1/django/db/models/fields/related.py#L827

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:20>

Django

unread,
Jul 16, 2013, 12:37:04 PM7/16/13
to django-...@googlegroups.com
#12728: loadata/flush issues given GenericRelation, model inheritance and postgres
-------------------------------------+-------------------------------------
Reporter: pragmar | Owner: nobody
Type: Bug | Status: closed
Component: | Version: master
contrib.contenttypes | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
psycopg2.ProgrammingError, | Patch needs improvement: 1
GenericRelation | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

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


Comment:

Ok, I will mark it as fixed.

--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:21>

Reply all
Reply to author
Forward
0 new messages