handle /NOT/foo/OR/bar
authorIan Beckwith <ianb@erislabs.net>
Tue, 19 Oct 2010 08:39:24 +0000 (09:39 +0100)
committerIan Beckwith <ianb@erislabs.net>
Tue, 19 Oct 2010 08:39:24 +0000 (09:39 +0100)
lib/ID3FS/Path.pm
lib/ID3FS/Path/Node.pm

index 0326af6..5a5c10e 100644 (file)
@@ -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";
     }
index 950be17..478adb3 100644 (file)
@@ -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);
     }
 }