﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30639	Raise an error on unsupported operations following QuerySet.union().	Daniel Himmelstein	nobody	"There is a major gotcha where several operations (such as `.filter` and `.exclude`) do not have any effect if applied to a queryset that has previously included a `.union` statement. See for example this [StackOverflow](https://stackoverflow.com/a/49261966/4651668).

Here is a code example:

{{{
queryset_union = queryset_a.union(queryset_b)
queryset_union.filter(key=value)
}}}


The last command has no effect. Ideally, it should apply the requested filter. However, from the [docs comment](https://docs.djangoproject.com/en/2.2/ref/models/querysets/#union) the following:

> In addition, only LIMIT, OFFSET, COUNT(*), ORDER BY, and specifying columns (i.e. slicing, count(), order_by(), and values()/values_list()) are allowed on the resulting QuerySet. Further, databases place restrictions on what operations are allowed in the combined queries. For example, most databases don’t allow LIMIT or OFFSET in the combined queries.

Therefore, without adding the functionality, it would make sense to trigger a warning or raise an exception, such that users are aware that their filter statement did not succeed. IMO this seems like a `NotImplementedError`. However, a warning would be more backwards compatible."	Bug	closed	Database layer (models, ORM)	dev	Normal	duplicate	union, filter, warning		Unreviewed	0	0	0	0	0	0
