[Bast-commits] r5409 - in DBIx-Class/0.08/branches/multi_stuff/t: .
lib lib/DBICTest lib/DBICTest/Schema
groditi at dev.catalyst.perl.org
groditi at dev.catalyst.perl.org
Wed Feb 4 21:23:06 GMT 2009
Author: groditi
Date: 2009-02-04 21:23:06 +0000 (Wed, 04 Feb 2009)
New Revision: 5409
Added:
DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema/Encoded.pm
Modified:
DBIx-Class/0.08/branches/multi_stuff/t/60core.t
DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema.pm
DBIx-Class/0.08/branches/multi_stuff/t/lib/sqlite.sql
Log:
adding failing test to make sure insert doesnt call set_column
Modified: DBIx-Class/0.08/branches/multi_stuff/t/60core.t
===================================================================
--- DBIx-Class/0.08/branches/multi_stuff/t/60core.t 2009-02-04 11:43:10 UTC (rev 5408)
+++ DBIx-Class/0.08/branches/multi_stuff/t/60core.t 2009-02-04 21:23:06 UTC (rev 5409)
@@ -7,7 +7,7 @@
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 @@
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');
+}
Added: DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema/Encoded.pm
===================================================================
--- DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema/Encoded.pm (rev 0)
+++ DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema/Encoded.pm 2009-02-04 21:23:06 UTC (rev 5409)
@@ -0,0 +1,39 @@
+package # hide from PAUSE
+ DBICTest::Schema::Encoded;
+
+use base 'DBIx::Class::Core';
+
+use strict;
+use warnings;
+
+__PACKAGE__->table('encoded');
+__PACKAGE__->add_columns(
+ 'id' => {
+ data_type => 'integer',
+ is_auto_increment => 1
+ },
+ 'encoded' => {
+ data_type => 'varchar',
+ size => 100,
+ is_nullable => 1,
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+sub set_column {
+ my ($self, $col, $value) = @_;
+ if( $col eq 'encoded' ){
+ $value = reverse split '', $value;
+ }
+ $self->next::method($col, $value);
+}
+
+sub new {
+ my($self, $attr, @rest) = @_;
+ $attr->{encoded} = reverse split '', $attr->{encoded}
+ if defined $attr->{encoded};
+ return $self->next::method($attr, @rest);
+}
+
+1;
Modified: DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema.pm 2009-02-04 11:43:10 UTC (rev 5408)
+++ DBIx-Class/0.08/branches/multi_stuff/t/lib/DBICTest/Schema.pm 2009-02-04 21:23:06 UTC (rev 5409)
@@ -44,7 +44,7 @@
),
qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/,
qw/Collection CollectionObject TypedObject Owners BooksInLibrary/,
- qw/ForceForeign/,
+ qw/ForceForeign Encoded/,
);
sub sqlt_deploy_hook {
Modified: DBIx-Class/0.08/branches/multi_stuff/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/branches/multi_stuff/t/lib/sqlite.sql 2009-02-04 11:43:10 UTC (rev 5408)
+++ DBIx-Class/0.08/branches/multi_stuff/t/lib/sqlite.sql 2009-02-04 21:23:06 UTC (rev 5409)
@@ -423,5 +423,12 @@
value varchar(100) NOT NULL
);
+--
+-- Table: encoded
+--
+CREATE TABLE encoded (
+ id INTEGER PRIMARY KEY NOT NULL,
+ encoded varchar(100) NOT NULL
+);
COMMIT;
More information about the Bast-commits
mailing list