간단한 쿼리를 수행하려고하는데 Datamapper가 올바른 결과 집합을 반환하지 않는 것 같습니다.Datamapper가 올바른 쿼리를 수행하지 않습니다.
이것은 매우 기본적인 것처럼 보이기 때문에 잘못된 이유가 없습니다.
나는 아마도 구문 문제라고 생각합니다. 이 관계 코드의 버그 인의 가능성이 있습니다
class User
has n, :answers
property :id, Serial
property :name, String
end
class Answer
belongs_to :user
has n, :topics, :through => Resource
property :id, Serial
property :text, Text
end
class Topic
has n, :answers, :through => Resource
property :name, String, :key => true
end
o=User.create(:name=>'tom')
puts a=Answer.create(:user=>o, :text => 'a1', :topics => [
Topic.first_or_create(:name => 'aboutme'),
Topic.first_or_create(:name => '@onetom')
])
#THIS WORKS
#puts Answer.all(:user => {:name => 'tom'}, :topics => [{:name => 'aboutme'}])
#THIS DOES NOT WORK
#puts o.answers.all(:topics => [{:name => 'aboutme'}])
고마워요! 문제 해결됨! = D –