X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=6b856855a6d5e11e13accffc44253e78cdde4e1f;hb=1a58752c42ba9acf33e2943b678de4948cf3ee3f;hp=9625e8c785a690fc723a414b9bf0712eacee4a87;hpb=b3ff132c9a424c303aa69d69ba9c596c01103562;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 9625e8c..6b85685 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -7,6 +7,7 @@ use overload 'bool' => "_bool", fallback => 1; use Carp::Clan qw/^DBIx::Class/; +use DBIx::Class::Exception; use Data::Page; use Storable; use DBIx::Class::ResultSetColumn; @@ -2200,10 +2201,10 @@ If you want objects to be saved immediately, use L instead. B: Take care when using C with a table having -columns with values that are automatically supplied by the database -(e.g. an auto_increment primary key column). In normal usage, the -value of such columns should NOT be specified in the call to -C. +columns with default values that you intend to be automatically +supplied by the database (e.g. an auto_increment primary key column). +In normal usage, the value of such columns should NOT be included at +all in the call to C, even when set to C. =cut @@ -2346,10 +2347,10 @@ the find has completed and before the create has started. To avoid this problem, use find_or_create() inside a transaction. B: Take care when using C with a table having -columns with values that are automatically supplied by the database -(e.g. an auto_increment primary key column). In normal usage, the -value of such columns should NOT be specified in the call to -C. +columns with default values that you intend to be automatically +supplied by the database (e.g. an auto_increment primary key column). +In normal usage, the value of such columns should NOT be included at +all in the call to C, even when set to C. See also L and L. For information on how to declare unique constraints, see L. @@ -2413,10 +2414,10 @@ See also L and L. For information on how to declare unique constraints, see L. B: Take care when using C with a table having -columns with values that are automatically supplied by the database -(e.g. an auto_increment primary key column). In normal usage, the -value of such columns should NOT be specified (even as undef) in the -call to C. +columns with default values that you intend to be automatically +supplied by the database (e.g. an auto_increment primary key column). +In normal usage, the value of such columns should NOT be included at +all in the call to C, even when set to C. =cut @@ -2474,10 +2475,10 @@ For example: } B: Take care when using C with a table having -columns with values that are automatically supplied by the database -(e.g. an auto_increment primary key column). In normal usage, the -value of such columns should NOT be specified in the call to -C. +columns with default values that you intend to be automatically +supplied by the database (e.g. an auto_increment primary key column). +In normal usage, the value of such columns should NOT be included at +all in the call to C, even when set to C. See also L, L and L. @@ -2789,24 +2790,38 @@ sub _resolved_attrs { # build columns (as long as select isn't set) into a set of as/select hashes unless ( $attrs->{select} ) { - @colbits = map { - ( ref($_) eq 'HASH' ) - ? $_ - : { - ( - /^\Q${alias}.\E(.+)$/ - ? "$1" - : "$_" - ) - => - ( - /\./ - ? "$_" - : "${alias}.$_" - ) - } - } ( ref($attrs->{columns}) eq 'ARRAY' ) ? @{ delete $attrs->{columns}} : (delete $attrs->{columns} || $source->columns ); + + my @cols = ( ref($attrs->{columns}) eq 'ARRAY' ) + ? @{ delete $attrs->{columns}} + : ( + ( delete $attrs->{columns} ) + || + $source->storage->_order_select_columns( + $source, + [ $source->columns ], + ) + ) + ; + + @colbits = map { + ( ref($_) eq 'HASH' ) + ? $_ + : { + ( + /^\Q${alias}.\E(.+)$/ + ? "$1" + : "$_" + ) + => + ( + /\./ + ? "$_" + : "${alias}.$_" + ) + } + } @cols; } + # add the additional columns on foreach ( 'include_columns', '+columns' ) { push @colbits, map { @@ -3103,12 +3118,13 @@ See L for details. sub throw_exception { my $self=shift; + if (ref $self && $self->_source_handle->schema) { $self->_source_handle->schema->throw_exception(@_) - } else { - croak(@_); } - + else { + DBIx::Class::Exception->throw(@_); + } } # XXX: FIXME: Attributes docs need clearing up