Disable select_for_update when checking the uniqueness of a
cabinet if the database backend is Oracle. GitHub issue #258. Thanks to @simeon-walker for the report. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- Fix document page widget appearance in the document page list view.
|
||||
- Make document version order deterministic.
|
||||
- Allow total page number instrospection of encrypted PDF with non ASCII user properties. GitLab issue #411.
|
||||
- Oracle database compatibility update in the cabinets app. GitHub #258.
|
||||
|
||||
2.6.1 (2017-07-18)
|
||||
==================
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
|
||||
from django.db import models, transaction
|
||||
from django.db import connection, models, transaction
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -64,7 +64,12 @@ class Cabinet(MPTTModel):
|
||||
# https://code.djangoproject.com/ticket/1751
|
||||
|
||||
with transaction.atomic():
|
||||
if Cabinet.objects.select_for_update().filter(parent=self.parent, label=self.label).exists():
|
||||
if connection.vendor == 'oracle':
|
||||
queryset = Cabinet.objects.filter(parent=self.parent, label=self.label)
|
||||
else:
|
||||
queryset = Cabinet.objects.select_for_update().filter(parent=self.parent, label=self.label)
|
||||
|
||||
if queryset.exists():
|
||||
params = {
|
||||
'model_name': _('Cabinet'),
|
||||
'field_labels': _('Parent and Label')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import transaction
|
||||
from django.db import connection, transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from rest_framework import serializers
|
||||
@@ -129,7 +129,12 @@ class WritableCabinetSerializer(serializers.ModelSerializer):
|
||||
# when there is a FK in the unique_together tuple
|
||||
# https://code.djangoproject.com/ticket/1751
|
||||
with transaction.atomic():
|
||||
if Cabinet.objects.select_for_update().filter(parent=data['parent'], label=data['label']).exists():
|
||||
if connection.vendor == 'oracle':
|
||||
queryset = Cabinet.objects.filter(parent=data['parent'], label=data['label'])
|
||||
else:
|
||||
queryset = Cabinet.objects.select_for_update().filter(parent=data['parent'], label=data['label'])
|
||||
|
||||
if queryset.exists():
|
||||
params = {
|
||||
'model_name': _('Cabinet'),
|
||||
'field_labels': _('Parent and Label')
|
||||
|
||||
Reference in New Issue
Block a user