my ($self) = @_;
delete $self->{_dirty_columns};
return unless $self->in_storage; # Don't reload if we aren't real!
-
- my $reload = $self->result_source->schema->storage->reload_row($self);
- unless ($reload) { # If we got deleted in the mean-time
+ if( my $current_storage = $self->get_current_storage) {
+
+ # Set $self to the current.
+ %$self = %$current_storage;
+
+ # Avoid a possible infinite loop with
+ # sub DESTROY { $_[0]->discard_changes }
+ bless $current_storage, 'Do::Not::Exist';
+
+ return $self;
+ } else {
$self->in_storage(0);
- return $self;
+ return $self;
}
-
- %$self = %$reload;
-
- # Avoid a possible infinite loop with
- # sub DESTROY { $_[0]->discard_changes }
- bless $reload, 'Do::Not::Exist';
-
- return $self;
}
=head2 id
$class->mk_group_accessors('column' => $acc);
}
+=head2 get_current_storage
+
+Returns a new Row which is whatever the Storage has for the currently created
+Row object. You ca use this to see if the storage has become inconsistent with
+whatever your Row object is.
+
+=cut
+
+sub get_current_storage {
+ my $self = shift @_;
+ my @primary_columns = map { $self->$_ } $self->primary_columns;
+ return $self->result_source->schema->txn_do(sub {
+ return $self->result_source->resultset->find(@primary_columns);
+ });
+}
=head2 throw_exception
sub select_single { die "Virtual method!" }
-=head2 reload_row ($row)
-
-given a L<DBIx::Class::Row> object, loads and returns the matching version from
-storage. Does not effect the existing row object.
-
-=cut
-
-sub reload_row { die "Virtual method!" }
-
=head2 columns_info_for
Returns metadata for the given source's columns. This
return @row;
}
-sub reload_row {
- my ($self, $row) = @_;
-
- my $reload = $row->result_source->resultset->find(
- map { $row->$_ } $row->primary_columns
- );
-
- return $reload;
-}
-
=head2 sth
=over 4
$self->execute_reliably(sub {$self->$txn_do($coderef, @args)});
};
-=head2 reload_row ($row)
-
-Overload to the reload_row method so that the reloading is always directed to
-the master storage.
-
-=cut
-
-around 'reload_row' => sub {
- my ($reload_row, $self, $row) = @_;
- return $self->execute_reliably(sub {
- return $self->$reload_row(shift);
- }, $row);
-};
-
=head2 connected
Check that the master and at least one of the replicants is connected.