[Jifty-commit] jifty-dbi branch, master, updated. 0.66-5-g0c28190

Jifty commits jifty-commit at lists.jifty.org
Sun Feb 27 13:31:49 EST 2011


The branch, master has been updated
       via  0c2819000f1bc3511ebaf20c516a8a1fe1092b65 (commit)
      from  ace56a232a61efe902a82d95a0d56964eb5230e9 (commit)

Summary of changes:
 lib/Jifty/DBI/Record.pm |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 0c2819000f1bc3511ebaf20c516a8a1fe1092b65
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Sun Feb 27 11:12:22 2011 -0500

    Set raw_values when we set values and fetched => 1
    
    Otherwise raw_values is always empty when load_by_hash is used.  The
    most common use case for load_by_hash is instantiating records in a
    collection object.  Note that decoded is still false for all columns.
    
    Before any columns are decoded, values and raw_values should be the same
    (as other places in the code ensure).

diff --git a/lib/Jifty/DBI/Record.pm b/lib/Jifty/DBI/Record.pm
index a840281..e3e046d 100755
--- a/lib/Jifty/DBI/Record.pm
+++ b/lib/Jifty/DBI/Record.pm
@@ -1215,7 +1215,8 @@ sub load_from_hash {
         # Optimization for loading from database
         $self->{values} = $hashref;
         $self->{fetched}{$_} = 1 for keys %{$hashref};
-        $self->{raw_values} = {};
+        # copy $hashref so changing 'values' doesn't change 'raw_values'
+        $self->{raw_values}{$_} = $hashref->{$_} for keys %{$hashref};
         $self->{decoded} = {};
         return $self->{values}{id};
     }
@@ -1231,6 +1232,7 @@ sub load_from_hash {
     foreach my $col ( grep exists $hashref->{ lc $_ }, map $_->name, $self->columns ) {
         $self->{'fetched'}{$col} = 1;
         $self->{'values'}{$col} = $hashref->{ lc $col };
+        $self->{'raw_values'}{$col} = $hashref->{ lc $col };
     }
 
     $self->{'decoded'} = {};

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list