Skip to content

Commit b15f939

Browse files
committed
skip union tests on transactions
1 parent 57dcc2f commit b15f939

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

django_mongodb_backend/features.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,8 @@ def supports_atlas_search(self):
589589
return False
590590
else:
591591
return True
592+
593+
@cached_property
594+
def supports_select_union(self):
595+
# Stage not supported inside of a multi-document transaction: $unionWith
596+
return not self.supports_transactions

tests/queries_/test_objectid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from bson import ObjectId
22
from django.core.exceptions import ValidationError
3-
from django.test import TestCase
3+
from django.test import TestCase, skipUnlessDBFeature
44

55
from .models import Order, OrderItem, Tag
66

@@ -75,13 +75,15 @@ def test_filter_parent_by_children_values_obj(self):
7575
parent_qs = Tag.objects.filter(children__id__in=child_ids).distinct().order_by("name")
7676
self.assertSequenceEqual(parent_qs, [self.t1])
7777

78+
@skipUnlessDBFeature("supports_select_union")
7879
def test_filter_group_id_union_with_str(self):
7980
"""Combine queries using union with string values."""
8081
qs_a = Tag.objects.filter(group_id=self.group_id_str_1)
8182
qs_b = Tag.objects.filter(group_id=self.group_id_str_2)
8283
union_qs = qs_a.union(qs_b).order_by("name")
8384
self.assertSequenceEqual(union_qs, [self.t3, self.t4])
8485

86+
@skipUnlessDBFeature("supports_select_union")
8587
def test_filter_group_id_union_with_obj(self):
8688
"""Combine queries using union with ObjectId values."""
8789
qs_a = Tag.objects.filter(group_id=self.group_id_obj_1)

0 commit comments

Comments
 (0)