# Path: tests/compat.py
# def wrap_testdata(func):
#     return func
# 
# Path: tests/testapp/models.py
# class Alphabet(Model):
#     a = IntegerField(default=1)
#     b = IntegerField(default=2)
#     c = IntegerField(default=3)
#     d = CharField(max_length=32)
#     e = CharField(max_length=32, null=True)
#     f = IntegerField(null=True)
#     g = DecimalField(default=0, decimal_places=2, max_digits=10)
# 
# class Author(Model):
#     name = CharField(max_length=32, db_index=True)
#     tutor = ForeignKey("self", on_delete=CASCADE, null=True, related_name="tutees")
#     bio = TextField()
#     birthday = DateTimeField(null=True)
#     deathday = DateTimeField(null=True)
# 
# class DynamicModel(Model):
#     attrs = DynamicField(
#         spec={
#             "datetimey": dt.datetime,
#             "datey": dt.date,
#             "floaty": float,
#             "inty": int,
#             "stry": str,
#             "timey": dt.time,
#             "nesty": {"level2": str},
#         }
#     )
# 
#     @classmethod
#     def check(cls, **kwargs):
#         # Disable the checks on MySQL so that checks tests don't fail
#         if not (connection_is_mariadb(connection)):
#             return []
#         return super().check(**kwargs)
# 
#     def __str__(self):  # pragma: no cover
#         return ",".join(f"{key}:{value}" for key, value in self.attrs.items())
# 
# class JSONModel(Model):
#     # Something really weird and funky - change the fields on this model at
#     # import time 😱
#     attrs = JSONField(null=True)
# 
#     name = CharField(max_length=3)
# 
#     def __str__(self):  # pragma: no cover
#         return str(json.dumps(self.attrs))
# 
# Path: tests/testapp/test_dynamicfield.py
# class DynColTestCase(TestCase):
#     @classmethod
#     def setUpClass(cls):
#         if not (connection_is_mariadb(connection)):
#             raise SkipTest("Dynamic Columns require MariaDB")
#         super().setUpClass()
# 
# Path: tests/testapp/utils.py
# class print_all_queries:
#     def __init__(self, conn=None):
#         if conn is None:  # pragma: no branch
#             conn = connection
#         self.conn = conn
# 
#     def __enter__(self):
#         self.capturer = CaptureQueriesContext(self.conn)
#         self.capturer.__enter__()
#         return self
# 
#     def __exit__(self, a, b, c):
#         self.capturer.__exit__(a, b, c)
#         for q in self.capturer.captured_queries:
#             print(q["sql"])


import hashlib
import pytest
from unittest import SkipTest
from django.db import connection
from django.db.models import F, FloatField, IntegerField, Q, Value
from django.db.models.functions import Length, Lower, Upper
from django.test import TestCase
from django_mysql.models.functions import (
    CRC32,
    ELT,
    MD5,
    SHA1,
    SHA2,
    AsType,
    ColumnAdd,
    ColumnDelete,
    ColumnGet,
    ConcatWS,
    Field,
    If,
    JSONArrayAppend,
    JSONExtract,
    JSONInsert,
    JSONKeys,
    JSONLength,
    JSONReplace,
    JSONSet,
    LastInsertId,
    RegexpInstr,
    RegexpReplace,
    RegexpSubstr,
    Sign,
    UpdateXML,
    XMLExtractValue,
)
from django_mysql.utils import connection_is_mariadb
from tests.compat import wrap_testdata
from tests.testapp.models import Alphabet, Author, DynamicModel, JSONModel
from tests.testapp.test_dynamicfield import DynColTestCase
from tests.testapp.utils import print_all_queries
            d_tag__gt=""
        )
        ab = qs.get()
        assert ab.d_tag == "<tag>"

    def test_regex_substr_field(self):
        Alphabet.objects.create(d="This is the string", e=r"\bis\b")
        qs = (
            Alphabet.objects.annotate(substr=RegexpSubstr("d", F("e")))
            .filter(substr__gt="")
            .values_list("substr", flat=True)
        )
        substr = qs[0]
        assert substr == "is"

    def test_regex_substr_filter(self):
        Author.objects.create(name="Euripides")
        Author.objects.create(name="Frank Miller")
        Author.objects.create(name="Sophocles")
        qs = list(
            Author.objects.annotate(name_has_space=Length(RegexpSubstr("name", r"\s")))
            .filter(name_has_space=0)
            .order_by("id")
            .values_list("name", flat=True)
        )
        assert qs == ["Euripides", "Sophocles"]


class DynamicColumnsFunctionTests(DynColTestCase):
    @classmethod

