From: Peter Rabbitson Date: Thu, 12 Nov 2009 00:40:14 +0000 (+0000) Subject: Fix return value of in_storage X-Git-Tag: v0.08113~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=63bb9738dd8fdca42ad88d99a2a3861ad2b00eed;p=dbsrgits%2FDBIx-Class.git Fix return value of in_storage --- diff --git a/Changes b/Changes index e2e4ae0..a5c5cee 100644 --- a/Changes +++ b/Changes @@ -32,6 +32,7 @@ Revision history for DBIx::Class - Improvements to populate's handling of mixed scalarref values - Fixed regression losing result_class after $rs->find (introduced in 0.08108) + - Fix in_storage() to return 1|0 as per existing documentation - POD improvements 0.08112 2009-09-21 10:57:00 (UTC) diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index f708d21..75b64db 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -424,7 +424,7 @@ L on one, sets it to false. sub in_storage { my ($self, $val) = @_; $self->{_in_storage} = $val if @_ > 1; - return $self->{_in_storage}; + return $self->{_in_storage} ? 1 : 0; } =head2 update diff --git a/t/60core.t b/t/60core.t index b62b82d..8ab6129 100644 --- a/t/60core.t +++ b/t/60core.t @@ -65,7 +65,7 @@ lives_ok (sub { $art->delete }, 'Cascading delete on Ordered has_many works' ); is(@art, 2, 'And then there were two'); -ok(!$art->in_storage, "It knows it's dead"); +is($art->in_storage, 0, "It knows it's dead"); dies_ok ( sub { $art->delete }, "Can't delete twice"); @@ -144,7 +144,7 @@ is($schema->resultset("Artist")->count, 4, 'count ok'); }); is($new_obj->name, 'find_or_new', 'find_or_new: instantiated a new artist'); - ok(! $new_obj->in_storage, 'new artist is not in storage'); + is($new_obj->in_storage, 0, 'new artist is not in storage'); } my $cd = $schema->resultset("CD")->find(1); diff --git a/t/79aliasing.t b/t/79aliasing.t index 94ae02b..4f9b3a3 100644 --- a/t/79aliasing.t +++ b/t/79aliasing.t @@ -52,7 +52,7 @@ plan tests => 11; my $cd_rs = $schema->resultset('CD')->search({ 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); my $cd = $cd_rs->find_or_new({ title => 'Huh?', year => 2006 }); - ok(! $cd->in_storage, 'new CD not in storage yet'); + is($cd->in_storage, 0, 'new CD not in storage yet'); is($cd->title, 'Huh?', 'new CD title is correct'); is($cd->year, 2006, 'new CD year is correct'); } diff --git a/t/80unique.t b/t/80unique.t index 2245511..0e4108b 100644 --- a/t/80unique.t +++ b/t/80unique.t @@ -195,7 +195,7 @@ is($row->baz, 3, 'baz is correct'); { key => 'cd_artist_title' } ); - ok(!$cd1->in_storage, 'CD is not in storage yet after update_or_new'); + is($cd1->in_storage, 0, 'CD is not in storage yet after update_or_new'); $cd1->insert; ok($cd1->in_storage, 'CD got added to strage after update_or_new && insert'); diff --git a/t/relationship/core.t b/t/relationship/core.t index 6a09c57..90e49a3 100644 --- a/t/relationship/core.t +++ b/t/relationship/core.t @@ -133,7 +133,7 @@ $cd = $artist->find_or_new_related( 'cds', { year => 2007, } ); is( $cd->title, 'Greatest Hits 2: Louder Than Ever', 'find_or_new_related new record ok' ); -ok( ! $cd->in_storage, 'find_or_new_related on a new record: not in_storage' ); +is( $cd->in_storage, 0, 'find_or_new_related on a new record: not in_storage' ); $cd->artist(undef); my $newartist = $cd->find_or_new_related( 'artist', {