* 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.
* cc: joel@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:10>
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>
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>
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>
* 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>
* 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>
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>
* 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>
* 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>
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>
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>
* status: new => closed
* resolution: => fixed
Comment:
Ok, I will mark it as fixed.
--
Ticket URL: <https://code.djangoproject.com/ticket/12728#comment:21>