From: Ian Beckwith Date: Tue, 19 Oct 2010 17:52:53 +0000 (+0100) Subject: sql formatting tweaks X-Git-Tag: debian/1.0-1~21 X-Git-Url: http://erislabs.net/gitweb/?p=id3fs.git;a=commitdiff_plain;h=c8571ddb3cc1f9bce16c91838de17f27242d2f32 sql formatting tweaks --- 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 . ")"; }