From: Dan Kubb Date: Sat, 6 Aug 2005 22:15:21 +0000 (+0000) Subject: Renamed DBIx::Class::Table::in_database to DBIx::Class::Table::in_storage X-Git-Tag: v0.03001~64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=8d5134b09734852f9c11a3fd6b1c8f6551637b53;hp=656796f2088da66cc80f4eb127c39c923ef3c1dd Renamed DBIx::Class::Table::in_database to DBIx::Class::Table::in_storage Updated affected libraries and test cases --- diff --git a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm index f576276..fb33a0a 100644 --- a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm +++ b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm @@ -10,7 +10,7 @@ __PACKAGE__->mk_classdata('__AutoCommit'); sub set_column { my $self = shift; my $ret = $self->NEXT::set_column(@_); - $self->update if ($self->autoupdate && $self->{_in_database}); + $self->update if ($self->autoupdate && $self->{_in_storage}); return $ret; } diff --git a/lib/DBIx/Class/CDBICompat/LazyLoading.pm b/lib/DBIx/Class/CDBICompat/LazyLoading.pm index 8e2c2ae..6a33eff 100644 --- a/lib/DBIx/Class/CDBICompat/LazyLoading.pm +++ b/lib/DBIx/Class/CDBICompat/LazyLoading.pm @@ -10,7 +10,7 @@ sub _select_columns { sub get_column { my ($self, $col) = @_; if ((ref $self) && (!exists $self->{'_column_data'}{$col}) - && $self->{'_in_database'}) { + && $self->{'_in_storage'}) { $self->_flesh(grep { exists $self->_column_groups->{$_}{$col} && $_ ne 'All' } keys %{ $self->_column_groups || {} }); diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index 29a995e..4c52191 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -85,7 +85,7 @@ sub discard_changes { if (my $key = $self->_live_object_key) { $self->remove_from_object_index; my $ret = $self->NEXT::ACTUAL::discard_changes; - $self->live_object_index->{$key} = $self if $self->in_database; + $self->live_object_index->{$key} = $self if $self->in_storage; return $ret; } else { return $self->NEXT::ACTUAL::discard_changes; diff --git a/lib/DBIx/Class/PK.pm b/lib/DBIx/Class/PK.pm index e420ac6..d31cfe4 100644 --- a/lib/DBIx/Class/PK.pm +++ b/lib/DBIx/Class/PK.pm @@ -71,10 +71,10 @@ sub find { sub discard_changes { my ($self) = @_; delete $self->{_dirty_columns}; - return unless $self->in_database; # Don't reload if we aren't real! + return unless $self->in_storage; # Don't reload if we aren't real! my ($reload) = $self->find($self->id); unless ($reload) { # If we got deleted in the mean-time - $self->in_database(0); + $self->in_storage(0); return $self; } delete @{$self}{keys %$self}; diff --git a/lib/DBIx/Class/Table.pm b/lib/DBIx/Class/Table.pm index 144826f..2a491e4 100644 --- a/lib/DBIx/Class/Table.pm +++ b/lib/DBIx/Class/Table.pm @@ -64,7 +64,7 @@ the object itself. sub insert { my ($self) = @_; - return $self if $self->in_database; + return $self if $self->in_storage; #use Data::Dumper; warn Dumper($self); my %in; $in{$_} = $self->get_column($_) @@ -72,24 +72,24 @@ sub insert { my %out = %{ $self->storage->insert($self->_table_name, \%in) }; $self->store_column($_, $out{$_}) for grep { $self->get_column($_) ne $out{$_} } keys %out; - $self->in_database(1); + $self->in_storage(1); $self->{_dirty_columns} = {}; return $self; } -=item in_database +=item in_storage - $obj->in_database; # Get value - $obj->in_database(1); # Set value + $obj->in_storage; # Get value + $obj->in_storage(1); # Set value Indicated whether the object exists as a row in the database or not =cut -sub in_database { +sub in_storage { my ($self, $val) = @_; - $self->{_in_database} = $val if @_ > 1; - return $self->{_in_database}; + $self->{_in_storage} = $val if @_ > 1; + return $self->{_in_storage}; } =item create @@ -117,7 +117,7 @@ UPDATE query to commit any changes to the object to the db if required. sub update { my ($self, $upd) = @_; - $self->throw( "Not in database" ) unless $self->in_database; + $self->throw( "Not in database" ) unless $self->in_storage; my %to_update = %{$upd || {}}; $to_update{$_} = $self->get_column($_) for $self->is_changed; return -1 unless keys %to_update; @@ -144,7 +144,7 @@ sub ident_condition { $obj->delete Deletes the object from the database. The object is still perfectly usable -accessor-wise etc. but ->in_database will now return 0 and the object must +accessor-wise etc. but ->in_storage will now return 0 and the object must be re ->insert'ed before it can be ->update'ed =cut @@ -152,10 +152,10 @@ be re ->insert'ed before it can be ->update'ed sub delete { my $self = shift; if (ref $self) { - $self->throw( "Not in database" ) unless $self->in_database; + $self->throw( "Not in database" ) unless $self->in_storage; #warn $self->_ident_cond.' '.join(', ', $self->_ident_values); $self->storage->delete($self->_table_name, $self->ident_condition); - $self->in_database(undef); + $self->in_storage(undef); #$self->store_column($_ => undef) for $self->primary_columns; # Should probably also arrange to trash PK if auto # but if we do, post-delete cascade triggers fail :/ @@ -308,7 +308,7 @@ sub _row_to_object { # WARNING: Destructive to @$row my ($class, $cols, $row) = @_; my $new = $class->new; $new->store_column($_, shift @$row) for @$cols; - $new->in_database(1); + $new->in_storage(1); return $new; } @@ -414,7 +414,7 @@ Updates the object if it's already in the db, else inserts it sub insert_or_update { my $self = shift; - return ($self->in_database ? $self->update : $self->insert); + return ($self->in_storage ? $self->update : $self->insert); } =item is_changed diff --git a/t/01core.t b/t/01core.t index 3e95f08..fbc1851 100644 --- a/t/01core.t +++ b/t/01core.t @@ -34,7 +34,7 @@ $art->delete; cmp_ok(@art, '==', 2, 'And then there were two'); -ok(!$art->in_database, "It knows it's dead"); +ok(!$art->in_storage, "It knows it's dead"); eval { $art->delete; }; @@ -44,7 +44,7 @@ is($art->name, 'We Are In Rehab', 'But the object is still live'); $art->insert; -ok($art->in_database, "Re-created"); +ok($art->in_storage, "Re-created"); @art = DBICTest::Artist->search({ }); @@ -84,7 +84,7 @@ $new = DBICTest::Track->new( { title => 'Insert or Update', } ); $new->insert_or_update; -ok($new->in_database, 'insert_or_update insert ok'); +ok($new->in_storage, 'insert_or_update insert ok'); # test in update mode $new->position(5);