Backout sybase changes
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSet.pm
index 9625e8c..78fd277 100644 (file)
@@ -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</find_or_create>
 instead.
 
 B<Note>: Take care when using C<find_or_new> 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<find_or_new>.
+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<find_or_new>, even when set to C<undef>.
 
 =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<Note>: Take care when using C<find_or_create> 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<find_or_create>.
+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<find_or_create>, even when set to C<undef>.
 
 See also L</find> and L</update_or_create>. For information on how to declare
 unique constraints, see L<DBIx::Class::ResultSource/add_unique_constraint>.
@@ -2413,10 +2414,10 @@ See also L</find> and L</find_or_create>. For information on how to declare
 unique constraints, see L<DBIx::Class::ResultSource/add_unique_constraint>.
 
 B<Note>: Take care when using C<update_or_create> 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<update_or_create>.
+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<update_or_create>, even when set to C<undef>.
 
 =cut
 
@@ -2474,10 +2475,10 @@ For example:
   }
 
 B<Note>: Take care when using C<update_or_new> 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<update_or_new>.
+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<update_or_new>, even when set to C<undef>.
 
 See also L</find>, L</find_or_create> and L</find_or_new>.
 
@@ -2789,24 +2790,35 @@ 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->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 +3115,13 @@ See L<DBIx::Class::Schema/throw_exception> 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