method
structurally_compatible?
v7.1.3.2 -
Show latest stable
- 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