[Bast-commits] r6800 -
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Fri Jun 26 20:17:56 GMT 2009
Author: ilmari
Date: 2009-06-26 20:17:55 +0000 (Fri, 26 Jun 2009)
New Revision: 6800
Modified:
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
Log:
Factor out remote relname for back-compat overridability
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 2009-06-26 18:48:22 UTC (rev 6799)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/RelBuilder.pm 2009-06-26 20:17:55 UTC (rev 6800)
@@ -158,6 +158,24 @@
return $nullable ? { join_type => 'LEFT' } : ();
}
+sub _remote_relname {
+ my ($self, $remote_table, $cond) = @_;
+
+ my $remote_relname;
+ # for single-column case, set the remote relname to the column
+ # name, to make filter accessors work, but strip trailing _id
+ if(scalar keys %{$cond} == 1) {
+ my ($col) = values %{$cond};
+ $col =~ s/_id$//;
+ $remote_relname = $self->_inflect_singular($col);
+ }
+ else {
+ $remote_relname = $self->_inflect_singular(lc $remote_table);
+ }
+
+ return $remote_relname;
+}
+
sub generate_code {
my ($self, $local_moniker, $rels, $uniqs) = @_;
@@ -193,19 +211,8 @@
}
my $local_relname;
- my $remote_relname;
+ my $remote_relname = $self->_remote_relname($remote_table, \%cond);
- # for single-column case, set the remote relname to the column
- # name, to make filter accessors work, but strip trailing _id
- if(scalar keys %cond == 1) {
- my ($col) = values %cond;
- $col =~ s/_id$//;
- $remote_relname = $self->_inflect_singular($col);
- }
- else {
- $remote_relname = $self->_inflect_singular(lc $remote_table);
- }
-
# If more than one rel between this pair of tables, use the local
# col names to distinguish
if($counters{$remote_moniker} > 1) {
More information about the Bast-commits
mailing list