Fixed #30349 -- Fixed QuerySet.exclude() on FilteredRelation.
Using annotated FilteredRelations raised a FieldError when coupled with exclude(). This is due to not passing filtered relation fields to the subquery created in split_exclude(). We fixed this issue by passing the filtered relation data to the newly created subquery. Secondly, in the case where an INNER JOIN is used in the excluded subquery, the ORM would trim the filtered relation INNER JOIN in attempt to simplify the query. This will also remove the ON clause filters generated by the FilteredRelation. We added logic to not trim the INNER JOIN if it is from FilteredRelation.
Showing
Please
register
or
sign in
to comment