From: Guillermo Roditi Date: Mon, 9 Feb 2009 20:27:27 +0000 (+0000) Subject: backporting the set_column/store_column fix X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e80c4ca9995674bcc86bc59780b940ce20c48d2;p=dbsrgits%2FDBIx-Class-Historic.git backporting the set_column/store_column fix --- diff --git a/Changes b/Changes index 6ad0a6d..24cd9c6 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,8 @@ Revision history for DBIx::Class - new order_by => { -desc => 'colname' } syntax supported with SQLA >= 1.50 - PG array datatype supported with SQLA >= 1.50 + - insert should use store_column, not set_column to avoid marking + clean just-stored values as dirty. New test for this (groditi) 0.08099_05 2008-10-30 21:30:00 (UTC) - Rewritte of Storage::DBI::connect_info(), extended with an diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 134e841..ba05001 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -263,7 +263,9 @@ sub insert { } my $updated_cols = $source->storage->insert($source, { $self->get_columns }); - $self->set_columns($updated_cols); + foreach my $col (keys %$updated_cols) { + $self->store_column($col, $updated_cols->{$col}); + } ## PK::Auto my @auto_pri = grep { diff --git a/t/60core.t b/t/60core.t index d41b551..8e1ff46 100644 --- a/t/60core.t +++ b/t/60core.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 86; +plan tests => 88; eval { require DateTime::Format::MySQL }; my $NO_DTFM = $@ ? 1 : 0; @@ -379,3 +379,11 @@ SKIP: { my $table = $class->table($class->table); is($table, $class->table, '->table($table) returns $table'); } + +#make sure insert doesn't use set_column +{ + my $en_row = $schema->resultset('Encoded')->new_result({encoded => 'wilma'}); + is($en_row->encoded, 'amliw', 'new encodes'); + $en_row->insert; + is($en_row->encoded, 'amliw', 'insert does not encode again'); +} diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index 11157f2..a35d54e 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -44,7 +44,7 @@ __PACKAGE__->load_classes(qw/ ), qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/, qw/Collection CollectionObject TypedObject Owners BooksInLibrary/, - qw/ForceForeign/, + qw/ForceForeign Encoded/, ); sub sqlt_deploy_hook { diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 263b234..ebc10cd 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -411,5 +411,12 @@ CREATE TABLE typed_object ( value varchar(100) NOT NULL ); +-- +-- Table: encoded +-- +CREATE TABLE encoded ( + id INTEGER PRIMARY KEY NOT NULL, + encoded varchar(100) NOT NULL +); COMMIT;