From 55c64af6bd58969eb20dca5286be25d47ace87bb Mon Sep 17 00:00:00 2001 From: Dave Hall Date: Thu, 18 Dec 2014 12:53:44 +0000 Subject: [PATCH] Fixing some transaction handling in MySQL with schema alterations --- .travis.yml | 6 +++--- src/watson/backends.py | 4 +++- src/watson/management/commands/installwatson.py | 2 -- src/watson/management/commands/uninstallwatson.py | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce3560d..ad6ac4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/src/watson/backends.py b/src/watson/backends.py index 71af2de..c05638f 100644 --- a/src/watson/backends.py +++ b/src/watson/backends.py @@ -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(""" diff --git a/src/watson/management/commands/installwatson.py b/src/watson/management/commands/installwatson.py index cbb967b..96c3568 100644 --- a/src/watson/management/commands/installwatson.py +++ b/src/watson/management/commands/installwatson.py @@ -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)) diff --git a/src/watson/management/commands/uninstallwatson.py b/src/watson/management/commands/uninstallwatson.py index d6738e4..b4bbf0d 100644 --- a/src/watson/management/commands/uninstallwatson.py +++ b/src/watson/management/commands/uninstallwatson.py @@ -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))