New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic `where`s should be treated as a unit. #17010

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@pvande

pvande commented Sep 22, 2014

ActiveRecord's default behavior around .where.not(hash) is to ensure that each key is appropriately filtered out from the query, with the effect being that the query is populated with (key1 != value1) AND (key2 != value2). In general, this feels like a fair implementation, despite not being a direct negation of .where(hash).

However, ActiveRecord also supports filtering on a polymorphic association. This works as expected, internally being expanded to a condition that verifies both the relation_id and the relation_type. Negating one of these conditions, however, excludes rows that share a relation_type or a relation_id.

Fixes #16983.

Polymorphic `where`s should be treated as a unit.
ActiveRecord's default behavior around `.where.not(hash)` is to ensure
that each key is appropriately filtered out from the query, with the
effect being that the query is populated with `(key1 != value1) AND
(key2 != value2)`. In general, this feels like a fair implementation,
despite not being a direct negation of `.where(hash)`.

However, ActiveRecord also supports filtering on a polymorphic
association. This works as expected, internally being expanded to a
condition that verifies both the relation_id and the relation_type.
Negating one of these conditions, however, excludes rows that share a
relation_type or a relation_id.

Fixes #16983.
@pvande

This comment has been minimized.

pvande commented Sep 23, 2014

The build error was a single job timing out for seemingly unrelated reasons.

@matthewd

This comment has been minimized.

Member

matthewd commented Sep 29, 2014

xref #14161

@pywebdesign

This comment has been minimized.

pywebdesign commented Jan 16, 2015

+1

@MisinformedDNA

This comment has been minimized.

MisinformedDNA commented Apr 13, 2015

There's a series of issues leading back to this one. But in order for any of them to close, this once needs to be merged. Any reason this hasn't been merged yet?

@teknull

This comment has been minimized.

teknull commented Apr 14, 2015

@MisinformedDNA Looks like the CI build failed with merge conflicts. Someone from core will need to sort those out before it can pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment