[Django] #30115: inspectdb, TypeError: unhashable type: 'dict'

4 views
Skip to first unread message

Django

unread,
Jan 18, 2019, 9:41:15 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb, TypeError: unhashable type: 'dict'
-----------------------------------------+------------------------
Reporter: Can Sarıgöl | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
I created a project with version 2.2a1 and run migrate after then run
inspectdb. I got this error

{{{
class DjangoSession(models.Model):
Traceback (most recent call last):
File "./manage.py", line 21, in <module>
main()
File "./manage.py", line 17, in main
execute_from_command_line(sys.argv)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/__init__.py", line 381, in
execute_from_command_line
utility.execute()
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/commands/inspectdb.py", line 34, in
handle
for line in self.handle_inspection(options):
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/commands/inspectdb.py", line 131, in
handle_inspection
field_type, field_params, field_notes =
self.get_field_type(connection, table_name, row)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/core/management/commands/inspectdb.py", line 239, in
get_field_type
field_type = connection.introspection.get_field_type(row.type_code,
row)
File
"/Users/can/Documents/Contribute_projects/Tests/django2_2_alfa2/venv/lib/python3.7
/site-packages/django/db/backends/sqlite3/introspection.py", line 65, in
get_field_type
if description.pk and field_type in {'BigIntegerField',
'IntegerField'}:
TypeError: unhashable type: 'dict'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30115>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 18, 2019, 9:46:21 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb for sqlite3, TypeError: unhashable type: 'dict'
-------------------------------+--------------------------------------

Reporter: Can Sarıgöl | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:1>

Django

unread,
Jan 18, 2019, 9:57:50 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb for sqlite3, TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------

Reporter: Can Sarıgöl | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* type: Uncategorized => Bug
* component: Uncategorized => Database layer (models, ORM)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

OK, yes, thanks for the report.

This works against 2.1.5 but errors as reported against 2.2a1:

{{{
django-admin startproject ticket_30115
cd ticket_30115/
./manage.py migrate
./manage.py inspectdb
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:2>

Django

unread,
Jan 18, 2019, 10:04:11 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb for sqlite3, TypeError: unhashable type: 'dict'
-------------------------------+--------------------------------------

Reporter: Can Sarıgöl | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Can Sarıgöl):

* type: Bug => Uncategorized
* component: Database layer (models, ORM) => Uncategorized
* severity: Release blocker => Normal
* stage: Accepted => Unreviewed


Comment:

[https://code.djangoproject.com/ticket/30115 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:3>

Django

unread,
Jan 18, 2019, 10:06:38 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb for sqlite3, TypeError: unhashable type: 'dict'
-------------------------------+--------------------------------------
Reporter: Can Sarıgöl | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Can Sarıgöl):

* type: Uncategorized => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:4>

Django

unread,
Jan 18, 2019, 10:10:05 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes with TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------

Reporter: Can Sarıgöl | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_tests: 0 => 1
* easy: 1 => 0


Comment:

Is that code untested or this caused by a version of SQLite that's
untested on Jenkins?

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:5>

Django

unread,
Jan 18, 2019, 10:16:25 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes with TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Can
| Sarıgöl
Type: Bug | Status: assigned

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Can Sarıgöl):

* owner: nobody => Can Sarıgöl
* status: new => assigned


Comment:

I am adding test for it

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:6>

Django

unread,
Jan 18, 2019, 10:20:03 AM1/18/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes with TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Can
| Sarıgöl
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

{{{
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.24.0'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:7>

Django

unread,
Jan 18, 2019, 6:31:37 PM1/18/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes with TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Can
| Sarıgöl
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Nick Pope):

Sorry about this. I clearly forgot to take the special case of a tuple of
`(field_type, field_params_dict)` into account, `field_params_dict` being
the source of the error.

It turns out that this special case was a hack to handle `max_length` for
`CharField` on SQLite only which was introduced by
9ede371c85a97406eecb19974ab01163839636a0.

Since a9a773ff38a9fd28085e8b62b8a160c4e2ea5efb, size is returned by
`get_table_description()` on SQLite so `row.internal_size` is always
overriding the `max_length` returned in `field_params_dict`.

Here is a [https://github.com/django/django/pull/10871 PR] that fixes the
issue by removing this legacy approach to handling `max_length`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:8>

Django

unread,
Jan 18, 2019, 6:33:03 PM1/18/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes with TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Nick Pope

Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

* owner: Can Sarıgöl => Nick Pope
* needs_tests: 1 => 0


Comment:

I think no tests should be needed as we're removing the code that caused
the broken behaviour.

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:9>

Django

unread,
Jan 22, 2019, 7:07:21 PM1/22/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes when introspecting varchar primary key with

TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Nick Pope
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:10>

Django

unread,
Jan 22, 2019, 7:20:40 PM1/22/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes when introspecting varchar primary key with
TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Nick Pope
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"bff748df3e1e1c0077e02df2b77bda2b827ad129" bff748df]:
{{{
#!CommitTicketReference repository=""
revision="bff748df3e1e1c0077e02df2b77bda2b827ad129"
Fixed #30115 -- Fixed SQLite introspection crash with a varchar primary
key.

Removed obsolete max_length handling for CharField that caused the issue.
Regression in a35d2a4510d5beec398b1007aaa26492d6aedf97.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:11>

Django

unread,
Jan 22, 2019, 7:34:50 PM1/22/19
to django-...@googlegroups.com
#30115: inspectdb on SQLite crashes when introspecting varchar primary key with
TypeError: unhashable type: 'dict'
-------------------------------------+-------------------------------------
Reporter: Can Sarıgöl | Owner: Nick Pope
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e53e64280df417c1f1acd63171746b28cd42edef" e53e642]:
{{{
#!CommitTicketReference repository=""
revision="e53e64280df417c1f1acd63171746b28cd42edef"
[2.2.x] Fixed #30115 -- Fixed SQLite introspection crash with a varchar
primary key.

Removed obsolete max_length handling for CharField that caused the issue.
Regression in a35d2a4510d5beec398b1007aaa26492d6aedf97.

Backport of bff748df3e1e1c0077e02df2b77bda2b827ad129 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30115#comment:12>

Reply all
Reply to author
Forward
0 new messages