Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12976 -- Fixed the sequence reset commands issued by sqlflush …

…in a multidb setup. To achieve this, database introspection was modified to utilize routing information to determine if a model should be available. Thanks to pczapla for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 29cb5124a6cac5611618990f8361cc03b478ff9b 1 parent ca81ad4
@freakboy3742 freakboy3742 authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 django/db/backends/__init__.py
View
13 django/db/backends/__init__.py
@@ -499,12 +499,14 @@ def django_table_names(self, only_existing=False):
If only_existing is True, the resulting list will only include the tables
that actually exist in the database.
"""
- from django.db import models
+ from django.db import models, router
tables = set()
for app in models.get_apps():
for model in models.get_models(app):
if not model._meta.managed:
continue
+ if not router.allow_syncdb(self.connection.alias, model):
+ continue
tables.add(model._meta.db_table)
tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many])
if only_existing:
@@ -513,18 +515,19 @@ def django_table_names(self, only_existing=False):
def installed_models(self, tables):
"Returns a set of all models represented by the provided list of table names."
- from django.db import models
+ from django.db import models, router
all_models = []
for app in models.get_apps():
for model in models.get_models(app):
- all_models.append(model)
+ if router.allow_syncdb(self.connection.alias, model):
+ all_models.append(model)
return set([m for m in all_models
if self.table_name_converter(m._meta.db_table) in map(self.table_name_converter, tables)
])
def sequence_list(self):
"Returns a list of information about all DB sequences for all models in all apps."
- from django.db import models
+ from django.db import models, router
apps = models.get_apps()
sequence_list = []
@@ -533,6 +536,8 @@ def sequence_list(self):
for model in models.get_models(app):
if not model._meta.managed:
continue
+ if not router.allow_syncdb(self.connection.alias, model):
+ continue
for f in model._meta.local_fields:
if isinstance(f, models.AutoField):
sequence_list.append({'table': model._meta.db_table, 'column': f.column})
Please sign in to comment.
Something went wrong with that request. Please try again.