From: Luke Saunders Date: Tue, 18 May 2010 16:29:27 +0000 (+0100) Subject: ditching limit and order_by and incrementing version X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d1d2fc5e020933e4a6334dd61619fe53a903c054;p=dbsrgits%2FDBIx-Class-ResultSet-WithMetaData.git ditching limit and order_by and incrementing version --- diff --git a/lib/DBIx/Class/ResultSet/WithMetaData.pm b/lib/DBIx/Class/ResultSet/WithMetaData.pm index e2ab12b..131fcdd 100644 --- a/lib/DBIx/Class/ResultSet/WithMetaData.pm +++ b/lib/DBIx/Class/ResultSet/WithMetaData.pm @@ -25,11 +25,11 @@ has 'id_cols' => ( =head1 VERSION -Version 0.999001 +Version 0.999003 =cut -our $VERSION = '0.999001'; +our $VERSION = '0.999003'; =head1 NAME @@ -56,7 +56,7 @@ DBIx::Class::ResultSet::WithMetaData # then somewhere else - my $object_type_arrayref = $object_type_rs->limit(count => 3)->with_substr->display(); + my $object_type_arrayref = $object_type_rs->with_substr->display(); # [{ # 'artistid' => '1', @@ -174,49 +174,6 @@ method row_info_for (%opts) { return $self->_row_info->{$id}; } -=head2 order_by (EXPERIMENTAL) - -=over 4 - -=item Arguments: col => $column_name - -=item Return Value: ResultSet - -=back - - $ordered_rs = $rs->order_by(col => 'name'); - -Convenience method. Essentually a shortcut for $rs->search({}, { order_by => $col }). - -=cut - -method order_by (%opts) { - my $col = $opts{col}; - $col = "me.$col" unless ($col =~ m/\./); - return $self->search({}, { order_by => $col }); -} - -=head2 limit (EXPERIMENTAL) - -=over 4 - -=item Arguments: count => Int - -=item Return Value: ResultSet - -=back - - $limitted_rs = $rs->limit(count => 3); - -Convenience method. Essentually a shortcut for $rs->search({}, { rows => $count }). - -=cut - -method limit (%opts) { - my $count = $opts{count}; - return $self->search({}, { rows => $count }); -} - method _mk_id (%opts) { my $row = $opts{row}; return join('-', map { $row->{$_} } @{$self->id_cols}); diff --git a/t/custom_methods.t b/t/custom_methods.t index 7c8c64a..e466143 100644 --- a/t/custom_methods.t +++ b/t/custom_methods.t @@ -9,7 +9,7 @@ use Data::Dumper; ok(my $schema = DBICTest->init_schema(), 'got schema'); { - my $artist_rs = $schema->resultset('Artist')->order_by(col => 'artistid')->display(); + my $artist_rs = $schema->resultset('Artist')->search({}, { order_by => 'artistid' })->display(); is_deeply($artist_rs, [ { 'artistid' => '1', @@ -27,7 +27,7 @@ ok(my $schema = DBICTest->init_schema(), 'got schema'); } { - my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->display(); + my $artists = $schema->resultset('Artist')->search({}, { order_by => 'artistid' })->with_substr->display(); is_deeply($artists, [ { 'artistid' => '1', @@ -48,7 +48,7 @@ ok(my $schema = DBICTest->init_schema(), 'got schema'); } { - my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->search({}, { prefetch => 'cds', rows => 1 })->display(); + my $artists = $schema->resultset('Artist')->search({}, { order_by => 'artistid' })->with_substr->search({}, { prefetch => 'cds', rows => 1 })->display(); is_deeply($artists, [ { 'artistid' => 1,