Code

Opened 3 years ago

Closed 2 years ago

#15216 closed Bug (fixed)

list/set inconsistency breaks syncdb

Reported by: arthur@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: inspectdb
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Found on SVN as of rev 15400.

$ python manage.py syncdb
Creating tables ...
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "django/core/management/commands/syncdb.py", line 102, in handle_noargs
    tables.append(connection.introspection.table_name_converter(model._meta.db_table))
AttributeError: 'set' object has no attribute 'append'

tables is expected to be a list here but is created at django/trunk/django/db/backends/__init__.py BaseDatabaseIntrospection.django_tables_name as a set (but a list instead if only_existing is True..).
A simple tables = list(table) at the appropriate line in django_tables_names has fixed syncdb for me.

Attachments (1)

django-set-object-has-no-attribute-append.patch (515 bytes) - added by Obey Arthur Liu <arthur@…> 3 years ago.
patch

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by Obey Arthur Liu <arthur@…>

patch

comment:1 Changed 3 years ago by russellm

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

The regressiontests/introspection tests contains tests for django_table_names(); tests for this case should be added.

comment:2 Changed 3 years ago by lrekucki

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 3 years ago by ramiro

  • Easy pickings unset
  • Keywords inspectdb added
  • UI/UX unset

comment:4 Changed 2 years ago by ramiro

Actually, the tables variable is obtained from a a call to the backend DatabaseIntrospection table_names() method and not from a call to django_table_names() so I don't see how a value returned by the latter would end being used at that point.

I agree with the proposal that the django_table_names() return value inconsistency should be fixed, though.

comment:5 Changed 2 years ago by ramiro

  • Resolution set to fixed
  • Status changed from new to closed

In [17510]:

Fixed #15216 -- Made return type of an internal DB introspection method consistent.

Thanks arthur AT milliways DOT fr for the report and patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.