From bff748df3e1e1c0077e02df2b77bda2b827ad129 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Fri, 18 Jan 2019 22:44:09 +0000 Subject: [PATCH] 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. --- django/db/backends/sqlite3/introspection.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index 2a5c64dd26..0d27c5511b 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -40,6 +40,7 @@ class FlexibleFieldLookupDict: 'real': 'FloatField', 'text': 'TextField', 'char': 'CharField', + 'varchar': 'CharField', 'blob': 'BinaryField', 'date': 'DateField', 'datetime': 'DateTimeField', @@ -47,14 +48,8 @@ class FlexibleFieldLookupDict: } def __getitem__(self, key): - key = key.lower() - try: - return self.base_data_types_reverse[key] - except KeyError: - size = get_field_size(key) - if size is not None: - return ('CharField', {'max_length': size}) - raise KeyError + key = key.lower().split('(', 1)[0].strip() + return self.base_data_types_reverse[key] class DatabaseIntrospection(BaseDatabaseIntrospection):