[Bast-commits] r3969 - in DBIx-Class-Partitioned/1.000/trunk:
lib/DBIx/Class/ResultSource/Table lib/DBIx/Class/Schema t
edenc at dev.catalyst.perl.org
edenc at dev.catalyst.perl.org
Wed Jan 23 00:40:13 GMT 2008
Author: edenc
Date: 2008-01-23 00:40:13 +0000 (Wed, 23 Jan 2008)
New Revision: 3969
Added:
DBIx-Class-Partitioned/1.000/trunk/t/03-source_registrations.t
Modified:
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm
DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Schema/Partitioned.pm
Log:
fixing partitioned source registration
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 20:58:23 UTC (rev 3968)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/ResultSource/Table/Partitioned.pm 2008-01-23 00:40:13 UTC (rev 3969)
@@ -21,7 +21,6 @@
%$self,
name => $partition,
_relationships => Storable::dclone( $self->_relationships ),
- result_class => '',
original_source_name => $self->source_name,
}
);
@@ -30,8 +29,6 @@
my $new_source_name =
$self->source_name . '->partition(' . $partition . ')';
$schema->register_source( $new_source_name => $new_source );
- $schema->source( $new_source->source_name )
- ->result_class( $self->result_class );
}
}
Modified: DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Schema/Partitioned.pm
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Schema/Partitioned.pm 2008-01-22 20:58:23 UTC (rev 3968)
+++ DBIx-Class-Partitioned/1.000/trunk/lib/DBIx/Class/Schema/Partitioned.pm 2008-01-23 00:40:13 UTC (rev 3969)
@@ -6,6 +6,20 @@
use base qw/DBIx::Class/;
__PACKAGE__->load_components('Schema::RestrictWithObject');
+sub register_source {
+ my $self = shift;
+ my ( $moniker, $source ) = @_;
+ my $result_class;
+ if ( $source->isa('DBIx::Class::ResultSource::Table::Partition') ) {
+ $result_class = $source->result_class;
+ $source->result_class('');
+ }
+ $self->next::method(@_);
+ $source->result_class($result_class),
+ $self->source( $source->source_name )->result_class($result_class)
+ if $result_class;
+}
+
sub source {
my $self = shift;
my $source = $self->next::method(@_);
Added: DBIx-Class-Partitioned/1.000/trunk/t/03-source_registrations.t
===================================================================
--- DBIx-Class-Partitioned/1.000/trunk/t/03-source_registrations.t (rev 0)
+++ DBIx-Class-Partitioned/1.000/trunk/t/03-source_registrations.t 2008-01-23 00:40:13 UTC (rev 3969)
@@ -0,0 +1,23 @@
+use warnings;
+use strict;
+
+use Test::More qw/no_plan/;
+use lib 't/lib';
+use My::Schema;
+my $schema = My::Schema->connect('dbi:SQLite:dbname=t/test.db');
+isa_ok( $schema->source('My::Schema::User'),
+ 'DBIx::Class::ResultSource::Table::Partitioned' );
+isa_ok( $schema->source('User'),
+ 'DBIx::Class::ResultSource::Table::Partitioned' );
+$schema = $schema->restrict_with_object( bless {}, 'Test::RestrictingObject' );
+isa_ok( $schema->source('My::Schema::User'),
+ 'DBIx::Class::ResultSource::Table::Partition' );
+isa_ok( $schema->source('User'),
+ 'DBIx::Class::ResultSource::Table::Partition' );
+
+package Test::RestrictingObject;
+
+sub restrict_User_source {
+ my ( $self, $source ) = @_;
+ return $source->partition('active_user');
+}
More information about the Bast-commits
mailing list