Ticket #23843: oracle_nvarchar.diff

File oracle_nvarchar.diff, 1.8 KB (added by Thomas C, 10 years ago)
  • tests/annotations/tests.py

    diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
    index afc23b8..8006760 100644
    a b import datetime  
    33from decimal import Decimal
    44
    55from django.core.exceptions import FieldError
     6from django.db import connection
    67from django.db.models import (
    78    Sum, Count,
    89    F, Value, Func,
    class NonAggregateAnnotationTestCase(TestCase):  
    235236        Company(name='Google', motto='Do No Evil', ticker_name='GOOG', description='Internet Company').save()
    236237        Company(name='Yahoo', motto=None, ticker_name=None, description='Internet Company').save()
    237238
     239        val = Value('No Tag')
     240        if connection.vendor == 'oracle':
     241            val = Func(val, function='CAST',
     242                       template='%(function)s(%(expressions)s AS nvarchar2(30))')
     243
    238244        qs = Company.objects.annotate(
    239245            tagline=Func(
    240246                F('motto'),
    241247                F('ticker_name'),
    242248                F('description'),
    243                 Value('No Tag'),
     249                val,
    244250                function='COALESCE')
    245251            ).order_by('name')
    246252
    class NonAggregateAnnotationTestCase(TestCase):  
    263269        class Lower(Func):
    264270            function = 'LOWER'
    265271
     272        val = Value('No Tag')
     273        if connection.vendor == 'oracle':
     274            val = Func(val, function='CAST',
     275                       template='%(function)s(%(expressions)s AS nvarchar2(30))')
     276
    266277        qs = Company.objects.annotate(
    267278            tagline=Func(
    268279                F('motto'),
    269280                F('ticker_name'),
    270281                F('description'),
    271                 Value('No Tag'),
     282                val,
    272283                function='COALESCE')
    273284        ).annotate(
    274285            tagline_lower=Lower(F('tagline'), output_field=CharField())
Back to Top