def test_can_monkey_patch_is_idempotent(self):
        patch_CursorWrapper_execute()

        with CaptureLastQuery() as cap, connection.cursor() as cursor:
            cursor.execute(
                "SELECT 1 FROM DUAL WHERE (/*QueryRewrite':label=hi*/1)")
        assert cap.query == "SELECT /*hi*/ 1 FROM DUAL WHERE (1)"
Exemple #2
0
    def test_can_monkey_patch_is_idempotent(self):
        patch_CursorWrapper_execute()

        with CaptureLastQuery() as cap, connection.cursor() as cursor:
            cursor.execute(
                "SELECT 1 FROM DUAL WHERE (/*QueryRewrite':label=hi*/1)")
        assert cap.query == "SELECT /*hi*/ 1 FROM DUAL WHERE (1)"
Exemple #3
0
    def perform_monkey_patches(self):
        from django.db.backends.mysql.base import DatabaseWrapper
        from django_mysql import monkey_patches

        # Fine to patch straight on since it's a cached_property descriptor
        DatabaseWrapper.is_mariadb = monkey_patches.is_mariadb

        # Depends on setting
        if getattr(settings, 'DJANGO_MYSQL_REWRITE_QUERIES', False):
            monkey_patches.patch_CursorWrapper_execute()
Exemple #4
0
    def perform_monkey_patches(self):
        from django.db.backends.mysql.base import DatabaseWrapper
        from django_mysql import monkey_patches

        # Fine to patch straight on since it's a cached_property descriptor
        DatabaseWrapper.is_mariadb = monkey_patches.is_mariadb

        # Depends on setting
        if getattr(settings, 'DJANGO_MYSQL_REWRITE_QUERIES', False):
            monkey_patches.patch_CursorWrapper_execute()