# File lib/dm-core/associations/relationship.rb, line 137 def query_for(source, other_query = nil) repository_name = relative_target_repository_name_for(source) DataMapper.repository(repository_name).scope do query = target_model.query.dup query.update(self.query) query.update(source_scope(source)) query.update(other_query) if other_query query.update(:fields => query.fields | target_key) end end