过去几天我一直在研究MetaWhere
的功能。大多数预测都非常简单,但我仍然坚持如何使用in_all
和in_any
。
以下是我的一些尝试:
Group.where(:id.in_any => [1,2,3])
=> SELECT `groups`.* FROM `groups` WHERE ((`groups`.`id` IN (1) OR `groups`.`id` IN (2) OR `groups`.`id` IN (3)))
Group.where(:id.in_any => [[1,2,3],[4,5,6],[7,8,9]])
=> undefined method 'visit_Fixnum' for #<MetaWhere::Visitors::Predicate:0x3740ba0>
Group.where(:id.in_any => [["1","2","3"],["4","5","6"],["7","8","9"]])
=> SELECT `groups`.* FROM `groups` WHERE (('1' AND '4' AND '7'))
Group.where(:id.in_any => ["(1,2,3)","(4,5,6)","(7,8,9)"])
=> SELECT `groups`.* FROM `groups` WHERE ((`groups`.`id` IN (0) OR `groups`.`id` IN (0) OR `groups`.`id` IN (0)))
Group.where(:id.in_any => ["1,2,3","4,5,6","7,8,9"])
=> SELECT `groups`.* FROM `groups` WHERE ((`groups`.`id` IN (1) OR `groups`.`id` IN (4) OR `groups`.`id` IN (7)))
我假设他们应该AND
或OR
一些IN
条款,但我无法弄清楚如何正确设置它们,我也没有能够找到任何体面的文件。如果有人有这些预测有用的情况的例子,那也是值得赞赏的。
答案 0 :(得分:0)
有时候,直接找到源是有帮助的。看起来有错误:https://twitter.com/#!/erniemiller/status/191151541342830592