- # hack - 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")
+ $str .= " AND fxt" . scalar(@joins) . ".files_id IS NULL";
+ }
+ return ($str, @outjoins);
+ }
+ else
+ {
+ my $left=$self->left();
+ my $right=$self->right();
+ return ("", @outjoins) unless($left || $right);
+ my ($leftstr, @leftjoins) = $left->to_sql($hasvals, $not, @joins) if($left);
+ push(@joins, @leftjoins);
+ push(@outjoins, @leftjoins);
+ my $op=$self->name();
+ if(defined($op) && $self->type() eq "boolean")
+ {
+ # if we are ANDing, add an inner join
+ # also if we are NOTing, but we are looking for a tag *value*
+ if( ($op eq "AND") || ($hasvals && ($op eq "NOT")))
+ {
+ # hack - 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")
+ {
+ push(@joins, "INNER");
+ push(@outjoins, "INNER");
+ }
+ }
+ elsif($op eq "NOT")