From: Rafael Kitover Date: Sat, 20 Feb 2010 03:52:15 +0000 (-0500) Subject: tests for new _id stripping code X-Git-Tag: 0.05003~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d13aecb1c69f045203333458d35ac838c1802374;p=dbsrgits%2FDBIx-Class-Schema-Loader.git tests for new _id stripping code --- diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index b810d7c..d97ec0c 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -249,7 +249,7 @@ sub generate_code { my $colnames = q{_} . join(q{_}, @$local_cols); $remote_relname .= $colnames if keys %cond > 1; $local_relname = $self->_multi_rel_local_relname( - $local_table, $local_cols + $remote_class, $local_table, $local_cols ); } else { $local_relname = $self->_inflect_plural(lc $local_table); @@ -291,7 +291,7 @@ sub generate_code { } sub _multi_rel_local_relname { - my ($self, $local_table, $local_cols) = @_; + my ($self, $remote_class, $local_table, $local_cols) = @_; my $colnames = q{_} . join(q{_}, @$local_cols); my $old_relname = #< TODO: remove me after 0.05003 release @@ -301,7 +301,7 @@ sub _multi_rel_local_relname { # TODO: remove me after 0.05003 release $old_relname = $self->_inflect_plural( $old_relname ); - warn __PACKAGE__." $VERSION: warning, stripping trailing _id from ${local_table} relation '$old_relname', renaming to '$local_relname'. This behavior is new as of 0.05003.\n" + warn __PACKAGE__." $VERSION: warning, stripping trailing _id from ${remote_class} relation '$old_relname', renaming to '$local_relname'. This behavior is new as of 0.05003.\n" if $stripped_id; return $local_relname; diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm index 7b4451e..f3e46ed 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_040.pm @@ -31,7 +31,7 @@ sub _remote_relname { } sub _multi_rel_local_relname { - my ($self, $local_table, $local_cols) = @_; + my ($self, $remote_class, $local_table, $local_cols) = @_; my $colnames = q{_} . join(q{_}, @$local_cols); my $local_relname = $self->_inflect_plural( lc($local_table) . $colnames ); diff --git a/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm b/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm index 3a64bc3..42920dd 100644 --- a/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm +++ b/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm @@ -43,7 +43,7 @@ sub _monikerize { sub run_tests { my $self = shift; - plan tests => 88; + plan tests => 89; $self->create(); @@ -462,6 +462,9 @@ sub run_tests { isa_ok( $obj13->id, $class12 ); isa_ok( $obj13->loader_test12, $class12); isa_ok( $obj13->dat, $class12); + + my $obj12 = $rsobj12->find(1); + isa_ok( $obj12->loader_test13_ids, "DBIx::Class::ResultSet" ); } SKIP: { diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index b134845..4520528 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -83,7 +83,7 @@ sub _custom_column_info { sub run_tests { my $self = shift; - plan tests => 155 + ($self->{extra}->{count} || 0); + plan tests => 156 + ($self->{extra}->{count} || 0); $self->create(); @@ -707,6 +707,9 @@ sub test_schema { isa_ok( $obj13->id, $class12 ); isa_ok( $obj13->loader_test12, $class12); isa_ok( $obj13->dat, $class12); + + my $obj12 = $rsobj12->find(1); + isa_ok( $obj12->loader_test13, $class13 ); } SKIP: {