X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdq%2Fremap.t;fp=t%2Fdq%2Fremap.t;h=cc90954cf83d60c88cece14fc9437585d323626e;hb=0f900f81807e8b218320e3f149e4bb82b70a6b70;hp=e8beb526ef241528ae23be064c6a79bb67d6fb7b;hpb=1f005975593c9215598d7ec497d881f328dac890;p=dbsrgits%2FDBIx-Class.git diff --git a/t/dq/remap.t b/t/dq/remap.t index e8beb52..cc90954 100644 --- a/t/dq/remap.t +++ b/t/dq/remap.t @@ -17,9 +17,13 @@ $schema->source($_)->resultset_class('DBIx::Class::ResultSet::WithDQMethods') my $cds = $schema->resultset('CD'); +throws_ok { + $cds->_remap_identifiers(Identifier('name')) +} qr/Invalid name on me: name/; + is_deeply( - [ $cds->_remap_identifiers(Identifier('name')) ], - [ Identifier('me', 'name'), [] ], + [ $cds->_remap_identifiers(Identifier('title')) ], + [ Identifier('me', 'title'), [] ], 'Remap column on me' ); @@ -36,4 +40,18 @@ is_deeply( 'Remap column on rel with re-alias' ); +is_deeply( + [ $cds->_remap_identifiers(Identifier('artist_id')) ], + [ Identifier('me', 'artist'), [] ], + 'Remap column w/column name rename' +); + +my $double_name = expr { $_->artist->name == $_->artist->name }->{expr}; + +is_deeply( + [ $cds->_remap_identifiers($double_name) ], + [ $double_name, [ { artist => {} } ] ], + 'Remap column on rel only adds rel once' +); + done_testing;