#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 <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.