Revision history for DBIx::Class
+ - add a make_column_dirty method to Row to force updates
- throw a clear exception when user tries multi-has_many prefetch
- SQLT parser prefixes index names with ${table}_idx_ to avoid clashes
- mark ResultSetManager as deprecated and undocument it
keys %{$self->{_dirty_columns}};
}
+=head2 make_column_dirty
+
+Marks a column dirty regardless if it has really changed. Throws an
+exception if the column does not exist.
+
+=cut
+sub make_column_dirty {
+ my ($self, $column) = @_;
+
+ $self->throw_exception( "No such column '${column}'" )
+ unless exists $self->{_column_data}{$column} || $self->has_column($column);
+ $self->{_dirty_columns}{$column} = 1;
+}
+
=head2 get_inflated_columns
my %inflated_data = $obj->get_inflated_columns;
my $schema = DBICTest->init_schema();
-plan tests => 78;
+plan tests => 84;
eval { require DateTime::Format::MySQL };
my $NO_DTFM = $@ ? 1 : 0;
is($art->name, 'We Are In Rehab', "Accessor update ok");
+my %dirty = $art->get_dirty_columns();
+cmp_ok(scalar(keys(%dirty)), '==', 1, '1 dirty column');
+ok(grep($_ eq 'name', keys(%dirty)), 'name is dirty');
+
is($art->get_column("name"), 'We Are In Rehab', 'And via get_column');
ok($art->update, 'Update run');
+my %not_dirty = $art->get_dirty_columns();
+cmp_ok(scalar(keys(%not_dirty)), '==', 0, 'Nothing is dirty');
+
+eval {
+ my $ret = $art->make_column_dirty('name2');
+};
+ok(defined($@), 'Failed to make non-existent column dirty');
+$art->make_column_dirty('name');
+my %fake_dirty = $art->get_dirty_columns();
+cmp_ok(scalar(keys(%fake_dirty)), '==', 1, '1 fake dirty column');
+ok(grep($_ eq 'name', keys(%fake_dirty)), 'name is fake dirty');
+
my $record_jp = $schema->resultset("Artist")->search(undef, { join => 'cds' })->search(undef, { prefetch => 'cds' })->next;
ok($record_jp, "prefetch on same rel okay");