From c8571ddb3cc1f9bce16c91838de17f27242d2f32 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Tue, 19 Oct 2010 18:52:53 +0100 Subject: [PATCH] sql formatting tweaks --- lib/ID3FS/Path.pm | 2 ++ lib/ID3FS/Path/Node.pm | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm index 01b1234..629c02a 100644 --- a/lib/ID3FS/Path.pm +++ b/lib/ID3FS/Path.pm @@ -695,6 +695,8 @@ sub tags_subselect } 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=(); diff --git a/lib/ID3FS/Path/Node.pm b/lib/ID3FS/Path/Node.pm index 774af3a..6254600 100644 --- a/lib/ID3FS/Path/Node.pm +++ b/lib/ID3FS/Path/Node.pm @@ -82,7 +82,7 @@ sub to_sql $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); } @@ -150,7 +150,7 @@ sub to_sql $str=$leftstr; $str .= " $op " if($op && !$not); $str .= $rightstr; - if($op || ($left && $right)) + if($op && $left && $right) { $str="(" . $str . ")"; } -- 2.11.0