From: Justin Guenther Date: Thu, 6 Jul 2006 19:58:52 +0000 (+0000) Subject: added test for incorrect alias _2 in join collapsing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7e5b5f6efadd4aec29644a16fd0e1ee38d4e8f35;p=dbsrgits%2FDBIx-Class-Historic.git added test for incorrect alias _2 in join collapsing --- diff --git a/t/76joins.t b/t/76joins.t index 6001598..2082047 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -297,4 +297,21 @@ cmp_ok($queries, '==', 1, 'Only one query run'); $tree_like = $schema->resultset('TreeLike')->find(1); $tree_like = $tree_like->search_related('children')->search_related('children')->search_related('children')->first; -is($tree_like->name, 'quux', 'Tree search_related ok'); \ No newline at end of file +is($tree_like->name, 'quux', 'Tree search_related ok'); + +# test that collapsed joins don't get a _2 appended to the alias + +my $sql = ''; +$schema->storage->debugcb(sub { $sql = $_[1] }); +$schema->storage->debug(1); + +eval { + my $row = $schema->resultset('Artist')->search_related('cds', undef, { + join => 'tracks', + prefetch => 'tracks', + })->search_related('tracks')->first; +}; + +like( $sql, qr/^SELECT tracks.trackid/, "collapsed join didn't add _2 to alias" ); + +$schema->storage->debug(0);