Fix a bug in getLineageSql, where it would return the empty string. This could cause downstream problems. Fixes bug #11616

This commit is contained in:
Colin Kuskie 2010-06-08 09:22:28 -07:00
parent 4eb013ef03
commit 2c08b4e712
3 changed files with 27 additions and 6 deletions

View file

@ -11,6 +11,7 @@
- fixed AddressBook feedback for missing fields.
- fixed #11606: Syndicated Content feed returns a relative link
- fixed #11614: Forums: Sort Fields
- fixed #11616: No access to /root
7.9.6
- new checkbox in the asset manager for clearing the package flag on import

View file

@ -461,10 +461,6 @@ sub getLineage {
my $sql = $self->getLineageSql($relatives,$rules);
unless ($sql) {
return [];
}
my @lineage;
my %relativeCache;
my $sth = $self->session->db->read($sql);
@ -732,7 +728,8 @@ sub getLineageSql {
}
## finish up our where clause
if (!scalar(@whereModifiers)) {
return "";
#Return valid SQL that will never select an asset.
return q|select * from asset where assetId="###---###"|;
}
$where .= ' and ('.join(" or ",@whereModifiers).')';
if (exists $rules->{whereClause} && $rules->{whereClause}) {

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 93; # increment this value for each test you create
use Test::More tests => 96; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@ -445,6 +445,22 @@ cmp_bag(
'getLineage: descendants of topFolder',
);
$ids = $root->getLineage(['ancestors']);
cmp_deeply(
$ids,
[],
'... getting ancestors of root returns empty array'
);
####################################################
#
# getLineageSql
#
####################################################
note "getLineageSql";
ok $root->getLineageSql(['ancestors']), 'valid SQL returned in an error condition';
####################################################
#
# getLineageIterator
@ -497,6 +513,13 @@ cmp_bag(
'getLineageIterator: descendants of topFolder',
);
my $empty = getListFromIterator($root->getLineageIterator(['ancestors']));
cmp_bag(
$empty,
[],
'... getting ancestors of root returns empty array'
);
####################################################
#
# addChild