|
@@ -1,10 +1,10 @@
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
+from collections import OrderedDict
|
|
|
import datetime
|
|
|
|
|
|
from django.contrib.auth.models import User
|
|
|
from django.test import TestCase
|
|
|
-from django.utils.datastructures import SortedDict
|
|
|
|
|
|
from .models import TestObject, Order, RevisionableModel
|
|
|
|
|
@@ -74,7 +74,7 @@ class ExtraRegressTests(TestCase):
|
|
|
|
|
|
|
|
|
qs = User.objects.extra(
|
|
|
- select=SortedDict((("alpha", "%s"), ("beta", "2"), ("gamma", "%s"))),
|
|
|
+ select=OrderedDict((("alpha", "%s"), ("beta", "2"), ("gamma", "%s"))),
|
|
|
select_params=(1, 3)
|
|
|
)
|
|
|
qs = qs.extra(select={"beta": 4})
|
|
@@ -180,100 +180,100 @@ class ExtraRegressTests(TestCase):
|
|
|
obj.save()
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values()),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values()),
|
|
|
[{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.values().extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
+ list(TestObject.objects.values().extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
[{'bar': 'second', 'third': 'third', 'second': 'second', 'whiz': 'third', 'foo': 'first', 'id': obj.pk, 'first': 'first'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second')),
|
|
|
[{'second': 'second', 'first': 'first'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.values('first', 'second').extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
+ list(TestObject.objects.values('first', 'second').extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
[{'second': 'second', 'first': 'first'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second', 'foo')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('first', 'second', 'foo')),
|
|
|
[{'second': 'second', 'foo': 'first', 'first': 'first'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('foo', 'whiz')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values('foo', 'whiz')),
|
|
|
[{'foo': 'first', 'whiz': 'third'}]
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list()),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list()),
|
|
|
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.values_list().extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
+ list(TestObject.objects.values_list().extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
[('first', 'second', 'third', obj.pk, 'first', 'second', 'third')]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second')),
|
|
|
[('first', 'second')]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.values_list('first', 'second').extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
+ list(TestObject.objects.values_list('first', 'second').extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third'))))),
|
|
|
[('first', 'second')]
|
|
|
)
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('second', flat=True)),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('second', flat=True)),
|
|
|
['second']
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second', 'whiz')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first', 'second', 'whiz')),
|
|
|
[('first', 'second', 'third')]
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('foo','whiz')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('foo','whiz')),
|
|
|
[('first', 'third')]
|
|
|
)
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', flat=True)),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', flat=True)),
|
|
|
['third']
|
|
|
)
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz','foo')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz','foo')),
|
|
|
[('third', 'first')]
|
|
|
)
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first','id')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('first','id')),
|
|
|
[('first', obj.pk)]
|
|
|
)
|
|
|
|
|
|
self.assertEqual(
|
|
|
- list(TestObject.objects.extra(select=SortedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', 'first', 'bar', 'id')),
|
|
|
+ list(TestObject.objects.extra(select=OrderedDict((('foo','first'), ('bar','second'), ('whiz','third')))).values_list('whiz', 'first', 'bar', 'id')),
|
|
|
[('third', 'first', 'second', obj.pk)]
|
|
|
)
|
|
|
|