[Bast-commits] r4301 - in
branches/DBIx-Class-Schema-Loader/current: .
lib/DBIx/Class/Schema/Loader t/lib
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Sat Apr 26 00:16:16 BST 2008
Author: ilmari
Date: 2008-04-26 00:16:16 +0100 (Sat, 26 Apr 2008)
New Revision: 4301
Modified:
branches/DBIx-Class-Schema-Loader/current/Changes
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_common_tests.pm
Log:
Strip trailing _id from single-column belongs_to relationships
Modified: branches/DBIx-Class-Schema-Loader/current/Changes
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/Changes 2008-04-25 22:54:54 UTC (rev 4300)
+++ branches/DBIx-Class-Schema-Loader/current/Changes 2008-04-25 23:16:16 UTC (rev 4301)
@@ -2,6 +2,7 @@
0.04999_06 Not Yet Released
- Singularise table monikers by default
+ - Strip trailing _id from single-column belongs_to relationships
0.04999_05 Mon Apr 14, 2008
- Fix limiting table list to the specified schema for DB2
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm 2008-04-25 22:54:54 UTC (rev 4300)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm 2008-04-25 23:16:16 UTC (rev 4301)
@@ -170,10 +170,11 @@
my $remote_relname;
# for single-column case, set the remote relname to the column
- # name, to make filter accessors work
+ # name, to make filter accessors work, but strip trailing _id
if(scalar keys %cond == 1) {
- my ($col) = keys %cond;
- $remote_relname = $self->_inflect_singular($cond{$col});
+ my ($col) = values %cond;
+ $col =~ s/_id$//;
+ $remote_relname = $self->_inflect_singular($col);
}
else {
$remote_relname = $self->_inflect_singular(lc $remote_table);
Modified: branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_common_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_common_tests.pm 2008-04-25 22:54:54 UTC (rev 4300)
+++ branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_common_tests.pm 2008-04-25 23:16:16 UTC (rev 4301)
@@ -401,7 +401,7 @@
isa_ok( $obj6->loader_test2, $class2);
isa_ok( $obj6->loader_test5, $class5);
- ok($class6->column_info('loader_test2')->{is_foreign_key}, 'Foreign key detected');
+ ok($class6->column_info('loader_test2_id')->{is_foreign_key}, 'Foreign key detected');
ok($class6->column_info('id')->{is_foreign_key}, 'Foreign key detected');
ok($class6->column_info('id2')->{is_foreign_key}, 'Foreign key detected');
@@ -753,14 +753,14 @@
CREATE TABLE loader_test6 (
id INTEGER NOT NULL PRIMARY KEY,
Id2 INTEGER,
- loader_test2 INTEGER,
+ loader_test2_id INTEGER,
dat VARCHAR(8),
- FOREIGN KEY (loader_test2) REFERENCES loader_test2 (id),
+ FOREIGN KEY (loader_test2_id) REFERENCES loader_test2 (id),
FOREIGN KEY(id,Id2) REFERENCES loader_test5 (id1,iD2)
) $self->{innodb}
},
- (q{ INSERT INTO loader_test6 (id, id2,loader_test2,dat) } .
+ (q{ INSERT INTO loader_test6 (id, id2,loader_test2_id,dat) } .
q{ VALUES (1, 1,1,'aaa') }),
qq{
More information about the Bast-commits
mailing list