[Bast-commits] r5458 - in DBIx-Class/0.08/trunk: .
lib/DBIx/Class/Relationship t
groditi at dev.catalyst.perl.org
groditi at dev.catalyst.perl.org
Thu Feb 12 01:49:26 GMT 2009
Author: groditi
Date: 2009-02-12 01:49:26 +0000 (Thu, 12 Feb 2009)
New Revision: 5458
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm
DBIx-Class/0.08/trunk/t/66relationship.t
Log:
fixed bug for undef_on_null_fk edge case
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2009-02-11 16:24:11 UTC (rev 5457)
+++ DBIx-Class/0.08/trunk/Changes 2009-02-12 01:49:26 UTC (rev 5458)
@@ -1,6 +1,7 @@
Revision history for DBIx::Class
- Possible to set locale in IC::DateTime extra => {} config
-
+ - Calling the accessor of a belongs_to when the foreign_key
+ was NULL and the row was not stored would unexpectedly fail (groditi)
0.08099_06 2009-01-23 07:30:00 (UTC)
- Allow a scalarref to be supplied to the 'from' resultset attribute
- Classes submitted as result_class for a resultsource are now
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm 2009-02-11 16:24:11 UTC (rev 5457)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm 2009-02-12 01:49:26 UTC (rev 5458)
@@ -31,6 +31,7 @@
$rel_info->{cond}, $rel, $self
);
if ($rel_info->{attrs}->{undef_on_null_fk}){
+ return unless ref($cond) eq 'HASH';
return if grep { not defined } values %$cond;
}
my $val = $self->find_related($rel, {}, {});
Modified: DBIx-Class/0.08/trunk/t/66relationship.t
===================================================================
--- DBIx-Class/0.08/trunk/t/66relationship.t 2009-02-11 16:24:11 UTC (rev 5457)
+++ DBIx-Class/0.08/trunk/t/66relationship.t 2009-02-12 01:49:26 UTC (rev 5458)
@@ -8,7 +8,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 74;
+plan tests => 75;
# has_a test
my $cd = $schema->resultset("CD")->find(4);
@@ -228,7 +228,10 @@
$undef_artist_cd->related_resultset('artist')->new({name => 'foo'});
};
is( $@, '', "Object created on a resultset related to not yet inserted object");
-
+lives_ok{
+ $schema->resultset('Artwork')->new_result({})->cd;
+} 'undef_on_null_fk does not choke on empty conds';
+
my $def_artist_cd = $schema->resultset("CD")->new_result({ 'title' => 'badgers', 'year' => 2007, artist => undef });
is($def_artist_cd->has_column_loaded('artist'), 1, 'FK loaded');
is($def_artist_cd->search_related('artist')->count, 0, 'closed search on null FK');
More information about the Bast-commits
mailing list