Fixing some transaction handling in MySQL with schema alterations

This commit is contained in:
Dave Hall 2014-12-18 12:53:44 +00:00
parent f51b15942a
commit 55c64af6bd
4 changed files with 6 additions and 8 deletions

View file

@ -35,9 +35,9 @@ matrix:
- python: 3.4
env: DJANGO=django==1.7.1 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis"
allow_failures:
- DJANGO=django==1.7.1
- DJANGO=django==1.7.1 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres"
- DJANGO=django==1.7.1 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis"
- env: DJANGO=django==1.7.1
- env: DJANGO=django==1.7.1 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres"
- env: DJANGO=django==1.7.1 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis"
fast_finish: true
services:
- postgresql

View file

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import re, abc
from django.contrib.contenttypes.models import ContentType
from django.db import connection
from django.db import connection, transaction
from django.db.models import Q
from django.utils.encoding import force_text
from django.utils import six
@ -181,6 +181,7 @@ class PostgresSearchBackend(SearchBackend):
""")
return bool(cursor.fetchall())
@transaction.atomic()
def do_install(self):
"""Executes the PostgreSQL specific SQL code to install django-watson."""
connection.cursor().execute("""
@ -220,6 +221,7 @@ class PostgresSearchBackend(SearchBackend):
search_config = self.search_config
))
@transaction.atomic()
def do_uninstall(self):
"""Executes the PostgreSQL specific SQL code to uninstall django-watson."""
connection.cursor().execute("""

View file

@ -3,7 +3,6 @@
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand
from django.db import transaction
from watson.registration import get_backend
@ -12,7 +11,6 @@ class Command(NoArgsCommand):
help = "Creates the database indices needed by django-watson."
@transaction.atomic()
def handle_noargs(self, **options):
"""Runs the management command."""
verbosity = int(options.get("verbosity", 1))

View file

@ -3,7 +3,6 @@
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand
from django.db import transaction
from watson.registration import get_backend
@ -12,7 +11,6 @@ class Command(NoArgsCommand):
help = "Destroys the database indices needed by django-watson."
@transaction.atomic()
def handle_noargs(self, **options):
"""Runs the management command."""
verbosity = int(options.get("verbosity", 1))