0
我想在rails中的ActiveRecord中进行以下查询。ActiveRecord for rails查询
SELECT * FROM test_run WHERE build = '$build' AND suite='$suite'AND (result = 'fail' OR result = 'error')
AND test_name NOT IN(SELECT test_name FROM test_run WHERE result = 'pass' AND build = '$build')GROUP BY test_name";
第一部分很容易,我不知道如何做子查询。
scope :never_passed, lambda { |b| where(:build => b, :status => 'fail').where(??)
任何想法,我需要做什么才能得到这个子查询作为上面的SQL工作?
感谢
检查了这一点。它应该为您节省一些麻烦:https://github.com/ernie/squeel/ – AJcodez 2012-08-07 17:06:54