: $_
) => ( /\./ ? $_ : "${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' ) {
( 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
my $schema = DBICTest->init_schema();
-plan tests => 88;
+plan tests => 89;
eval { require DateTime::Format::MySQL };
my $NO_DTFM = $@ ? 1 : 0;
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(
{},
);
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' } ]);
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';