X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F88result_set_column.t;h=7abf670c70b3c874a44b2f5ca375e5ca211a4ccf;hb=6c5aa1fbffdc9e5679d2f68780b11a9569ec1993;hp=9a04bd16d6d7e8db2daed46e274098b90e258ac2;hpb=a5a7bb733a940db710b7408508374833683a2e79;p=dbsrgits%2FDBIx-Class.git diff --git a/t/88result_set_column.t b/t/88result_set_column.t index 9a04bd1..7abf670 100644 --- a/t/88result_set_column.t +++ b/t/88result_set_column.t @@ -1,10 +1,18 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Warn; use Test::Exception; -use lib qw(t/lib); + +# MASSIVE FIXME - there is a hole in ::RSC / as_subselect_rs +# losing the order. Needs a rework/extract of the realiaser, +# and that's a whole another bag of dicks +BEGIN { $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS} = 0 } + + use DBICTest ':DiffSQL'; my $schema = DBICTest->init_schema(); @@ -32,6 +40,13 @@ while (my $r = $rs_title->next) { is_deeply (\@all_titles, \@nexted_titles, 'next works'); +my @list_ctx; +warnings_exist { + @list_ctx = $rs_year->func_rs('DISTINCT'); +} [qr/\Qfunc_rs() always returns a ResultSet instance regardless of calling context/]; +is( scalar @list_ctx, 1, 'wantarray context does not affect func_rs'); +isa_ok( $list_ctx[0], 'DBIx::Class::ResultSet' ); +isa_ok( scalar( $rs_year->func_rs('DISTINCT') ), 'DBIx::Class::ResultSet' ); is_deeply( [ sort $rs_year->func('DISTINCT') ], [ 1997, 1998, 1999, 2001 ], "wantarray context okay"); ok ($max_year->next == $rs_year->max, q/get_column (\'FUNC') ok/); @@ -40,14 +55,16 @@ is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title"); cmp_ok($rs_year->sum, '==', 9996, "three artists returned"); -my $rso_year = $rs->search({}, { order_by => 'cdid' })->get_column('year'); -is($rso_year->next, 1999, "reset okay"); +{ + my $rso_year = $rs->search({}, { order_by => 'cdid' })->get_column('year'); + is($rso_year->next, 1999, "reset okay"); -is($rso_year->first, 1999, "first okay"); + is($rso_year->first, 1999, "first okay"); -warnings_exist (sub { - is($rso_year->single, 1999, "single okay"); -}, qr/Query returned more than one row/, 'single warned'); + warnings_exist (sub { + is($rso_year->single, 1999, "single okay"); + }, qr/Query returned more than one row/, 'single warned'); +} # test distinct propagation