$ the-wire · showcase
Django resolves FilteredRelation aliases in .values() and .order_by()
By RepoJournal · Filed · About Django
Django now correctly resolves FilteredRelation aliases in .values() and .order_by(), fixing a long-standing ORM quirk.
Django fixed a bug where .values() and .order_by() did not resolve FilteredRelation aliases correctly [1]. The patch updates Query.add_fields(), Query.add_ordering(), and SQLCompiler.find_ordering_name() to look up these aliases before splitting field names into relationship traversals [1]. Previously, queries referencing a FilteredRelation alias in these methods mis-resolved the field; now they resolve as expected [1]. The fix also includes new tests, .test_alias_values() and .test_alias_order_by(), to cover the behavior [1]. Separately, test skips were added for 1-element GeometryCollections on Oracle 23.9 [3], with a follow-up skip covering additional geography LayerMapping cases [4]. A CI job added ubuntu-latest results to django-asv, the Django benchmarking suite [2]. The activity totals across both repos were 3 commits and 2 PRs.
Action items
References
- [1] Fixed #36945 -- Made .values() and .order_by() resolve FilteredRelation aliases correctly. ↗ django/django
- [2] Results for ubuntu-latest added [skip ci] ↗ django/django-asv
- [3] Added test skip for 1-element GeometryCollections on Oracle 23.9. ↗ django/django
- [4] Skipped more tests for 1-element GeometryCollections on Oracle 23.9. ↗ django/django