Skip to content

Commit

Permalink
When looking for django tables which exist, query for all tables once…
Browse files Browse the repository at this point in the history
…, not once *per table*.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
alex committed Oct 31, 2010
1 parent aa951eb commit fa8f0cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion django/core/management/commands/flush.py
Expand Up @@ -9,7 +9,6 @@
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,
Expand Down
4 changes: 3 additions & 1 deletion django/core/management/sql.py
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion django/db/backends/__init__.py
Expand Up @@ -615,7 +615,12 @@ def django_table_names(self, only_existing=False):
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):
Expand Down
3 changes: 1 addition & 2 deletions django/db/backends/sqlite3/introspection.py
Expand Up @@ -4,7 +4,7 @@
# 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.
Expand Down Expand Up @@ -138,4 +138,3 @@ def _table_info(self, cursor, name):
'null_ok': not field[3],
'pk': field[5] # undocumented
} for field in cursor.fetchall()]

0 comments on commit fa8f0cb

Please sign in to comment.