Q: Fixing LinkedTo link searches

I am looking at fixing search builder so that when
you do a search on criteria LinkedTo it works.

Currently LinkedTo is handled by sub _LinkFieldLimit
which looks to be horribly broken. For example:

sub _LinkFieldLimit {
my $restriction;
my $self;
my $LinkAlias;
my %args;
if ( $restriction->{‘TYPE’} ) {
$self->SUPER::Limit(
ALIAS => $LinkAlias,
ENTRYAGGREGATOR => ‘AND’,
FIELD => ‘Type’,
OPERATOR => ‘=’,
VALUE => $restriction->{‘TYPE’}
);
}

Nothing is ever done with %args, and how can we declare
$restriction and then access it before assigning it?

So the solution I am pursuing is using sub _LinkLimit
like the other “specific” link types but adding
some extra logic for when the link type is LinkedTo.

Here’s what I can’t figure out. It’s really a search
builder problem, but I need the join to look like
this:

SELECT DISTINCT main.* FROM (AT_Assets main LEFT JOIN Links Links_1 ON ( Links_1.Target = main.URI OR Links_1.Base = main.URI)) WHERE ( ( (Links_1.LocalBase IS NULL)OR(Links_1.LocalTarget IS NULL) ) )

How do I get the OR condition in the join? I don’t think
using the EXPRESSION parameter to Join is going to help
me.

Thanks.

-Todd

BTW, I am working on this both for RT and AT. That’s
why the SQL below shows a join on URI, instead of id.On Wed, Dec 21, 2005 at 05:10:59PM -0500, Todd Chapman wrote:

I am looking at fixing search builder so that when
you do a search on criteria LinkedTo it works.

Currently LinkedTo is handled by sub _LinkFieldLimit
which looks to be horribly broken. For example:

sub _LinkFieldLimit {
my $restriction;
my $self;
my $LinkAlias;
my %args;
if ( $restriction->{‘TYPE’} ) {
$self->SUPER::Limit(
ALIAS => $LinkAlias,
ENTRYAGGREGATOR => ‘AND’,
FIELD => ‘Type’,
OPERATOR => ‘=’,
VALUE => $restriction->{‘TYPE’}
);
}

Nothing is ever done with %args, and how can we declare
$restriction and then access it before assigning it?

So the solution I am pursuing is using sub _LinkLimit
like the other “specific” link types but adding
some extra logic for when the link type is LinkedTo.

Here’s what I can’t figure out. It’s really a search
builder problem, but I need the join to look like
this:

SELECT DISTINCT main.* FROM (AT_Assets main LEFT JOIN Links Links_1 ON ( Links_1.Target = main.URI OR Links_1.Base = main.URI)) WHERE ( ( (Links_1.LocalBase IS NULL)OR(Links_1.LocalTarget IS NULL) ) )

How do I get the OR condition in the join? I don’t think
using the EXPRESSION parameter to Join is going to help
me.

Thanks.

-Todd


Rt-devel mailing list
Rt-devel@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel