return undef;
}
+=item get_columns
+
+ my %data = $obj->get_columns;
+
+Fetch all column values at once.
+
+=cut
+
+sub get_columns {
+ my $self = shift;
+ return map { $_ => $self->get_column($_) } $self->columns;
+}
+
=item set_column
$obj->set_column($col => $val);
return $ret;
}
+=item set_columns
+
+ my $copy = $orig->copy({ $col => $val, ... });
+
+Set more than one column value at once.
+
+=cut
+
+sub set_columns {
+ my ($self,$data) = @_;
+ while (my ($col,$val) = each %$data) {
+ $self->set_column($col,$val);
+ }
+}
+
+=item copy
+
+ my $copy = $orig->copy({ change => $to, ... });
+
+Insert a new row with the specified changes.
+
+=cut
+
=item store_column
$obj->store_column($col => $val);
return $new;
}
-=item copy
-
- my $copy = $orig->copy({ change => $to, ... });
-
-=cut
-
sub copy {
my ($self, $changes) = @_;
my $new = bless({ _column_data => { %{$self->{_column_data}}} }, ref $self);
sub run_tests {
-plan tests => 23;
+plan tests => 27;
my @art = DBICTest::Artist->search({ }, { order_by => 'name DESC'});
is(DBICTest::Artist->count, 4, 'count ok');
+my $cd = DBICTest::CD->find(1);
+my %cols = $cd->get_columns;
+
+cmp_ok(keys %cols, '==', 4, 'get_columns number of columns ok');
+
+is($cols{title}, 'Spoonful of bees', 'get_columns values ok');
+
+%cols = ( title => 'Forkful of bees', year => 2005);
+$cd->set_columns(\%cols);
+
+is($cd->title, 'Forkful of bees', 'set_columns ok');
+
+is($cd->year, 2005, 'set_columns ok');
+
+$cd->discard_changes;
+
# insert_or_update
$new = DBICTest::Track->new( {
trackid => 100,