What steps will reproduce the problem? 1. python manage.py inspectdb > myapp/models.py 2. python manage.py sql #(Or anything that loads the model, i.e. python manage.py runserver)
What is the expected output? What do you see instead? Instead of printing the generated "CREATE" statements the operation fails with an assertion error.
[...] models.py", line 117, in ScoreLog scoreid = models.AutoField() File "/opt/python2.5/site-packages/django/db/models/fields/init.py", line 424, in init assert kwargs.get('primary_key', False) is True, "%ss must have primary_key=True." % self.class.name AssertionError: AutoFields must have primary_key=True.
What version of the product are you using? On what operating system? * Django 1.0b1 * django-pyodbc trunk-r71 * iODBC 3.52.6 * FreeTDS 0.82 * Debian Etch * MSSQL 2005 SP1
Comment #1
Posted on Aug 26, 2008 by Quick Hippo...But it doesn't always fail:
On the FIRST table (1 out of 28 tables) inspectdb did set PK:
diagram_id = models.AutoField(primary_key=True)
All subsequent tables have the parameter missing. That's odd...
Comment #2
Posted on Aug 26, 2008 by Helpful HippoThis seems to be a problem with Django's inspectdb management command that affects all RDBMS having case-sensitive column names and if the primary key columns of tables in the DB you are introspecting have at least one uppercase character.
Please test this patch: http://dpaste.com/hold/73952/
Will wait for your feedback and then possibly will post it in a ticket in Django Trac.
Comment #3
Posted on Aug 27, 2008 by Helpful HippoTicket 8573 has been opened in Django ticket tracker: http://code.djangoproject.com/ticket/8573
Closing this issue because the backend is doing its duty.
Comment #4
Posted on Sep 6, 2008 by Quick HippoSorry for the lack of feedback - was getting updates from Google Code into an unchecked mailbox ... Let's see what happens upstream.
Comment #5
Posted on Sep 17, 2008 by Helpful KangarooWe've fixed this bug in Django, thanks to a report from ramiro. See http://code.djangoproject.com/changeset/9053 and http://code.djangoproject.com/ticket/8573
Status: Invalid
Labels:
Type-Defect
Priority-Medium