# print "THASVALS: $hasvals\n";
# print "TPARENT: ", (defined($parent)? $parent : "NO"), "\n";
my @ids=();
- my $sql=("SELECT tags.name FROM (\n" .
- $self->tags_subselect() .
- ") AS subselect\n" .
- "INNER JOIN files_x_tags ON subselect.files_id=files_x_tags.files_id\n" .
- "INNER JOIN tags ON files_x_tags.tags_id=tags.id\n");
+ my $sql="SELECT tags.name FROM ";
+ if($self->in_or())
+ {
+ $sql .= "files_x_tags\n";
+ }
+ else
+ {
+ $sql .= ("(\n" .
+ $self->tags_subselect() .
+ ") AS subselect\n" .
+ "INNER JOIN files_x_tags ON subselect.files_id=files_x_tags.files_id\n");
+ }
+ $sql .= "INNER JOIN tags ON files_x_tags.tags_id=tags.id\n";
my @andclauses=();
my $id=$self->trailing_tag_id();
my $hasvals=$self->expecting_values();
if($self->{in_all})
{
+ # FIXME: is this used?
+ die "IN_ALL CALLED!!\n";
return "\tSELECT id FROM files AS files_id\n";
}
my $tree=$self->{tagtree};
return $sql;
}
-
+# FIXME: remove
sub constraints_tag_list
{
my($self, @constraints)=@_;
return 1;
}
+# if path is .../OR/ or .../OR/NOT
+sub in_or
+{
+ my($self)=@_;
+ my $tail=$self->tail();
+ return 0 unless($tail);
+ return 0 unless($tail->type() eq "boolean");
+ return 1 if($tail->name() eq "OR");
+ return 0 unless($tail->name() eq "NOT");
+ my $parent=$self->tail_parent();
+ return 0 unless($parent);
+ return 0 unless($parent->type() eq "boolean");
+ return 1 if($parent->name() eq "OR");
+ return 0;
+}
+
1;