Subject: | Auditing failure on update |
Date: | Wed, 31 Mar 2010 15:24:57 -0500 |
To: | bug-DBIx-Class-Journal [...] rt.cpan.org |
From: | Andy Clayton <clayton [...] physics.umn.edu> |
Hello,
While testing out the latest development version, 0.900001_03, I ran
into a problem with auditing on updating. It seems that it inserts the
object rather than the id:
INSERT INTO "artist_audit_history" VALUES(3,
'Music::Schema::Journal::ChangeLog=HASH(0x8d14bf4)', 1, 'Cloud Cult');
This is also observable in the database generated by the first test:
INSERT INTO "cd_audit_history" VALUES(2,
'DBICTest::Schema::_JOURNAL::ChangeLog=HASH(0x8fca278)', 1, 1, 'Angry
young man', '2000');
This is somewhat puzzling as I would think that passing the ChangeLog
row to create should work, though maybe the problem is that the relation
is the same name as the column? Regardless, changing it to explicitly
use the id--just as create does--fixes the problem. I've attached a
patch, and I should hopefully have time tomorrow or the next to write
one for the tests as well.
Thanks,
-Andy
Index: Journal.pm
===================================================================
--- Journal.pm (revision 1401)
+++ Journal.pm (revision 1423)
@@ -69,9 +69,9 @@
if($self->in_storage) {
my $j = $self->_journal_schema;
- my $change = $j->journal_create_change;
+ my $change_id = $j->journal_create_change()->id;
my $prev = $self->result_source->resultset->find( $self->ident_condition );
- $j->journal_record_in_history( $prev, audit_change_id => $change );
+ $j->journal_record_in_history( $prev, audit_change_id => $change_id );
}
}