[Bast-commits] r6753 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class
t/inflate
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sun Jun 21 12:37:57 GMT 2009
Author: ribasushi
Date: 2009-06-21 12:37:56 +0000 (Sun, 21 Jun 2009)
New Revision: 6753
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/trunk/t/inflate/serialize.t
Log:
make_column_dirty fix
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2009-06-21 07:00:21 UTC (rev 6752)
+++ DBIx-Class/0.08/trunk/Changes 2009-06-21 12:37:56 UTC (rev 6753)
@@ -6,7 +6,9 @@
nonexisting prefetch
- Fixed the prefetch with limit bug
- New resultsed method count_rs, returns a ::ResultSetColumn
- returning a single count value
+ which in turn returns a single count value
+ - make_column_dirty() now overwrites the deflated value with an
+ inflated one if such exists
0.08107 2009-06-14 08:21:00 (UTC)
- Fix serialization regression introduced in 0.08103 (affects
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-06-21 07:00:21 UTC (rev 6752)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-06-21 12:37:56 UTC (rev 6753)
@@ -710,7 +710,21 @@
$self->throw_exception( "No such column '${column}'" )
unless exists $self->{_column_data}{$column} || $self->has_column($column);
+
+ # the entire clean/dirty code relieas on exists, not on true/false
+ return 1 if exists $self->{_dirty_columns}{$column};
+
$self->{_dirty_columns}{$column} = 1;
+
+ # if we are just now making the column dirty, and if there is an inflated
+ # value, force it over the deflated one
+ if (exists $self->{_inflated_column}{$column}) {
+ $self->store_column($column,
+ $self->_deflated_column(
+ $column, $self->{_inflated_column}{$column}
+ )
+ );
+ }
}
=head2 get_inflated_columns
Modified: DBIx-Class/0.08/trunk/t/inflate/serialize.t
===================================================================
--- DBIx-Class/0.08/trunk/t/inflate/serialize.t 2009-06-21 07:00:21 UTC (rev 6752)
+++ DBIx-Class/0.08/trunk/t/inflate/serialize.t 2009-06-21 12:37:56 UTC (rev 6753)
@@ -32,7 +32,7 @@
plan (skip_all => "No suitable serializer found") unless $selected;
-plan (tests => 8);
+plan (tests => 11);
DBICTest::Schema::Serialized->inflate_column( 'serialized',
{ inflate => $selected->{inflater},
deflate => $selected->{deflater},
@@ -84,3 +84,17 @@
ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
ok($inflated = $object->serialized, 'arrayref inflation');
is_deeply($inflated, $struct_array, 'inflated array matches original');
+
+
+#===== make sure make_column_dirty ineracts reasonably with inflation
+$object = $rs->first;
+$object->update ({serialized => { x => 'y'}});
+
+$object->serialized->{x} = 'z'; # change state without notifying $object
+ok (!$object->get_dirty_columns, 'no dirty columns yet');
+is_deeply ($object->serialized, { x => 'z' }, 'object data correct');
+
+$object->make_column_dirty('serialized');
+$object->update;
+
+is_deeply ($rs->first->serialized, { x => 'z' }, 'changes made it to the db' );
More information about the Bast-commits
mailing list