Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/aggregation/test_filter_argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
)
from django.test import TestCase
from django.test.utils import Approximate

from django.db import connection
from .models import Author, Book, Publisher

from django_singlestore.utils import check_version_ge

class FilteredAggregateTests(TestCase):
@classmethod
Expand Down Expand Up @@ -145,6 +145,9 @@ def test_filtered_aggregate_ref_annotation(self):
self.assertEqual(aggs["cnt"], 2)

def test_filtered_aggregate_ref_subquery_annotation(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 has limitations on correlated subqueries")

aggs = Author.objects.annotate(
earliest_book_year=Subquery(
Book.objects.filter(
Expand Down
7 changes: 7 additions & 0 deletions tests/aggregation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math
import re
from decimal import Decimal
from django_singlestore.utils import check_version_ge

from django.core.exceptions import FieldError
from django.db import connection
Expand Down Expand Up @@ -1412,6 +1413,9 @@ def test_arguments_must_be_expressions(self):
def test_aggregation_subquery_annotation(self):
"""Subquery annotations are excluded from the GROUP BY if they are
not explicitly grouped against."""
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 has limitations on correlated subqueries")

latest_book_pubdate_qs = (
Book.objects.filter(publisher=OuterRef("pk"))
.order_by("-pubdate")
Expand Down Expand Up @@ -1470,6 +1474,9 @@ def test_aggregation_subquery_annotation_values(self):
Subquery annotations and external aliases are excluded from the GROUP
BY if they are not selected.
"""
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 has limitations on correlated subqueries")

books_qs = (
Book.objects.annotate(
first_author_the_same_age=Subquery(
Expand Down
6 changes: 5 additions & 1 deletion tests/db_functions/datetime/test_extract_trunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import timezone as datetime_timezone

from django.conf import settings
from django.db import DataError, OperationalError
from django.db import DataError, OperationalError, connection
from django.db.models import (
DateField,
DateTimeField,
Expand Down Expand Up @@ -48,6 +48,7 @@
from django.utils import timezone

from ..models import Author, DTModel, Fan
from django_singlestore.utils import check_version_ge


def truncate_to(value, kind, tzinfo=None):
Expand Down Expand Up @@ -1637,6 +1638,9 @@ def test_trunc_subquery_with_parameters(self):
)

def test_extract_outerref(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 has limitations on correlated subqueries")

datetime_1 = datetime(2000, 1, 1)
datetime_2 = datetime(2001, 3, 5)
datetime_3 = datetime(2002, 1, 3)
Expand Down
7 changes: 7 additions & 0 deletions tests/expressions/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
Time,
)

from django_singlestore.utils import check_version_ge


class BasicExpressionsTests(TestCase):
@classmethod
Expand Down Expand Up @@ -498,6 +500,11 @@ def test_exist_single_field_output_field(self):
self.assertIsInstance(Exists(queryset).output_field, BooleanField)

def test_subquery(self):

if not check_version_ge(connection, "8.9"):
self.skipTest("SingleStore prior to 8.9 has limitations on correlated subqueries")


Company.objects.filter(name="Example Inc.").update(
point_of_contact=Employee.objects.get(firstname="Joe", lastname="Smith"),
ceo=self.max,
Expand Down
7 changes: 6 additions & 1 deletion tests/model_fields/test_charfield.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.db import models, connection
from django.test import SimpleTestCase, TestCase

from .models import Post
from django_singlestore.utils import check_version_ge


class TestCharField(TestCase):
Expand All @@ -20,6 +21,10 @@ def test_lookup_integer_in_charfield(self):
self.assertEqual(Post.objects.filter(title=9).count(), 0)

def test_emoji(self):

if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore 8.5 and earlier have utf8mb4 encoding limitations")

p = Post.objects.create(title="Smile 😀", body="Whatever.")
p.refresh_from_db()
self.assertEqual(p.title, "Smile 😀")
Expand Down
31 changes: 31 additions & 0 deletions tests/model_fields/test_jsonfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

from .models import CustomJSONDecoder, JSONModel, NullableJSONModel, RelatedJSONModel

from django_singlestore.utils import check_version_ge


@skipUnlessDBFeature("supports_json_field")
class JSONFieldTests(TestCase):
Expand Down Expand Up @@ -414,6 +416,10 @@ def test_ordering_by_transform(self):
self.assertSequenceEqual(query, expected)

def test_ordering_grouping_by_key_transform(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")


base_qs = NullableJSONModel.objects.filter(value__d__0__isnull=False)
for qs in (
base_qs.order_by("value__d__0"),
Expand Down Expand Up @@ -544,6 +550,9 @@ def test_nested_key_transform_on_subquery(self):
)

def test_key_text_transform_char_lookup(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

qs = NullableJSONModel.objects.annotate(
char_value=KeyTextTransform("foo", "value"),
).filter(char_value__startswith="bar")
Expand Down Expand Up @@ -913,6 +922,9 @@ def test_array_key_contains(self):
)

def test_key_iexact(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

self.assertIs(
NullableJSONModel.objects.filter(value__foo__iexact="BaR").exists(), True
)
Expand Down Expand Up @@ -991,36 +1003,52 @@ def test_key_contains(self):
)

def test_key_icontains(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

self.assertIs(
NullableJSONModel.objects.filter(value__foo__icontains="Ar").exists(), True
)

def test_key_startswith(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

self.assertIs(
NullableJSONModel.objects.filter(value__foo__startswith="b").exists(), True
)

def test_key_istartswith(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")
self.assertIs(
NullableJSONModel.objects.filter(value__foo__istartswith="B").exists(), True
)

def test_key_endswith(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")
self.assertIs(
NullableJSONModel.objects.filter(value__foo__endswith="r").exists(), True
)

def test_key_iendswith(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")
self.assertIs(
NullableJSONModel.objects.filter(value__foo__iendswith="R").exists(), True
)

def test_key_regex(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")
self.assertIs(
NullableJSONModel.objects.filter(value__foo__regex=r"^bar$").exists(), True
)

def test_key_iregex(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")
self.assertIs(
NullableJSONModel.objects.filter(value__foo__iregex=r"^bAr$").exists(), True
)
Expand Down Expand Up @@ -1140,6 +1168,9 @@ def test_join_key_transform_annotation_expression(self):
)

def test_key_text_transform_from_lookup(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

qs = NullableJSONModel.objects.annotate(b=KT("value__bax__foo")).filter(
b__contains="ar",
)
Expand Down
6 changes: 5 additions & 1 deletion tests/model_fields/test_textfield.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django import forms
from django.db import models
from django.db import models, connection
from django.test import SimpleTestCase, TestCase

from .models import Post
from django_singlestore.utils import check_version_ge


class TextFieldTests(TestCase):
Expand Down Expand Up @@ -30,6 +31,9 @@ def test_lookup_integer_in_textfield(self):
self.assertEqual(Post.objects.filter(body=24).count(), 0)

def test_emoji(self):
if not check_version_ge(connection, "8.7"):
self.skipTest("SingleStore prior to 8.7 supports it differently")

p = Post.objects.create(title="Whatever", body="Smile 😀.")
p.refresh_from_db()
self.assertEqual(p.body, "Smile 😀.")
Expand Down
Loading