Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.3.X] Fixed #15573: Forced the default site id to be 1 when creating

test databases, to prevent a large number of errors when running the 
tests using the oracle backend. Backport of r16027 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 79bb9c145620ad6b4b424e2390c6e0b6905c122b 1 parent 05054ab
Ian Kelly authored April 16, 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
@@ -374,6 +374,14 @@ def create_test_db(self, verbosity=1, autoclobber=False):
374 374
             verbosity=max(verbosity - 1, 0),
375 375
             interactive=False,
376 376
             database=self.connection.alias)
  377
+        
  378
+        # One effect of calling syncdb followed by flush is that the id of the
  379
+        # default site may or may not be 1, depending on how the sequence was
  380
+        # reset.  If the sites app is loaded, then we coerce it.
  381
+        from django.db.models import get_model
  382
+        Site = get_model('sites', 'Site')
  383
+        if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
  384
+            Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
377 385
 
378 386
         from django.core.cache import get_cache
379 387
         from django.core.cache.backends.db import BaseDatabaseCache

0 notes on commit 79bb9c1

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