[Catalyst] MySchema vs c->model(MySchemaModel)

John Lifsey - Contractor - 5595 john.lifsey at nrl.navy.mil
Fri Dec 3 21:15:00 GMT 2010

I'm running into an unexpected problem when using 
Catalyst::Model::DBIC::Schema. I tried the #dbix-class on IRC but 
thought this might be more related to Catalyst....

In MySchema::Result::Foo (built from default schema loader generated 
syntax using Moose/MooseX::nonmoose)

around 'BUILDARGS' => sub {
   my $orig = shift;
   my $class = shift;
   delete $_[0]->{not_a_real_column};
   return $class->$orig(@_);

This works as expected when using the schema directly.

   use MySchema;
   my $s = MySchema->connect('blah');
   $s->resultset('Foo')->new({ real_column=>'value', 
not_a_real_column=>'some other thing' }); #win

not_a_real_column is removed before a new row is instantiated

However, when using the same schema via C::M::DBIC::Schema the order is 
The following fails when trying to create a new Foo row object because 
not_a_real_column is invalid.
In other words it does not run thru BUILDARGS first.

real_column=>'value', not_a_real_column=>'some other thing' }); #fail

I'm happy to acknowledge I'm DoingItWrong if that's the case, but the 
behavior struck me as odd considering it does work in the former example.

Anyone care to help me grok this?

PS: Interestingly enough, if I wrap around new (I know, that's sick 
wrong bad Mooseyness, but I did it to test) both test cases pass and 
everything works

More information about the Catalyst mailing list