[Bast-commits] r8837 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Relationship t/relationship
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Mar 1 00:36:23 GMT 2010
Author: ribasushi
Date: 2010-03-01 00:36:23 +0000 (Mon, 01 Mar 2010)
New Revision: 8837
Added:
DBIx-Class/0.08/trunk/t/relationship/unresolvable.t
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Base.pm
Log:
Fix incorrect placement of condition resolution failure trap
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Base.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Base.pm 2010-03-01 00:31:51 UTC (rev 8836)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Base.pm 2010-03-01 00:36:23 UTC (rev 8837)
@@ -202,12 +202,16 @@
my $source = $self->result_source;
# condition resolution may fail if an incomplete master-object prefetch
- # is encountered
- my $cond =
- eval { $source->_resolve_condition( $rel_info->{cond}, $rel, $self ) }
- ||
- $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION
- ;
+ # is encountered - that is ok during prefetch construction (not yet in_storage)
+ my $cond = eval { $source->_resolve_condition( $rel_info->{cond}, $rel, $self ) };
+ if (my $err = $@) {
+ if ($self->in_storage) {
+ $self->throw_exception ($err);
+ }
+ else {
+ $cond = $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION;
+ }
+ }
if ($cond eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) {
my $reverse = $source->reverse_relationship_info($rel);
Added: DBIx-Class/0.08/trunk/t/relationship/unresolvable.t
===================================================================
--- DBIx-Class/0.08/trunk/t/relationship/unresolvable.t (rev 0)
+++ DBIx-Class/0.08/trunk/t/relationship/unresolvable.t 2010-03-01 00:36:23 UTC (rev 8837)
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+my $cd = $schema->resultset('CD')->search ({}, { columns => ['year'], rows => 1 })->single;
+
+
+throws_ok (
+ sub { $cd->tracks },
+ qr/Unable to resolve relationship .+ column .+ not loaded from storage/,
+ 'Correct exception on nonresolvable object-based condition'
+);
+
+done_testing;
More information about the Bast-commits
mailing list