[Bast-commits] r4505 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t
gphat at dev.catalyst.perl.org
gphat at dev.catalyst.perl.org
Thu Jun 19 14:06:57 BST 2008
Author: gphat
Date: 2008-06-19 14:06:57 +0100 (Thu, 19 Jun 2008)
New Revision: 4505
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/trunk/t/60core.t
Log:
Add make_column_dirty to Row (per request from #dbix-class questions)
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2008-06-19 12:44:22 UTC (rev 4504)
+++ DBIx-Class/0.08/trunk/Changes 2008-06-19 13:06:57 UTC (rev 4505)
@@ -1,5 +1,6 @@
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
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2008-06-19 12:44:22 UTC (rev 4504)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2008-06-19 13:06:57 UTC (rev 4505)
@@ -451,6 +451,20 @@
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;
Modified: DBIx-Class/0.08/trunk/t/60core.t
===================================================================
--- DBIx-Class/0.08/trunk/t/60core.t 2008-06-19 12:44:22 UTC (rev 4504)
+++ DBIx-Class/0.08/trunk/t/60core.t 2008-06-19 13:06:57 UTC (rev 4505)
@@ -7,7 +7,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 78;
+plan tests => 84;
eval { require DateTime::Format::MySQL };
my $NO_DTFM = $@ ? 1 : 0;
@@ -37,10 +37,26 @@
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");
More information about the Bast-commits
mailing list