# Path: tests/compat.py
# def wrap_testdata(func):
#     return func
# 
# Path: tests/testapp/models.py
# class Alphabet(Model):
#     a = IntegerField(default=1)
#     b = IntegerField(default=2)
#     c = IntegerField(default=3)
#     d = CharField(max_length=32)
#     e = CharField(max_length=32, null=True)
#     f = IntegerField(null=True)
#     g = DecimalField(default=0, decimal_places=2, max_digits=10)
# 
# class Author(Model):
#     name = CharField(max_length=32, db_index=True)
#     tutor = ForeignKey("self", on_delete=CASCADE, null=True, related_name="tutees")
#     bio = TextField()
#     birthday = DateTimeField(null=True)
#     deathday = DateTimeField(null=True)
# 
# class DynamicModel(Model):
#     attrs = DynamicField(
#         spec={
#             "datetimey": dt.datetime,
#             "datey": dt.date,
#             "floaty": float,
#             "inty": int,
#             "stry": str,
#             "timey": dt.time,
#             "nesty": {"level2": str},
#         }
#     )
# 
#     @classmethod
#     def check(cls, **kwargs):
#         # Disable the checks on MySQL so that checks tests don't fail
#         if not (connection_is_mariadb(connection)):
#             return []
#         return super().check(**kwargs)
# 
#     def __str__(self):  # pragma: no cover
#         return ",".join(f"{key}:{value}" for key, value in self.attrs.items())
# 
# class JSONModel(Model):
#     # Something really weird and funky - change the fields on this model at
#     # import time 😱
#     attrs = JSONField(null=True)
# 
#     name = CharField(max_length=3)
# 
#     def __str__(self):  # pragma: no cover
#         return str(json.dumps(self.attrs))
# 
# Path: tests/testapp/test_dynamicfield.py
# class DynColTestCase(TestCase):
#     @classmethod
#     def setUpClass(cls):
#         if not (connection_is_mariadb(connection)):
#             raise SkipTest("Dynamic Columns require MariaDB")
#         super().setUpClass()
# 
# Path: tests/testapp/utils.py
# class print_all_queries:
#     def __init__(self, conn=None):
#         if conn is None:  # pragma: no branch
#             conn = connection
#         self.conn = conn
# 
#     def __enter__(self):
#         self.capturer = CaptureQueriesContext(self.conn)
#         self.capturer.__enter__()
#         return self
# 
#     def __exit__(self, a, b, c):
#         self.capturer.__exit__(a, b, c)
#         for q in self.capturer.captured_queries:
#             print(q["sql"])


# Path: tests/testapp/test_functions.py
import hashlib
import pytest
from unittest import SkipTest
from django.db import connection
from django.db.models import F, FloatField, IntegerField, Q, Value
from django.db.models.functions import Length, Lower, Upper
from django.test import TestCase
from django_mysql.models.functions import (
    CRC32,
    ELT,
    MD5,
    SHA1,
    SHA2,
    AsType,
    ColumnAdd,
    ColumnDelete,
    ColumnGet,
    ConcatWS,
    Field,
    If,
    JSONArrayAppend,
    JSONExtract,
    JSONInsert,
    JSONKeys,
    JSONLength,
    JSONReplace,
    JSONSet,
    LastInsertId,
    RegexpInstr,
    RegexpReplace,
    RegexpSubstr,
    Sign,
    UpdateXML,
    XMLExtractValue,
)
from django_mysql.utils import connection_is_mariadb
from tests.compat import wrap_testdata
from tests.testapp.models import Alphabet, Author, DynamicModel, JSONModel
from tests.testapp.test_dynamicfield import DynColTestCase
from tests.testapp.utils import print_all_queries

            d_tag__gt=""
        )
        ab = qs.get()
        assert ab.d_tag == "<tag>"

    def test_regex_substr_field(self):
        Alphabet.objects.create(d="This is the string", e=r"\bis\b")
        qs = (
            Alphabet.objects.annotate(substr=RegexpSubstr("d", F("e")))
            .filter(substr__gt="")
            .values_list("substr", flat=True)
        )
        substr = qs[0]
        assert substr == "is"

    def test_regex_substr_filter(self):
        Author.objects.create(name="Euripides")
        Author.objects.create(name="Frank Miller")
        Author.objects.create(name="Sophocles")
        qs = list(
            Author.objects.annotate(name_has_space=Length(RegexpSubstr("name", r"\s")))
            .filter(name_has_space=0)
            .order_by("id")
            .values_list("name", flat=True)
        )
        assert qs == ["Euripides", "Sophocles"]


class DynamicColumnsFunctionTests(DynColTestCase):
    @classmethod

    @wrap_testdata