From: Nigel Metheringham Date: Wed, 12 Nov 2008 19:23:59 +0000 (+0000) Subject: Extended tests to check new syntax X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=584e74ed9268ffeba3aba23a148cdace7b46649c;p=dbsrgits%2FDBIx-Class-Historic.git Extended tests to check new syntax --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 59d7d06..9d422da 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2090,7 +2090,7 @@ sub _resolved_attrs { : $_ ) => ( /\./ ? $_ : "${alias}.$_" ) } - } @{ delete $attrs->{columns} || [ $source->columns ] }; + } ( ref($attrs->{columns}) eq 'ARRAY' ) ? @{ delete $attrs->{columns}} : (delete $attrs->{columns} || $source->columns ); } # add the additional columns on foreach ( 'include_columns', '+columns' ) { @@ -2098,7 +2098,7 @@ sub _resolved_attrs { ( ref($_) eq 'HASH' ) ? $_ : { ( split( /\./, $_ ) )[-1] => ( /\./ ? $_ : "${alias}.$_" ) } - } @{ delete $attrs->{$_} } if ( $attrs->{$_} ); + } ( ref($attrs->{$_}) eq 'ARRAY' ) ? @{ delete $attrs->{$_} } : delete $attrs->{$_} if ( $attrs->{$_} ); } # start with initial select items diff --git a/t/60core.t b/t/60core.t index ea330ae..9a0bd7e 100644 --- a/t/60core.t +++ b/t/60core.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 88; +plan tests => 89; eval { require DateTime::Format::MySQL }; my $NO_DTFM = $@ ? 1 : 0; @@ -238,9 +238,9 @@ cmp_ok($or_rs->count, '==', 5, 'Search with OR ok'); my $distinct_rs = $schema->resultset("CD")->search($search, { join => 'tags', distinct => 1 }); cmp_ok($distinct_rs->all, '==', 4, 'DISTINCT search with OR ok'); -SKIP: { - skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 1 - if $is_broken_sqlite; +#SKIP: { +# skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 2 +# if $is_broken_sqlite; my $tcount = $schema->resultset("Track")->search( {}, @@ -251,7 +251,15 @@ SKIP: { ); cmp_ok($tcount->next->get_column('count'), '==', 13, 'multiple column COUNT DISTINCT ok'); -} + $tcount = $schema->resultset("Track")->search( + {}, + { + columns => {count => {count => {distinct => ['position', 'title']}}}, + } + ); + cmp_ok($tcount->next->get_column('count'), '==', 13, 'multiple column COUNT DISTINCT using column syntax ok'); + +#} my $tag_rs = $schema->resultset('Tag')->search( [ { 'me.tag' => 'Cheesy' }, { 'me.tag' => 'Blue' } ]); diff --git a/t/68inflate_resultclass_hashrefinflator.t b/t/68inflate_resultclass_hashrefinflator.t index 214e11a..96926ea 100644 --- a/t/68inflate_resultclass_hashrefinflator.t +++ b/t/68inflate_resultclass_hashrefinflator.t @@ -115,3 +115,12 @@ for my $index (0 .. $#hashrefinf) { is ($track->get_column ($col), $datahashref->{cds}{tracks}{$col}, "Correct track '$col'"); } } + +# check for same query as above but using extended columns syntax +$rs_hashrefinf = $schema->resultset ('Artist')->search ({ 'me.artistid' => 1}, { + join => { cds => 'tracks' }, + columns => {name => 'name', 'cds.tracks.title' => 'tracks.title', 'cds.tracks.cd' => 'tracks.cd'}, + order_by => [qw/cds.cdid tracks.trackid/], +}); +$rs_hashrefinf->result_class('DBIx::Class::ResultClass::HashRefInflator'); +is_deeply [$rs_hashrefinf->all], \@hashrefinf, 'Check query using extended columns syntax';