method

structurally_compatible?

Importance_1
v7.0.0 - Show latest stable - 0 notes - Class: ActiveRecord::QueryMethods
structurally_compatible?(other) public

Checks whether the given relation is structurally compatible with this relation, to determine if it’s possible to use the #and and #or methods without raising an error. Structurally compatible is defined as: they must be scoping the same model, and they must differ only by #where (if no #group has been defined) or #having (if a #group is present).

Post.where("id = 1").structurally_compatible?(Post.where("author_id = 3"))
# => true

Post.joins(:comments).structurally_compatible?(Post.where("id = 1"))
# => false
Show source
Register or log in to add new notes.