# 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
                attrs2=ColumnAdd("attrs", {"another": "key"})
            ).values_list("attrs2", flat=True)
        )
        assert results == [
            {"flote": 1.0, "sub": {"document": "store"}, "another": "key"}
        ]

    def test_add_nested(self):
        with pytest.raises(ValueError) as excinfo:
            list(
                DynamicModel.objects.annotate(
                    attrs2=ColumnAdd("attrs", {"sub2": {"document": "store"}})
                ).values_list("attrs2", flat=True)
            )
        assert "nested values is not supported" in str(excinfo.value)

    def test_add_update(self):
        DynamicModel.objects.update(attrs=ColumnAdd("attrs", {"over": 9000}))
        m = DynamicModel.objects.get()
        assert m.attrs == {"flote": 1.0, "sub": {"document": "store"}, "over": 9000}

    def test_as_type_instantiation(self):
        with pytest.raises(ValueError) as excinfo:
            AsType(1, "PANTS")
        assert "Invalid data_type 'PANTS'" in str(excinfo.value)

    def test_add_update_typed(self):
        DynamicModel.objects.update(
            attrs=ColumnAdd("attrs", {"over": AsType(9000, "DOUBLE")})
        )

# 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

                attrs2=ColumnAdd("attrs", {"another": "key"})
            ).values_list("attrs2", flat=True)
        )
        assert results == [
            {"flote": 1.0, "sub": {"document": "store"}, "another": "key"}
        ]

    def test_add_nested(self):
        with pytest.raises(ValueError) as excinfo:
            list(
                DynamicModel.objects.annotate(
                    attrs2=ColumnAdd("attrs", {"sub2": {"document": "store"}})
                ).values_list("attrs2", flat=True)
            )
        assert "nested values is not supported" in str(excinfo.value)

    def test_add_update(self):
        DynamicModel.objects.update(attrs=ColumnAdd("attrs", {"over": 9000}))
        m = DynamicModel.objects.get()
        assert m.attrs == {"flote": 1.0, "sub": {"document": "store"}, "over": 9000}

    def test_as_type_instantiation(self):
        with pytest.raises(ValueError) as excinfo:
            AsType(1, "PANTS")
        assert "Invalid data_type 'PANTS'" in str(excinfo.value)

    def test_add_update_typed(self):
        DynamicModel.objects.update(
            attrs=ColumnAdd("attrs", {"over": AsType(9000, "DOUBLE")})
        )

        m = DynamicModel.objects.get()