Ticket #18317: django-ticket18317.diff

File django-ticket18317.diff, 1.1 KB (added by manfre, 3 years ago)

Adjusts raw SQL depending on connection vendor.

  • tests/regressiontests/model_fields/tests.py

    diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
    index ea1e1c7..b265e9d 100644
    a b from decimal import Decimal 
    66from django import test
    77from django import forms
    88from django.core.exceptions import ValidationError
    9 from django.db import models
     9from django.db import connection, models
    1010from django.db.models.fields.files import FieldFile
    1111from django.utils import unittest
    1212
    class BooleanFieldTests(unittest.TestCase): 
    207207        # http://code.djangoproject.com/ticket/13293
    208208        # Verify that when an extra clause exists, the boolean
    209209        # conversions are applied with an offset
     210        length = 'LENGTH(string)'
     211        if connection.vendor == 'microsoft':
     212            length = 'LEN(string)'
    210213        b5 = BooleanModel.objects.all().extra(
    211             select={'string_length': 'LENGTH(string)'})[0]
     214            select={'string_length': length})[0]
    212215        self.assertFalse(isinstance(b5.pk, bool))
    213216
    214217class ChoicesTests(test.TestCase):
Back to Top