Changes between Version 1 and Version 2 of Ticket #28484
- Timestamp:
- Aug 9, 2017, 5:35:15 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28484
- Property Component Uncategorized → Database layer (models, ORM)
-
Ticket #28484 – Description
v1 v2 1 1 Related to the #extra deprecation https://docs.djangoproject.com/en/1.11/ref/models/querysets/#extra 2 2 Given this example: 3 3 {{{ 4 4 queryset = Model.objects.all() 5 5 ordered_ids = "1,3,5,7" 6 6 queryset.annotate(custom=RawSQL(f"SELECT FIELD(id, %s)", (ordered_ids,))).order_by("custom") 7 queryset.extra(select={"custom": f"FIELD(id, {ordered_ids})"}, order_by=[custom]).distinct() 8 9 7 queryset.extra(select={"custom": f"FIELD(id, {ordered_ids})"}, order_by=['custom']).distinct() 8 }}} 10 9 The result of both queries is different. But executing the ".query" query in the Mysql native console, the result is the same. 11 10 The result with #extra is ok (the same the native mysql console returns) but the result with annotate is wrong.