From 533ab840b5f0ba3cd078aeff616a75b6160439d8 Mon Sep 17 00:00:00 2001 From: Parth Sharma Date: Tue, 25 Nov 2025 16:42:24 +0530 Subject: [PATCH 1/2] skipped tests failing on older version --- tests/aggregation/test_filter_argument.py | 9 ++- tests/aggregation/tests.py | 17 +++++ .../datetime/test_extract_trunc.py | 9 ++- tests/expressions/tests.py | 8 +++ tests/model_fields/test_charfield.py | 8 ++- tests/model_fields/test_jsonfield.py | 72 +++++++++++++++++++ tests/model_fields/test_textfield.py | 9 ++- 7 files changed, 128 insertions(+), 4 deletions(-) diff --git a/tests/aggregation/test_filter_argument.py b/tests/aggregation/test_filter_argument.py index 75835edb0bb4..8f0028589cde 100644 --- a/tests/aggregation/test_filter_argument.py +++ b/tests/aggregation/test_filter_argument.py @@ -18,7 +18,7 @@ ) from django.test import TestCase from django.test.utils import Approximate - +from django.db import connection from .models import Author, Book, Publisher @@ -145,6 +145,13 @@ def test_filtered_aggregate_ref_annotation(self): self.assertEqual(aggs["cnt"], 2) def test_filtered_aggregate_ref_subquery_annotation(self): + if connection.vendor == "singlestore": + # Check SingleStore version + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") aggs = Author.objects.annotate( earliest_book_year=Subquery( Book.objects.filter( diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 48266d97746b..be0f09cd3d5c 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1412,6 +1412,14 @@ 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 connection.vendor == "singlestore": + # Check SingleStore version + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") + latest_book_pubdate_qs = ( Book.objects.filter(publisher=OuterRef("pk")) .order_by("-pubdate") @@ -1470,6 +1478,15 @@ def test_aggregation_subquery_annotation_values(self): Subquery annotations and external aliases are excluded from the GROUP BY if they are not selected. """ + # Skip test for SingleStore 8.5 due to correlated subquery limitations + if connection.vendor == "singlestore": + # Check SingleStore version + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") + books_qs = ( Book.objects.annotate( first_author_the_same_age=Subquery( diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py index e576e6e46415..8fdd0e0ccdbd 100644 --- a/tests/db_functions/datetime/test_extract_trunc.py +++ b/tests/db_functions/datetime/test_extract_trunc.py @@ -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, @@ -1637,6 +1637,13 @@ def test_trunc_subquery_with_parameters(self): ) def test_extract_outerref(self): + if connection.vendor == "singlestore": + # Check SingleStore version + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") datetime_1 = datetime(2000, 1, 1) datetime_2 = datetime(2001, 3, 5) datetime_3 = datetime(2002, 1, 3) diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 63a7b40e83d9..08e76a22b29c 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -498,6 +498,14 @@ def test_exist_single_field_output_field(self): self.assertIsInstance(Exists(queryset).output_field, BooleanField) def test_subquery(self): + if connection.vendor == "singlestore": + # Check SingleStore version + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith(("8.5" ,"8.7")): + self.skipTest("SingleStore 8.5 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, diff --git a/tests/model_fields/test_charfield.py b/tests/model_fields/test_charfield.py index e841ed807a33..e7ba8a8787bd 100644 --- a/tests/model_fields/test_charfield.py +++ b/tests/model_fields/test_charfield.py @@ -1,5 +1,5 @@ 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 @@ -20,6 +20,12 @@ def test_lookup_integer_in_charfield(self): self.assertEqual(Post.objects.filter(title=9).count(), 0) def test_emoji(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + 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 😀") diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index c185cdb079e8..b42ff81ac653 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -414,6 +414,13 @@ def test_ordering_by_transform(self): self.assertSequenceEqual(query, expected) def test_ordering_grouping_by_key_transform(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + base_qs = NullableJSONModel.objects.filter(value__d__0__isnull=False) for qs in ( base_qs.order_by("value__d__0"), @@ -544,6 +551,13 @@ def test_nested_key_transform_on_subquery(self): ) def test_key_text_transform_char_lookup(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + qs = NullableJSONModel.objects.annotate( char_value=KeyTextTransform("foo", "value"), ).filter(char_value__startswith="bar") @@ -913,6 +927,13 @@ def test_array_key_contains(self): ) def test_key_iexact(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + self.assertIs( NullableJSONModel.objects.filter(value__foo__iexact="BaR").exists(), True ) @@ -991,36 +1012,80 @@ def test_key_contains(self): ) def test_key_icontains(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + self.assertIs( NullableJSONModel.objects.filter(value__foo__icontains="Ar").exists(), True ) def test_key_startswith(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + self.assertIs( NullableJSONModel.objects.filter(value__foo__startswith="b").exists(), True ) def test_key_istartswith(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") self.assertIs( NullableJSONModel.objects.filter(value__foo__istartswith="B").exists(), True ) def test_key_endswith(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") self.assertIs( NullableJSONModel.objects.filter(value__foo__endswith="r").exists(), True ) def test_key_iendswith(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") self.assertIs( NullableJSONModel.objects.filter(value__foo__iendswith="R").exists(), True ) def test_key_regex(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") self.assertIs( NullableJSONModel.objects.filter(value__foo__regex=r"^bar$").exists(), True ) def test_key_iregex(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") self.assertIs( NullableJSONModel.objects.filter(value__foo__iregex=r"^bAr$").exists(), True ) @@ -1140,6 +1205,13 @@ def test_join_key_transform_annotation_expression(self): ) def test_key_text_transform_from_lookup(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier supports it differently") + qs = NullableJSONModel.objects.annotate(b=KT("value__bax__foo")).filter( b__contains="ar", ) diff --git a/tests/model_fields/test_textfield.py b/tests/model_fields/test_textfield.py index 63d6f1cda2a3..d1890adf6b9f 100644 --- a/tests/model_fields/test_textfield.py +++ b/tests/model_fields/test_textfield.py @@ -1,5 +1,5 @@ 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 @@ -30,6 +30,13 @@ def test_lookup_integer_in_textfield(self): self.assertEqual(Post.objects.filter(body=24).count(), 0) def test_emoji(self): + if connection.vendor == "singlestore": + with connection.cursor() as cursor: + cursor.execute("SELECT @@memsql_version") + version = cursor.fetchone()[0] + if version.startswith("8.5"): + self.skipTest("SingleStore 8.5 and earlier have utf8mb4 encoding limitations") + p = Post.objects.create(title="Whatever", body="Smile 😀.") p.refresh_from_db() self.assertEqual(p.body, "Smile 😀.") From 7c6a512fb0107c5d12d874053ea6e867c7c41ead Mon Sep 17 00:00:00 2001 From: Parth Sharma Date: Wed, 26 Nov 2025 23:29:39 +0530 Subject: [PATCH 2/2] using a util function for version --- tests/aggregation/test_filter_argument.py | 12 +-- tests/aggregation/tests.py | 24 ++--- .../datetime/test_extract_trunc.py | 11 +-- tests/expressions/tests.py | 13 ++- tests/model_fields/test_charfield.py | 11 +-- tests/model_fields/test_jsonfield.py | 91 +++++-------------- tests/model_fields/test_textfield.py | 9 +- 7 files changed, 54 insertions(+), 117 deletions(-) diff --git a/tests/aggregation/test_filter_argument.py b/tests/aggregation/test_filter_argument.py index 8f0028589cde..af20f54d6116 100644 --- a/tests/aggregation/test_filter_argument.py +++ b/tests/aggregation/test_filter_argument.py @@ -20,7 +20,7 @@ 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 @@ -145,13 +145,9 @@ def test_filtered_aggregate_ref_annotation(self): self.assertEqual(aggs["cnt"], 2) def test_filtered_aggregate_ref_subquery_annotation(self): - if connection.vendor == "singlestore": - # Check SingleStore version - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") + 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( diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index be0f09cd3d5c..3e7bbe52280b 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -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 @@ -1412,14 +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 connection.vendor == "singlestore": - # Check SingleStore version - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") - + 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") @@ -1478,15 +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. """ - # Skip test for SingleStore 8.5 due to correlated subquery limitations - if connection.vendor == "singlestore": - # Check SingleStore version - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") - + 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( diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py index 8fdd0e0ccdbd..0da150e81c8c 100644 --- a/tests/db_functions/datetime/test_extract_trunc.py +++ b/tests/db_functions/datetime/test_extract_trunc.py @@ -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): @@ -1637,13 +1638,9 @@ def test_trunc_subquery_with_parameters(self): ) def test_extract_outerref(self): - if connection.vendor == "singlestore": - # Check SingleStore version - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") + 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) diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 08e76a22b29c..1ee225be4c78 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -87,6 +87,8 @@ Time, ) +from django_singlestore.utils import check_version_ge + class BasicExpressionsTests(TestCase): @classmethod @@ -498,13 +500,10 @@ def test_exist_single_field_output_field(self): self.assertIsInstance(Exists(queryset).output_field, BooleanField) def test_subquery(self): - if connection.vendor == "singlestore": - # Check SingleStore version - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith(("8.5" ,"8.7")): - self.skipTest("SingleStore 8.5 has limitations on correlated subqueries") + + 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"), diff --git a/tests/model_fields/test_charfield.py b/tests/model_fields/test_charfield.py index e7ba8a8787bd..50ed10edfc46 100644 --- a/tests/model_fields/test_charfield.py +++ b/tests/model_fields/test_charfield.py @@ -3,6 +3,7 @@ from django.test import SimpleTestCase, TestCase from .models import Post +from django_singlestore.utils import check_version_ge class TestCharField(TestCase): @@ -20,12 +21,10 @@ def test_lookup_integer_in_charfield(self): self.assertEqual(Post.objects.filter(title=9).count(), 0) def test_emoji(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier have utf8mb4 encoding limitations") + + 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 😀") diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index b42ff81ac653..ca2d55a8fe51 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -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): @@ -414,12 +416,9 @@ def test_ordering_by_transform(self): self.assertSequenceEqual(query, expected) def test_ordering_grouping_by_key_transform(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 ( @@ -551,12 +550,8 @@ def test_nested_key_transform_on_subquery(self): ) def test_key_text_transform_char_lookup(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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"), @@ -927,12 +922,8 @@ def test_array_key_contains(self): ) def test_key_iexact(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 @@ -1012,80 +1003,52 @@ def test_key_contains(self): ) def test_key_icontains(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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 ) @@ -1205,12 +1168,8 @@ def test_join_key_transform_annotation_expression(self): ) def test_key_text_transform_from_lookup(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier supports it differently") + 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", diff --git a/tests/model_fields/test_textfield.py b/tests/model_fields/test_textfield.py index d1890adf6b9f..05b219b19279 100644 --- a/tests/model_fields/test_textfield.py +++ b/tests/model_fields/test_textfield.py @@ -3,6 +3,7 @@ from django.test import SimpleTestCase, TestCase from .models import Post +from django_singlestore.utils import check_version_ge class TextFieldTests(TestCase): @@ -30,12 +31,8 @@ def test_lookup_integer_in_textfield(self): self.assertEqual(Post.objects.filter(body=24).count(), 0) def test_emoji(self): - if connection.vendor == "singlestore": - with connection.cursor() as cursor: - cursor.execute("SELECT @@memsql_version") - version = cursor.fetchone()[0] - if version.startswith("8.5"): - self.skipTest("SingleStore 8.5 and earlier have utf8mb4 encoding limitations") + 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()