From: Amiri Barksdale at Home Date: Thu, 23 Dec 2010 21:34:02 +0000 (-0800) Subject: Re-adding sequence to raw table not working X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e96b2eebed68a7fd29cb74cf88603b6c02e42483;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Re-adding sequence to raw table not working --- diff --git a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm index 9dceab6..cfeb9c0 100644 --- a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm +++ b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm @@ -164,6 +164,15 @@ method attach_additional_sources () { $self->columns ); $table->set_primary_key($self->primary_columns); + + # Attempting to re-add sequence here -- AKB + for my $pk ( $self->primary_columns ) { + $table->columns_info->{$pk}->{sequence} = + $self->set_sequence( $table->name, $self->primary_columns ) + unless grep { + $table->columns_info->{$_}->{originally_defined_in} ne $self->name + } keys %{ $table->columns_info }; + } # we need to copy our rels to the raw object as well # note that ->add_relationship on a source object doesn't create an @@ -224,6 +233,10 @@ method set_primary_key (@args) { return $self->next::method(@args); } +method set_sequence ($table_name, @pks) { + return $table_name . '_' . join('_',@pks) . '_' . 'seq'; +} + method raw_source_name () { my $base = $self->source_name; confess "Can't generate raw source name for ${\$self->name} when we don't have a source_name" diff --git a/t/03insert.t b/t/03insert.t index 275a753..d237f4a 100644 --- a/t/03insert.t +++ b/t/03insert.t @@ -37,3 +37,5 @@ lives_ok { $drink1 = $schema->resultset('Coffee')->create( { flavor => 'aaight', } ); } "I can do it for the other view, too"; + + diff --git a/t/lib/Cafe/Result/Coffee.pm b/t/lib/Cafe/Result/Coffee.pm index 9468ddb..9562ecc 100644 --- a/t/lib/Cafe/Result/Coffee.pm +++ b/t/lib/Cafe/Result/Coffee.pm @@ -8,7 +8,7 @@ use aliased 'DBIx::Class::ResultSource::MultipleTableInheritance' => 'MTI'; __PACKAGE__->table_class(MTI); __PACKAGE__->table('coffee'); __PACKAGE__->add_columns( - "id", { data_type => "integer", is_auto_increment => 1, sequence => '_coffee_id_seq'}, + "id", { data_type => "integer", is_auto_increment => 1}, "flavor", { data_type => "text", default_value => "good" }, );