10
10
from tortoise .contrib .test .condition import NotEQ
11
11
from tortoise .exceptions import ConfigurationError , FieldError
12
12
from tortoise .expressions import Case , Q , When
13
- from tortoise .functions import Count , Sum
13
+ from tortoise .functions import Count , Lower , Sum
14
14
15
15
16
16
class TestOrderBy (test .TestCase ):
@@ -95,6 +95,16 @@ async def test_order_by_aggregation_reversed(self):
95
95
)
96
96
self .assertEqual ([t .name for t in tournaments ], ["1" , "2" ])
97
97
98
+ async def test_order_by_reserved_word_annotation (self ):
99
+ await Tournament .create (name = "1" )
100
+ await Tournament .create (name = "2" )
101
+
102
+ reserved_words = ["order" , "group" , "limit" , "offset" , "where" ]
103
+
104
+ for word in reserved_words :
105
+ tournaments = await Tournament .annotate (** {word : Lower ("name" )}).order_by (word )
106
+ self .assertEqual ([t .name for t in tournaments ], ["1" , "2" ])
107
+
98
108
async def test_distinct_values_with_annotation (self ):
99
109
await Tournament .create (name = "3" )
100
110
await Tournament .create (name = "1" )
@@ -115,7 +125,7 @@ async def test_distinct_values_with_annotation(self):
115
125
)
116
126
self .assertEqual ([t ["name" ] for t in tournaments ], ["1" , "2" , "3" ])
117
127
118
- async def test_distinct_all_withl_annotation (self ):
128
+ async def test_distinct_all_with_annotation (self ):
119
129
await Tournament .create (name = "3" )
120
130
await Tournament .create (name = "1" )
121
131
await Tournament .create (name = "2" )
0 commit comments