Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24637 closed Bug (fixed)

get_constraints broke on newer version of sqlite.

Reported by: dmrsearch Owned by: maestrofjp
Component: Database layer (models, ORM) Version: dev
Severity: Release blocker Keywords:
Cc: maestrofjp Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Running the test suite with the latest version of sqlite "3.8.9" gives the following error. The way sqlite brings back constraints change between the two versions.

ERROR: test_unique_together_meta (inspectdb.tests.InspectDBTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sthompso/PycharmProjects/django/tests/inspectdb/tests.py", line 225, in test_unique_together_meta
    stdout=out)
  File "/Users/sthompso/PycharmProjects/django/django/core/management/__init__.py", line 118, in call_command
    return command.execute(*args, **defaults)
  File "/Users/sthompso/PycharmProjects/django/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/Users/sthompso/PycharmProjects/django/django/core/management/commands/inspectdb.py", line 25, in handle
    for line in self.handle_inspection(options):
  File "/Users/sthompso/PycharmProjects/django/django/core/management/commands/inspectdb.py", line 69, in handle_inspection
    constraints = connection.introspection.get_constraints(cursor, table_name)
  File "/Users/sthompso/PycharmProjects/django/django/db/backends/sqlite3/introspection.py", line 242, in get_constraints
    for number, index, unique in cursor.fetchall():
ValueError: too many values to unpack

Change History (11)

comment:1 by maestrofjp, 10 years ago

Cc: maestrofjp added

comment:2 by maestrofjp, 10 years ago

It appears that database.index_list() in sqlite3 has changed:

Current documentation for the latest release 3.8.9:
http://www.sqlite.org/pragma.html#pragma_index_list

Older documentation (don't know which version exactly but shows what Django is relying on):
https://www.safaribooksonline.com/library/view/using-sqlite/9781449394592/re183.html

comment:3 by maestrofjp, 10 years ago

The new version of 3.8.9 returns 5 columns while we are relying that is only has 3 columns.

comment:4 by maestrofjp, 10 years ago

The original reporter was on OSX as I helped him with this is at PyCon Sprints. I can confirm that upgrading from Sqlite3 3.8.2 to 3.8.9 on Ubuntu 14 causes the above issue. This issue is reproducible. Sqlite 3.8.9 was released on April 8, 2015. I had to install it from source on Ubuntu.

comment:5 by maestrofjp, 10 years ago

Owner: changed from nobody to maestrofjp
Status: newassigned

I have a PR in progress that works for both behaviors.

comment:6 by maestrofjp, 10 years ago

Has patch: set

comment:7 by Simon Charette, 10 years ago

Triage Stage: UnreviewedAccepted
Version: 1.8master

comment:8 by Simon Charette, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:9 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In f8e8853:

Fixed #24637 -- Fixed database introspection with SQLite 3.8.9.

comment:10 by Tim Graham <timograham@…>, 10 years ago

In d74903e4:

[1.7.x] Fixed #24637 -- Fixed database introspection with SQLite 3.8.9.

Backport of f8e8853b51476af1cc75a229dadc990c9ccf45ec from master

comment:11 by Tim Graham <timograham@…>, 10 years ago

In 309142d:

[1.8.x] Fixed #24637 -- Fixed database introspection with SQLite 3.8.9.

Backport of f8e8853b51476af1cc75a229dadc990c9ccf45ec from master

Note: See TracTickets for help on using tickets.
Back to Top