When you have a resultset that has a join in it and you try to do a
search on it with another join to the same table twice then the second
join is joined only once.
# t/90join_torture.t
my $rs = $schema->resultset("Artist")->search({}, { join => 'twokeys' });
my $second_search_rs = $rs->search({ 'cds_2.cdid' => '2' }, { join =>
['cds', 'cds'] });
is(scalar(@{$second_search_rs->{attrs}->{join}}), 3, 'both joins kept');
ok($second_search_rs->next, 'query on double joined rel runs okay');
__OUTPUT__
# Failed test 'both joins kept'
# at t/90join_torture.t line 125.
# got: '2'
# expected: '3'
DBIx::Class::ResultSet::next(): DBI Exception: DBD::SQLite::db
prepare_cached failed: no such column: cds_2.cdid(1) at dbdimp.c line
271 [for Statement "SELECT me.artistid, me.name FROM artist me LEFT
JOIN twokeys twokeys ON ( twokeys.artist = me.artistid ) LEFT JOIN cd
cds ON ( cds.artist = me.artistid ) WHERE ( cds_2.cdid = ? )"] at
t/90join_torture.t line 126
The svn diff is attached (it's against
http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk/lib I
hope that's the right branch).
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
Index: t/90join_torture.t
===================================================================
--- t/90join_torture.t (revision 3843)
+++ t/90join_torture.t (working copy)
@@ -119,4 +119,11 @@
ok(!$@, "pathological prefetch ok");
+# should end up with cds and cds_2 joined
+my $rs = $schema->resultset("Artist")->search({}, { join => 'twokeys' });
+my $second_search_rs = $rs->search({ 'cds_2.cdid' => '2' }, { join => ['cds',
'cds'] });
+is(scalar(@{$second_search_rs->{attrs}->{join}}), 3, 'both joins kept');
+ok($second_search_rs->next, 'query on double joined rel runs okay');
+
+
1;
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]