[Bast-commits] r3961 - in DBIx-Class-Partitioned/1.000/trunk:
lib/DBIx/Class t
edenc at dev.catalyst.perl.org
edenc at dev.catalyst.perl.org
Tue Jan 22 02:08:34 GMT 2008
Author: edenc
Date: 2008-01-22 02:08:34 +0000 (Tue, 22 Jan 2008)
New Revision: 3961
Modified:
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm
DBIx-Class-Partitioned/1.000/trunk/t/01-basic.t
Log:
updates partitions properly
Modified: DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm 2008-01-22 02:00:00 UTC (rev 3960)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm 2008-01-22 02:08:34 UTC (rev 3961)
@@ -58,6 +58,15 @@
$partition->storage->delete( $partition, $self->ident_condition );
}
+sub update_partitioned {
+ my ( $self, $to_update ) = @_;
+ my $partition =
+ $self->result_source->partition( $self->_current_partition );
+ return unless %$to_update;
+ $partition->storage->update( $partition, $to_update,
+ $self->ident_condition );
+}
+
sub new {
my $class = shift;
my $self = $class->next::method(@_);
@@ -87,10 +96,10 @@
sub update {
my $self = shift;
+ my %to_update = $self->get_dirty_columns;
$self->next::method(@_);
my $old_part = $self->_current_partition;
my $new_part = $self->_partition_name;
-
if ( $old_part && $new_part ) {
if ( $old_part ne $new_part ) {
$self->delete_partitioned;
@@ -98,7 +107,12 @@
$self->insert_partitioned;
}
else {
- $self->insert_partitioned;
+ if ( $self->in_partition ) {
+ $self->update_partitioned(\%to_update);
+ }
+ else {
+ $self->insert_partitioned;
+ }
}
}
elsif ( !$old_part && $new_part ) {
Modified: DBIx-Class-Partitioned/1.000/trunk/t/01-basic.t
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/t/01-basic.t 2008-01-22 02:00:00 UTC (rev 3960)
+++ DBIx-Class-Partitioned/1.000/trunk/t/01-basic.t 2008-01-22 02:08:34 UTC (rev 3961)
@@ -33,13 +33,21 @@
is( $user->affiliations->first->name, 'foo' );
is( $user->posts->first->title, 'foo' );
is( $user->posts->first->content, 'bar' );
+ ok( !$schema->resultset('ActiveUser')->search( { $user->get_columns } )
+ ->count );
$user->is_expired(0);
$user->update;
ok( $schema->resultset('ActiveUser')->search( { $user->get_columns } )
->count );
ok( $user_rs->result_source->partition('active_user')
->resultset->search( { $user->get_columns } )->count );
-
+ $user->foo('foo');
+ $user->update;
+ ok( $schema->resultset('ActiveUser')->search( { $user->get_columns } )
+ ->count );
+ ok( $user_rs->result_source->partition('active_user')
+ ->resultset->search( { $user->get_columns } )->count );
+ is( $schema->resultset('User')->search({$user->get_columns})->single->foo, 'foo');
is( $user->affiliations->first->name, 'foo' );
is( $user->posts->first->title, 'foo' );
is( $user->posts->first->content, 'bar' );
More information about the Bast-commits
mailing list