Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15573: Forced the default site id to be 1 when creating test d…

…atabases, to prevent a large number of errors when running the tests using the oracle backend.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16027 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d3c08fd8139416942da30bb22e529357e7708e2c 1 parent 13bb069
Ian Kelly authored April 15, 2011

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  django/db/backends/creation.py
8  django/db/backends/creation.py
@@ -247,6 +247,14 @@ def create_test_db(self, verbosity=1, autoclobber=False):
247 247
             verbosity=max(verbosity - 1, 0),
248 248
             interactive=False,
249 249
             database=self.connection.alias)
  250
+        
  251
+        # One effect of calling syncdb followed by flush is that the id of the
  252
+        # default site may or may not be 1, depending on how the sequence was
  253
+        # reset.  If the sites app is loaded, then we coerce it.
  254
+        from django.db.models import get_model
  255
+        Site = get_model('sites', 'Site')
  256
+        if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
  257
+            Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
250 258
 
251 259
         from django.core.cache import get_cache
252 260
         from django.core.cache.backends.db import BaseDatabaseCache

0 notes on commit d3c08fd

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