X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F76select.t;h=8f45fd056d2984a0c04e0137750fb2e27cf30367;hb=ed04f0765deb438a059ac948881747d846292bda;hp=bee69e6b12864f0a63b21f0fb7ecc12247c2d7d6;hpb=af6aac2d51a435fa60151ac047e1559257fd4eba;p=dbsrgits%2FDBIx-Class.git diff --git a/t/76select.t b/t/76select.t index bee69e6..8f45fd0 100644 --- a/t/76select.t +++ b/t/76select.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; @@ -9,8 +9,6 @@ use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); -plan tests => 24; - my $rs = $schema->resultset('CD')->search({}, { '+select' => \ 'COUNT(*)', @@ -29,16 +27,6 @@ $rs = $schema->resultset('CD')->search({}, lives_ok(sub { $rs->first->get_column('count') }, 'multiple +select/+as columns, 1st rscolumn present'); lives_ok(sub { $rs->first->get_column('addedtitle') }, 'multiple +select/+as columns, 2nd rscolumn present'); -# Tests a regression in ResultSetColumn wrt +select -$rs = $schema->resultset('CD')->search(undef, - { - '+select' => [ \'COUNT(*) AS year_count' ], - order_by => 'year_count' - } -); -my @counts = $rs->get_column('cdid')->all; -ok(scalar(@counts), 'got rows from ->all using +select'); - $rs = $schema->resultset('CD')->search({}, { '+select' => [ \ 'COUNT(*)', 'title' ], @@ -64,6 +52,7 @@ my $cds = $schema->resultset ('CD')->search ({}, { order_by => 'me.cdid'}); # ma cmp_ok ($cds->count, '>', 2, 'Initially populated with more than 2 CDs'); my $table = $cds->result_source->name; +$table = $$table if ref $table eq 'SCALAR'; my $subsel = $cds->search ({}, { columns => [qw/cdid title/], from => \ "(SELECT cdid, title FROM $table LIMIT 2) me", @@ -100,13 +89,13 @@ lives_ok(sub { }, 'columns 2nd rscolumn present'); lives_ok(sub { - $rs->first->artist->get_column('name') -}, 'columns 3rd rscolumn present'); + $rs->first->artist->get_column('name') +}, 'columns 3rd rscolumn present'); $rs = $schema->resultset('CD')->search({}, - { + { 'join' => 'artist', '+columns' => ['cdid', 'title', 'artist.name'], } @@ -120,7 +109,7 @@ is_same_sql_bind ( ); lives_ok(sub { - $rs->first->get_column('cdid') + $rs->first->get_column('cdid') }, 'columns 1st rscolumn present'); lives_ok(sub { @@ -164,34 +153,16 @@ my $sub_rs = $rs->search ({}, } ); -is_deeply ( +is_deeply( $sub_rs->single, { - artist => 1, - track_position => 2, - tracks => - { - trackid => 17, - title => 'Apiary', - }, + artist => 1, + tracks => { + title => 'Apiary', + trackid => 17, + }, }, 'columns/select/as fold properly on sub-searches', ); -TODO: { - local $TODO = "Multi-collapsing still doesn't work right - HRI should be getting an arrayref, not an individual hash"; - is_deeply ( - $sub_rs->single, - { - artist => 1, - track_position => 2, - tracks => [ - { - trackid => 17, - title => 'Apiary', - }, - ], - }, - 'columns/select/as fold properly on sub-searches', - ); -} +done_testing;