質問

I've been exploring the capabilities of MetaWhere over the last couple of days. Most of the predications are pretty straightforward, but I'm stuck on how to use in_all and in_any.

Here are some of my attempts:

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)))

I'm assuming they're supposed to AND or OR a bunch of IN clauses, but I can't figure out how to set them up properly, nor have I been able to find any decent documentation. And if anyone has any examples of situations where these predications would be useful, that would be appreciated as well.

役に立ちましたか?

解決

Sometimes, it helps to go straight to the source. Looks like there's bug: https://twitter.com/#!/erniemiller/status/191151541342830592

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top