Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Russell Keith-Magee authored

Showing 1 changed file with 9 additions and 4 deletions. Show diff stats Hide diff stats

  1. 13  django/db/backends/__init__.py
13  django/db/backends/__init__.py
@@ -499,12 +499,14 @@ def django_table_names(self, only_existing=False):
499 499
         If only_existing is True, the resulting list will only include the tables
500 500
         that actually exist in the database.
501 501
         """
502  
-        from django.db import models
  502
+        from django.db import models, router
503 503
         tables = set()
504 504
         for app in models.get_apps():
505 505
             for model in models.get_models(app):
506 506
                 if not model._meta.managed:
507 507
                     continue
  508
+                if not router.allow_syncdb(self.connection.alias, model):
  509
+                    continue
508 510
                 tables.add(model._meta.db_table)
509 511
                 tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many])
510 512
         if only_existing:
@@ -513,18 +515,19 @@ def django_table_names(self, only_existing=False):
513 515
 
514 516
     def installed_models(self, tables):
515 517
         "Returns a set of all models represented by the provided list of table names."
516  
-        from django.db import models
  518
+        from django.db import models, router
517 519
         all_models = []
518 520
         for app in models.get_apps():
519 521
             for model in models.get_models(app):
520  
-                all_models.append(model)
  522
+                if router.allow_syncdb(self.connection.alias, model):
  523
+                    all_models.append(model)
521 524
         return set([m for m in all_models
522 525
             if self.table_name_converter(m._meta.db_table) in map(self.table_name_converter, tables)
523 526
         ])
524 527
 
525 528
     def sequence_list(self):
526 529
         "Returns a list of information about all DB sequences for all models in all apps."
527  
-        from django.db import models
  530
+        from django.db import models, router
528 531
 
529 532
         apps = models.get_apps()
530 533
         sequence_list = []
@@ -533,6 +536,8 @@ def sequence_list(self):
533 536
             for model in models.get_models(app):
534 537
                 if not model._meta.managed:
535 538
                     continue
  539
+                if not router.allow_syncdb(self.connection.alias, model):
  540
+                    continue
536 541
                 for f in model._meta.local_fields:
537 542
                     if isinstance(f, models.AutoField):
538 543
                         sequence_list.append({'table': model._meta.db_table, 'column': f.column})

0 notes on commit 29cb512

Please sign in to comment.
Something went wrong with that request. Please try again.