lib/bmg/operator/allbut.rb in bmg-0.18.0 vs lib/bmg/operator/allbut.rb in bmg-0.18.1

- old
+ new

@@ -61,14 +61,36 @@ [:allbut, operand.to_ast, butlist.dup] end protected ### optimization + def _allbut(type, butlist) + operand.allbut(self.butlist|butlist) + end + + def _matching(type, right, on) + # Always possible to push the matching, since by construction + # `on` can only use attributes that have not been trown away, + # hence they exist on `operand` too. + operand.matching(right, on).allbut(butlist) + end + def _restrict(type, predicate) operand.restrict(predicate).allbut(butlist) end + def _page(type, ordering, page_index, options) + return super unless self.preserving_key? + operand.page(ordering, page_index, options).allbut(butlist) + end + protected ### inspect + + def preserving_key? + operand.type.knows_keys? && operand.type.keys.find{|k| + (k & butlist).empty? + } + end def args [ butlist ] end