}
my ($sqlclause, @joins)=(undef, ());
($sqlclause, @joins) = $tree->to_sql($hasvals) if($tree);
+# use Data::Dumper;
+# print Dumper $tree if($tree);
# print "SQL(" . scalar(@joins) ."): $sqlclause\n";
my $sql="\tSELECT fxt1.files_id FROM tags t1";
my @crosses=();
$str .= "t" . scalar(@joins) . ".id='" . $self->{id} . "'";
if($not && !$hasvals)
{
- $str .= " AND fxt" . scalar(@joins) . ".files_id IS NULL";
+ $str = "(" . $str . " AND fxt" . scalar(@joins) . ".files_id IS NULL)";
}
return ($str, @outjoins);
}
$str=$leftstr;
$str .= " $op " if($op && !$not);
$str .= $rightstr;
- if($op || ($left && $right))
+ if($op && $left && $right)
{
$str="(" . $str . ")";
}