[Bast-commits] r3962 - in
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class: .
ResultSource/Table
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue Jan 22 04:01:42 GMT 2008
Author: matthewt
Date: 2008-01-22 04:01:42 +0000 (Tue, 22 Jan 2008)
New Revision: 3962
Modified:
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partition.pm
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm
Log:
clean up partition source registration
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:08:34 UTC (rev 3961)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Partitioned.pm 2008-01-22 04:01:42 UTC (rev 3962)
@@ -72,7 +72,7 @@
my $self = $class->next::method(@_);
$self->_current_partition( $self->_partition_name || '' );
my $original = $self->result_source->original_source;
- $original->schema( $self->result_source->schema );
+# $original->schema( $self->result_source->schema );
$self->result_source($original);
return $self;
}
@@ -82,7 +82,7 @@
my $self = $class->next::method(@_);
$self->_current_partition( $self->_partition_name || '' );
my $original = $self->result_source->original_source;
- $original->schema( $self->result_source->schema );
+# $original->schema( $self->result_source->schema );
$self->result_source($original);
return $self;
}
Modified: DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partition.pm
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partition.pm 2008-01-22 02:08:34 UTC (rev 3961)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partition.pm 2008-01-22 04:01:42 UTC (rev 3962)
@@ -6,8 +6,12 @@
use Scalar::Util ();
use base qw/DBIx::Class::ResultSource::Table/;
-__PACKAGE__->mk_group_accessors( 'simple' => qw/original_source/ );
+__PACKAGE__->mk_group_accessors( 'simple' => qw/original_source_name/ );
+sub original_source {
+ return $_[0]->schema->source($_[0]->original_source_name);
+}
+
sub partition {
return shift->original_source->partition(@_);
}
Modified: DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm 2008-01-22 02:08:34 UTC (rev 3961)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm 2008-01-22 04:01:42 UTC (rev 3962)
@@ -15,13 +15,20 @@
# ugh...
if ( Scalar::Util::blessed($schema) ) {
- foreach my $partition_source ( values %{ $self->_partitions } ) {
- my $result_class = $partition_source->result_class;
- $partition_source->result_class('');
+ my %new_part;
+ foreach my $partition ( keys %{ $self->_partitions } ) {
+ my $old_source = $self->_partitions->{$partition};
+ my $new_source = $old_source->new($old_source);
+ my $new_source_name = $self->source_name.'->partition('.$partition.')';
+ $new_source->result_class('');
$schema->register_source(
- $partition_source->source_name => $partition_source );
- $partition_source->result_class($result_class);
+ $new_source_name => $new_source );
+ $new_source = $schema->source($new_source->source_name);
+ $new_source->original_source_name($self->source_name);
+ $new_source->result_class($old_source->result_class);
+ $new_part{$partition} = $new_source;
}
+ $self->_partitions(\%new_part);
}
return $self->next::method(@_);
@@ -33,10 +40,7 @@
foreach my $partition (@parts) {
my $new_source =
DBIx::Class::ResultSource::Table::Partition->new($self);
- $new_source->original_source($self);
- Scalar::Util::weaken( $new_source->{original_source} );
- my $new_source_name = join '::', map { ucfirst } split '_', $partition;
- $new_source->source_name($new_source_name);
+ $new_source->original_source_name($self->source_name);
$new_source->name($partition);
$new_source->_relationships(
Storable::dclone( $new_source->_relationships ) );
More information about the Bast-commits
mailing list