From edba03ce7b833ca4ad60f2e33250ec5e9d455a91 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Tue, 19 Oct 2010 09:39:24 +0100 Subject: [PATCH] handle /NOT/foo/OR/bar --- lib/ID3FS/Path.pm | 2 ++ lib/ID3FS/Path/Node.pm | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm index 0326af6..5a5c10e 100644 --- a/lib/ID3FS/Path.pm +++ b/lib/ID3FS/Path.pm @@ -363,6 +363,8 @@ sub parse $self->{tagtree}=$self->elements_to_tree(\@elements); if($self->{tagtree}) { +# use Data::Dumper; +# print Dumper $self->{tagtree}; # my ($conditions, @joins)=$self->{tagtree}->to_sql(); # print "CONDITIONS(", scalar(@joins), "): ", $conditions, "\n"; } diff --git a/lib/ID3FS/Path/Node.pm b/lib/ID3FS/Path/Node.pm index 950be17..478adb3 100644 --- a/lib/ID3FS/Path/Node.pm +++ b/lib/ID3FS/Path/Node.pm @@ -134,6 +134,15 @@ sub to_sql # print("LEFT: ", $left->print(), "\n") if ($left); # print("RIGHT: ", $right->print(), "\n") if($right); } + elsif($op eq "OR") + { + # if left child is a not, we need an extra (inner) join + if($left && $left->name() && $left->name() eq "NOT") + { + push(@joins, "INNER"); + push(@outjoins, "INNER"); + } + } } my ($rightstr, @rightjoins) = $right->to_sql($hasvals, $not, @joins) if($right); push(@outjoins, @rightjoins); @@ -147,6 +156,8 @@ sub to_sql $str="(" . $str . ")"; } # print "STR: $str\n"; +# my @all=(@joins, @rightjoins); +# print "JOINS: RETURN ", scalar(@outjoins), " ALL ", scalar(@all), "\n"; return($str, @outjoins); } } -- 2.11.0