added some notes in the tests and fixed get_from_storage to actually use the new...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Row.pm
index d2def31..798f4fa 100644 (file)
@@ -295,6 +295,21 @@ C<set_inflated_columns>, which might edit it in place, so dont rely on it being
 the same after a call to C<update>.  If you need to preserve the hashref, it is
 sufficient to pass a shallow copy to C<update>, e.g. ( { %{ $href } } )
 
+If the values passed or any of the column values set on the object
+contain scalar references, eg:
+
+  $obj->last_modified(\'NOW()');
+  # OR
+  $obj->update({ last_modified => \'NOW()' });
+
+The update will pass the values verbatim into SQL. (See
+L<SQL::Abstract> docs).  The values in your Row object will NOT change
+as a result of the update call, if you want the object to be updated
+with the actual values from the database, call L</discard_changes>
+after the update.
+
+  $obj->update()->discard_changes();
+
 =cut
 
 sub update {
@@ -436,6 +451,20 @@ sub get_dirty_columns {
            keys %{$self->{_dirty_columns}};
 }
 
+=head2 make_column_dirty
+
+Marks a column dirty regardless if it has really changed.  Throws an
+exception if the column does not exist.
+
+=cut
+sub make_column_dirty {
+  my ($self, $column) = @_;
+
+  $self->throw_exception( "No such column '${column}'" )
+    unless exists $self->{_column_data}{$column} || $self->has_column($column);
+  $self->{_dirty_columns}{$column} = 1;
+}
+
 =head2 get_inflated_columns
 
   my %inflated_data = $obj->get_inflated_columns;
@@ -770,6 +799,19 @@ sub register_column {
   $class->mk_group_accessors('column' => $acc);
 }
 
+=head2 get_from_storage
+
+Returns a new Row which is whatever the Storage has for the currently created
+Row object.  You can use this to see if the storage has become inconsistent with
+whatever your Row object is.
+
+=cut
+
+sub get_from_storage {
+    my $self = shift @_;
+    my @primary_columns = map { $self->$_ } $self->primary_columns;
+    return $self->result_source->resultset->search(undef, {execute_reliably=>1})->find(@primary_columns);      
+}
 
 =head2 throw_exception