# 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
        assert results == [len(self.obj.attrs["sub"])]

    def test_json_length_path_expression(self):
        results = list(
            JSONModel.objects.annotate(
                x=JSONLength("attrs", Value("$.sub"))
            ).values_list("x", flat=True)
        )
        assert results == [len(self.obj.attrs["sub"])]

    def test_json_length_type(self):
        results = list(
            JSONModel.objects.annotate(x=JSONLength("attrs")).filter(x__range=[3, 5])
        )
        assert results == [self.obj]

    def test_json_insert(self):
        self.obj.attrs = JSONInsert("attrs", {"$.int": 99, "$.int2": 102})
        self.obj.save()
        self.obj.refresh_from_db()
        assert self.obj.attrs["int"] == 88
        assert self.obj.attrs["int2"] == 102

    def test_json_insert_expression(self):
        self.obj.attrs = JSONInsert("attrs", {Value("$.int"): Value(99)})
        self.obj.save()
        self.obj.refresh_from_db()
        assert self.obj.attrs["int"] == 88

    def test_json_insert_dict(self):

# 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

        assert results == [len(self.obj.attrs["sub"])]

    def test_json_length_path_expression(self):
        results = list(
            JSONModel.objects.annotate(
                x=JSONLength("attrs", Value("$.sub"))
            ).values_list("x", flat=True)
        )
        assert results == [len(self.obj.attrs["sub"])]

    def test_json_length_type(self):
        results = list(
            JSONModel.objects.annotate(x=JSONLength("attrs")).filter(x__range=[3, 5])
        )
        assert results == [self.obj]

    def test_json_insert(self):
        self.obj.attrs = JSONInsert("attrs", {"$.int": 99, "$.int2": 102})
        self.obj.save()
        self.obj.refresh_from_db()
        assert self.obj.attrs["int"] == 88
        assert self.obj.attrs["int2"] == 102

    def test_json_insert_expression(self):
        self.obj.attrs = JSONInsert("attrs", {Value("$.int"): Value(99)})
        self.obj.save()
        self.obj.refresh_from_db()
        assert self.obj.attrs["int"] == 88

    def test_json_insert_dict(self):

        self.obj.attrs = JSONInsert(