- # as above - if right child is a NOT, we don't need extra join/brackets
- # NOT will do the same and we will end up with an extra one
- unless($right && $right->name() && $right->name() eq "NOT")
- {
- if($hasvals)
- {
- push(@joins, "INNER");
- push(@outjoins, "INNER");
- }
- else
- {
- push(@joins, "LEFT");
- push(@outjoins, "LEFT");
- }
- }
-# print("LEFT: ", $left->print(), "\n") if ($left);
-# print("RIGHT: ", $right->print(), "\n") if($right);
- }
- elsif($op eq "OR")
- {
- print "OR\n";
- # if left child is a NOT, we need an extra (inner) join
- # unless right child is also a NOT
- if(($left && $left->name() && $left->name() eq "NOT") &&
- !($right && $right->name() && $right->name() eq "NOT"))
- {
- push(@joins, "INNER");
- push(@outjoins, "INNER");
- }
+ # return an extra join, but don't pass it down to $right->to_sql
+ # if we are looking for a tag *value*, use INNER join rather than LEFT
+ push(@outjoins, ($hasvals ? "INNER" : "LEFT"));