From: Peter Rabbitson Date: Sat, 16 Apr 2011 02:00:04 +0000 (+0200) Subject: Moar test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fpeople%2Ffrew%2Fjoin-args;p=dbsrgits%2FDBIx-Class.git Moar test --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 32627bc..04864fc 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -3322,6 +3322,9 @@ sub _resolved_attrs { $join = $self->_merge_joinpref_attr( $join, $attrs->{prefetch} ); } + use Data::Dumper; + die Dumper $join; + $attrs->{from} = # have to copy here to avoid corrupting the original [ @{ $attrs->{from} }, diff --git a/t/relationship/join_args.t b/t/relationship/join_args.t index af15d52..2e4668d 100644 --- a/t/relationship/join_args.t +++ b/t/relationship/join_args.t @@ -10,43 +10,48 @@ use Test::Exception; my $schema = DBICTest->init_schema; dies_ok { - my $rsq = $schema->resultset('Artist')->search({ - 'artwork_to_artist.artwork_cd_id' => 5, - }, { - join => { artwork_to_artist => { -unknown_arg => 'foo' } } - })->as_query + my $rsq = $schema->resultset('Artist')->search({ + 'artwork_to_artist.artwork_cd_id' => 5, + }, { + join => { artwork_to_artist => { -unknown_arg => 'foo' } } + })->as_query } 'dies on unknown rel args'; lives_ok { - my $rsq = $schema->resultset('Artist')->search({ - 'a2a.artwork_cd_id' => 5, - }, { - join => { artwork_to_artist => { -alias => 'a2a' } } - })->as_query + my $rsq = $schema->resultset('Artist')->search({ + 'a2a.artwork_cd_id' => 5, + }, { + join => { artwork_to_artist => { -alias => 'a2a' } } + })->as_query } 'lives for arg -alias'; lives_ok { - my $rsq = $schema->resultset('Artist')->search({ - 'artwork_to_artist.artwork_cd_id' => 5, - }, { - join => { artwork_to_artist => { -join_type => 'left' } } - })->as_query + my $rsq = $schema->resultset('Artist')->search({ + 'artwork_to_artist.artwork_cd_id' => 5, + }, { + join => { artwork_to_artist => { -join_type => 'left' } } + })->as_query } 'lives for arg -join_type'; -is_same_sql_bind( $schema->resultset('Artist')->search({ - 'a2a.artwork_cd_id' => 5, -}, { - join => { - 'artwork_to_artist' => { -alias => 'a2a', -join_type => 'right' } - } -})->as_query, -'( - SELECT me.artistid, me.name, me.rank, me.charfield - FROM artist me - RIGHT JOIN artwork_to_artist a2a - ON a2a.artist_id = me.artistid - WHERE ( a2a.artwork_cd_id = ? ) -)', [[ 'a2a.artwork_cd_id' => 5 ]], 'rel is aliased and join-typed correctly' +is_same_sql_bind( + $schema->resultset('Artist')->search( + { 'a2a.artwork_cd_id' => 5 }, + { + join => { artwork_to_artist => { -alias => 'a2a', -join_type => 'right', artwork => {} } }, + prefetch => { artwork_to_artist => { artwork => { -alias => 'aw' } } }, + }, + )->as_query, + '( + SELECT me.artistid, me.name, me.rank, me.charfield + FROM artist me + RIGHT JOIN artwork_to_artist a2a + ON a2a.artist_id = me.artistid + WHERE ( a2a.artwork_cd_id = ? ) + )', + [[ { sqlt_datatype => 'integer', dbic_colname => 'a2a.artwork_cd_id' } + => 5 ], + ], + 'rel is aliased and join-typed correctly', ); done_testing;