[Bast-commits] r3853 -
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue Nov 6 14:53:48 GMT 2007
Author: matthewt
Date: 2007-11-06 14:53:48 +0000 (Tue, 06 Nov 2007)
New Revision: 3853
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/BelongsTo.pm
Log:
make belongs_to accept an [] join cond
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/BelongsTo.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/BelongsTo.pm 2007-11-03 02:17:11 UTC (rev 3852)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/BelongsTo.pm 2007-11-06 14:53:48 UTC (rev 3853)
@@ -41,20 +41,25 @@
);
}
# explicit join condition
- elsif (ref $cond eq 'HASH') {
- my $cond_rel;
- for (keys %$cond) {
- if (m/\./) { # Explicit join condition
- $cond_rel = $cond;
- last;
+ elsif (ref $cond) {
+ if (ref $cond eq 'HASH') { # ARRAY is also valid
+ my $cond_rel;
+ for (keys %$cond) {
+ if (m/\./) { # Explicit join condition
+ $cond_rel = $cond;
+ last;
+ }
+ $cond_rel->{"foreign.$_"} = "self.".$cond->{$_};
}
- $cond_rel->{"foreign.$_"} = "self.".$cond->{$_};
+ $cond = $cond_rel;
}
- my $acc_type = (keys %$cond_rel == 1 and $class->has_column($rel))
- ? 'filter'
- : 'single';
+ my $acc_type = ((ref $cond eq 'HASH')
+ && keys %$cond == 1
+ && $class->has_column($rel))
+ ? 'filter'
+ : 'single';
$class->add_relationship($rel, $f_class,
- $cond_rel,
+ $cond,
{ accessor => $acc_type, %{$attrs || {}} }
);
}
More information about the Bast-commits
mailing list