X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=8aa1d5f732fce99f5e8ffcc8c33febe2e2f2ef81;hb=53998003f729b85b27a9e981875cfe5c753e0d28;hp=5609572668b18853a38d307976773e3c7dbcf081;hpb=37aafa2ede65e38af8fe9eda374ad4626290932f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 5609572..8aa1d5f 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -9,13 +9,17 @@ use Data::Page; use Storable; use DBIx::Class::ResultSetColumn; use DBIx::Class::ResultSourceHandle; -use List::Util (); use Hash::Merge (); use Scalar::Util qw/blessed weaken/; use Try::Tiny; use Storable qw/nfreeze thaw/; + +# not importing first() as it will clash with our own method +use List::Util (); + use namespace::clean; + BEGIN { # De-duplication in _merge_attr() is disabled, but left in for reference *__HM_DEDUP = sub () { 0 }; @@ -1957,8 +1961,12 @@ sub pager { } my $attrs = $self->{attrs}; - $self->throw_exception("Can't create pager for non-paged rs") - unless $self->{attrs}{page}; + if (!defined $attrs->{page}) { + $self->throw_exception("Can't create pager for non-paged rs"); + } + elsif ($attrs->{page} <= 0) { + $self->throw_exception('Invalid page number (page-numbers are 1-based)'); + } $attrs->{rows} ||= 10; # throw away the paging flags and re-run the count (possibly @@ -3148,16 +3156,6 @@ sub _resolved_attrs { $_->{as} = [ map { $_ =~ /^\Q$alias.\E(.+)$/ ? $1 : $_ } @{$_->{as}} ]; } - # FIXME !!! - # Blatant bugwardness encoded into multiple tests. - # While columns behaves sensibly, +columns is expected - # to dump *any* foreign columns into the main object - # /me vomits - $selection_pieces->{'+columns'}{as} = [ map - { (split /\./, $_)[-1] } - @{$selection_pieces->{'+columns'}{as}} - ]; - # merge everything for (@sel_pairs) { $attrs->{select} = $self->_merge_attr ($attrs->{select}, $selection_pieces->{$_}{select});