punctuation
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Row.pm
index 4188d10..c658885 100644 (file)
@@ -6,7 +6,10 @@ use warnings;
 use base qw/DBIx::Class/;
 
 use Scalar::Util 'blessed';
-use DBIx::Class::_Util qw( dbic_internal_try fail_on_internal_call );
+use DBIx::Class::_Util qw(
+  dbic_internal_try fail_on_internal_call
+  DUMMY_ALIASPAIR
+);
 use DBIx::Class::Carp;
 use SQL::Abstract qw( is_literal_value is_plain_value );
 
@@ -553,7 +556,9 @@ sub update {
   my %to_update = $self->get_dirty_columns
     or return $self;
 
-  $self->throw_exception( "Not in database" ) unless $self->in_storage;
+  $self->throw_exception(
+    'Result object not marked in_storage: an update() operation is not possible'
+  ) unless $self->in_storage;
 
   my $rows = $self->result_source->schema->storage->update(
     $self->result_source, \%to_update, $self->_storage_ident_condition
@@ -615,7 +620,9 @@ See also L<DBIx::Class::ResultSet/delete>.
 sub delete {
   my $self = shift;
   if (ref $self) {
-    $self->throw_exception( "Not in database" ) unless $self->in_storage;
+    $self->throw_exception(
+      'Result object not marked in_storage: a delete() operation is not possible'
+    ) unless $self->in_storage;
 
     $self->result_source->schema->storage->delete(
       $self->result_source, $self->_storage_ident_condition
@@ -1190,14 +1197,15 @@ sub copy {
 
     $copied->{$_->ID}++ or $_->copy(
 
-      $foreign_vals ||= $rsrc->_resolve_relationship_condition(
-        infer_values_based_on => {},
+      $foreign_vals ||= $rsrc->resolve_relationship_condition(
+        require_join_free_values => 1,
         rel_name => $rel_name,
         self_result_object => $new,
 
-        self_alias => "\xFE", # irrelevant
-        foreign_alias => "\xFF", # irrelevant,
-      )->{inferred_values}
+        # an API where these are optional would be too cumbersome,
+        # instead always pass in some dummy values
+        DUMMY_ALIASPAIR,
+      )->{join_free_values}
 
     ) for $self->related_resultset($rel_name)->all;
   }
@@ -1220,7 +1228,7 @@ Set a raw value for a column without marking it as changed. This
 method is used internally by L</set_column> which you should probably
 be using.
 
-This is the lowest level at which data is set on a result object,
+This is the lowest level at which data is set on a result object;
 extend this method to catch all data setting methods.
 
 =cut
@@ -1513,15 +1521,16 @@ L<DBIx::Class::ResultSet/ATTRIBUTES>.
 =cut
 
 sub get_from_storage {
-    my $self = shift @_;
-    my $attrs = shift @_;
-    my $resultset = $self->result_source->resultset;
+    my $self = shift;
 
-    if(defined $attrs) {
-      $resultset = $resultset->search(undef, $attrs);
-    }
-
-    return $resultset->find($self->_storage_ident_condition);
+    # with or without attrs?
+    (
+      defined( $_[0] )
+        ? $self->result_source->resultset->search_rs( undef, $_[0] )
+        : $self->result_source->resultset
+    )->find(
+      $self->_storage_ident_condition
+    );
 }
 
 =head2 discard_changes