[Dbix-class] How to find updated fields

RA Jones ra.jones at dpw.clara.co.uk
Sat Mar 24 22:43:56 GMT 2007


Guillermo Roditi wrote:
> if it's insert then they are all dirty, thats why. try in_storage 
> instead. think it out first
Sorry my mistake there, it should have read 'overloaded update() method' 
rather than 'overloaded insert() method'. But the get_dirty_columns 
function in the example I gave still should have worked, but didn't. Why?

> On 3/24/07, RA Jones <ra.jones at dpw.clara.co.uk> wrote:
>> So I created a very simple overloaded insert() method as described
>> in DBIx::Class::Manual::Component, in a new module called
>> DBIx::Class::CRUD
>> 
>> package DBIx::Class::CRUD; use base qw/DBIx::Class/;
>> 
>> sub update { my $self = shift;
>> 
>> my %dirty_cols = $self->get_dirty_columns; use Data::Dumper; # open
>> $fh here print $fh Dumper %dirty_cols; return $self->next::method(
>> @_ ); }
>> 
>> And in MyApp::Schema::MyClass: 
>> __PACKAGE__->load_components(qw/PK::Auto CRUD Core/);
>> 
>> But %dirty_cols is empty. The DBIC::CRUD::insert method *is* being 
>> called as a) I can dump $self to output, where there is no entry
>> for anything resembling get_dirty_columns, and b) entry confirmed
>> with $c->log->info( join "\n" =>
>> Class::C3::calculateMRO('Schema::MyClass') ):
>> 
>> Schema::Location, DBIx::Class::CRUD, DBIx::Class::Core, <a few
>> more>, DBIx::Class::PK::Auto, etc.
>> 
>> I'm obviously *still* doing something wrong :-(
-- 
Richard Jones
Leeds, UK
mailto:ra.jones at dpw.clara.co.uk




More information about the Dbix-class mailing list