Consider the following script: #!/usr/bin/perl use strict; use warnings;
# mysql> # create database foo; # create table foo.tblfoo ( # fooid integer not null auto_increment, # mydate datetime, # primary key (fooid) # ); # grant all privileges on foo.* to foou...@localhost # identified by 'foopassword'; use DateTime; { package My::Plugin::RowStuff; sub insert { my $self = shift; warn "I'm going to do something before inserting"; $self->next::method(@_); } sub delete { my $self = shift; warn "I'm going to do something before deleting"; $self->next::method(@_); } 1; package My::SchemaBase; use base 'DBIx::Class'; __PACKAGE__->load_components(qw/ InflateColumn::DateTime +My::Plugin::RowStuff Core /); 1; package My::Schema::Foo; use base 'My::SchemaBase'; __PACKAGE__->table('tblfoo'); __PACKAGE__->add_columns( fooid => {}, mydate => { data_type => 'datetime' }, ); __PACKAGE__->set_primary_key('fooid'); 1; package My::Schema; use base 'DBIx::Class::Schema'; My::Schema->load_classes(qw/Foo/); 1; } my $schema = My::Schema->connect( 'DBI:mysql:database=foo', 'foouser', 'foopassword' ); my $obj = $schema->resultset('Foo')->create({ mydate => DateTime->now(), }); $obj->delete(); exit 0; 1; When I run this, my custom insert and delete methods in My::Plugin::RowStuff do not get run. I can't figure out why not, but I have identified the following: 1) removing InflateColumn::DateTime will make it work 2) removing the inheritance of My::SchemaBase will work - i.e. have My::Schema::Foo inherit directly from DBIx::Class and call load_components(...) in that package. 3) adding skeleton insert and delete methods to My::SchemaBase will work, so that it now looks like: package My::SchemaBase; use base 'DBIx::Class'; __PACKAGE__->load_components(qw/ InflateColumn::DateTime +My::Plugin::RowStuff Core /); sub insert { shift->next::method(@_) } sub delete { shift->next::method(@_) } 1; As #1 and #2 aren't viable for my codebase, I'm going with the odd #3 solution. Does anyone know why InflateColumn::DateTime is exhibiting this behavior? Much obliged, Steve _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk