summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/backends/sqlite3/introspection.py27
1 files changed, 5 insertions, 22 deletions
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py
index 490606c64d..2a5c64dd26 100644
--- a/django/db/backends/sqlite3/introspection.py
+++ b/django/db/backends/sqlite3/introspection.py
@@ -83,18 +83,13 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
Return a description of the table with the DB-API cursor.description
interface.
"""
+ cursor.execute('PRAGMA table_info(%s)' % self.connection.ops.quote_name(table_name))
return [
FieldInfo(
- info['name'],
- info['type'],
- None,
- info['size'],
- None,
- None,
- info['null_ok'],
- info['default'],
- info['pk'] == 1,
- ) for info in self._table_info(cursor, table_name)
+ name, data_type, None, get_field_size(data_type), None, None,
+ not notnull, default, pk == 1,
+ )
+ for cid, name, data_type, notnull, default, pk in cursor.fetchall()
]
def get_sequences(self, cursor, table_name, table_fields=()):
@@ -211,18 +206,6 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
return m.group(1) if m.group(1) else m.group(2)
return None
- def _table_info(self, cursor, name):
- cursor.execute('PRAGMA table_info(%s)' % self.connection.ops.quote_name(name))
- # cid, name, type, notnull, default_value, pk
- return [{
- 'name': field[1],
- 'type': field[2],
- 'size': get_field_size(field[2]),
- 'null_ok': not field[3],
- 'default': field[4],
- 'pk': field[5], # undocumented
- } for field in cursor.fetchall()]
-
def _get_foreign_key_constraints(self, cursor, table_name):
constraints = {}
cursor.execute('PRAGMA foreign_key_list(%s)' % self.connection.ops.quote_name(table_name))