# Path: tests/compat.py
# def wrap_testdata(func):
#     return func
# 
# Path: tests/testapp/models.py
# 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 SpeclessDynamicModel(Model):
#     attrs = DynamicField()
# 
#     @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())


import datetime as dt
import json
import mariadb_dyncol
import pytest
from unittest import SkipTest, mock
from django.core import serializers
from django.core.exceptions import FieldError
from django.db import connection, models
from django.db.migrations.writer import MigrationWriter
from django.db.models import CharField, Transform
from django.test import TestCase
from django.test.utils import isolate_apps
from django_mysql.models import DynamicField
from django_mysql.utils import connection_is_mariadb
from tests.compat import wrap_testdata
from tests.testapp.models import DynamicModel, SpeclessDynamicModel
        from django_mysql.models.fields import DynamicField as DField
        from django_mysql.models.fields.dynamic import DynamicField as DField
            ),
        ]
        DynamicModel.objects.bulk_create(cls.objs)
        cls.objs = list(DynamicModel.objects.order_by("id"))

    def test_equal(self):
        assert list(DynamicModel.objects.filter(attrs={"a": "b"})) == self.objs[:1]

    def test_exact(self):
        assert (
            list(DynamicModel.objects.filter(attrs__exact={"a": "b"})) == self.objs[:1]
        )

    def test_preexisting_transforms_work_fine(self):
        assert list(DynamicModel.objects.filter(attrs__dumb="notdumb")) == []

    def test_non_existent_transform(self):
        with pytest.raises(FieldError):
            DynamicModel.objects.filter(attrs__nonexistent="notdumb")

    def test_has_key(self):
        assert list(DynamicModel.objects.filter(attrs__has_key="c")) == self.objs[1:3]

    def test_key_transform_datey(self):
        assert list(DynamicModel.objects.filter(attrs__datey=dt.date(2001, 1, 4))) == [
            self.objs[4]
        ]

    def test_key_transform_datey_DATE(self):
        assert list(

# Path: tests/compat.py
# def wrap_testdata(func):
#     return func
# 
# Path: tests/testapp/models.py
# 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 SpeclessDynamicModel(Model):
#     attrs = DynamicField()
# 
#     @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())


# Path: tests/testapp/test_dynamicfield.py
import datetime as dt
import json
import mariadb_dyncol
import pytest
from unittest import SkipTest, mock
from django.core import serializers
from django.core.exceptions import FieldError
from django.db import connection, models
from django.db.migrations.writer import MigrationWriter
from django.db.models import CharField, Transform
from django.test import TestCase
from django.test.utils import isolate_apps
from django_mysql.models import DynamicField
from django_mysql.utils import connection_is_mariadb
from tests.compat import wrap_testdata
from tests.testapp.models import DynamicModel, SpeclessDynamicModel
        from django_mysql.models.fields import DynamicField as DField
        from django_mysql.models.fields.dynamic import DynamicField as DField

            ),
        ]
        DynamicModel.objects.bulk_create(cls.objs)
        cls.objs = list(DynamicModel.objects.order_by("id"))

    def test_equal(self):
        assert list(DynamicModel.objects.filter(attrs={"a": "b"})) == self.objs[:1]

    def test_exact(self):
        assert (
            list(DynamicModel.objects.filter(attrs__exact={"a": "b"})) == self.objs[:1]
        )

    def test_preexisting_transforms_work_fine(self):
        assert list(DynamicModel.objects.filter(attrs__dumb="notdumb")) == []

    def test_non_existent_transform(self):
        with pytest.raises(FieldError):
            DynamicModel.objects.filter(attrs__nonexistent="notdumb")

    def test_has_key(self):
        assert list(DynamicModel.objects.filter(attrs__has_key="c")) == self.objs[1:3]

    def test_key_transform_datey(self):
        assert list(DynamicModel.objects.filter(attrs__datey=dt.date(2001, 1, 4))) == [
            self.objs[4]
        ]

    def test_key_transform_datey_DATE(self):
        assert list(

            DynamicModel.objects.filter(attrs__datey_DATE=dt.date(2001, 1, 4))