summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2010-10-31 00:53:58 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2010-10-31 00:53:58 +0000
commitfa8f0cb2d841d8187de9d3723bd9e1104db1ace1 (patch)
tree881aad19c1212d475fdd1a7da20509ea561923b1
parentaa951eb8ea5e3986ed8b76f55f5f4741eec0e717 (diff)
When looking for django tables which exist, query for all tables once, not once *per table*.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/flush.py1
-rw-r--r--django/core/management/sql.py4
-rw-r--r--django/db/backends/__init__.py7
-rw-r--r--django/db/backends/sqlite3/introspection.py3
4 files changed, 10 insertions, 5 deletions
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index 093c6db7b9..bcadb9671a 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -9,7 +9,6 @@ from django.core.management.sql import sql_flush, emit_post_sync_signal
from django.utils.importlib import import_module
-
class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + (
make_option('--noinput', action='store_false', dest='interactive', default=True,
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
index 86d91fa8b7..01fc20fd4c 100644
--- a/django/core/management/sql.py
+++ b/django/core/management/sql.py
@@ -111,7 +111,9 @@ def sql_flush(style, connection, only_django=False):
tables = connection.introspection.django_table_names(only_existing=True)
else:
tables = connection.introspection.table_names()
- statements = connection.ops.sql_flush(style, tables, connection.introspection.sequence_list())
+ statements = connection.ops.sql_flush(
+ style, tables, connection.introspection.sequence_list()
+ )
return statements
def sql_custom(app, style, connection):
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 2843e0d4c3..25587a7526 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -615,7 +615,12 @@ class BaseDatabaseIntrospection(object):
tables.add(model._meta.db_table)
tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many])
if only_existing:
- tables = [t for t in tables if self.table_name_converter(t) in self.table_names()]
+ existing_tables = self.table_names()
+ tables = [
+ t
+ for t in tables
+ if self.table_name_converter(t) in existing_tables
+ ]
return tables
def installed_models(self, tables):
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py
index c243e58c8e..7f14941abf 100644
--- a/django/db/backends/sqlite3/introspection.py
+++ b/django/db/backends/sqlite3/introspection.py
@@ -4,7 +4,7 @@ from django.db.backends import BaseDatabaseIntrospection
# This light wrapper "fakes" a dictionary interface, because some SQLite data
# types include variables in them -- e.g. "varchar(30)" -- and can't be matched
# as a simple dictionary lookup.
-class FlexibleFieldLookupDict:
+class FlexibleFieldLookupDict(object):
# Maps SQL types to Django Field types. Some of the SQL types have multiple
# entries here because SQLite allows for anything and doesn't normalize the
# field type; it uses whatever was given.
@@ -138,4 +138,3 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
'null_ok': not field[3],
'pk': field[5] # undocumented
} for field in cursor.fetchall()]
-