DBIx::Class::Row::Delta - Keep track of and report on changes to a DBIC row object.


Record an initial set of values for a DBIC row, and later on get a string with the changed values.


  use DBIx::Class::Row::Delta;

  my $book = $book_rs->find(321);
  my $book_notes_delta = DBIC::Row::Delta->new({
      dbic_row    => $book,
      changes_sub => sub {
          my ($row) = @_;
          return {
              "Book Type"     => $row->book_type->type,
              "Book Title"    => $row->book_title->title // "N/A",
              "Delivery Date" => $row->delivery_date->ymd,

  # ...
  # Do stuff to $book, ->update(), etc.
  # ...

  # Note: this will discard_changes on $book.
  my $changes_string = $book_notes_delta->changes;
  # e.g.
  # Book SKU (1933021-002 => 1933023-001), Delivery Date (2012-01-18 => 2012-01-22)


new({ $dbic_row!, &$changes_sub! }) : $new_object | die

Create a new object. Start by taking a snapshot of the contents of $dbic_row by calling $changes_sub->($dbic_row).

The sub ref $changes_sub should return a hash ref with keys and values that describe the state of the object. If the values look weird when stringified, you're responsible for formatting them properly. All the hash ref values should be strings or undef.

Both dbic_row and changes_sub are required.

changes() : $delta_string | undef

Return a string representation of the diff between the initial snapshot and the current state of $dbic_row, or return undef if they are the same. Only the changed values are reported.


    Book SKU (1933021-002 => 1933023-001), Delivery Date (2012-01-18 => 2012-01-22)

Note: This will start by calling $dbic_row->discard to refresh the data properly.


Please report any bugs or feature requests to bug-dbix-class-row-delta at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc DBIx::Class::Row::Delta

You can also look for information at:


The source for this module is on GitHub:

Patches welcome, etc.


Johan Lindstrom - on behalf of Net-A-Porter -


Copyright 2012- Net-A-Porter.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.


Thanks to Net-A-Porter for providing time during one of the regular Hack-days.