[Dbix-class] Problems with custom resultset_class

Nathan Kurz nate at verse.com
Sat Aug 12 01:46:16 CEST 2006


I've just managed to track down an obcure problem I've been having
with my custom ResultSet classes.  What seemed to be happening was
that only part of the class was being read: some functions would work,
but others would act like they weren't there.  The problem turned out
to be that if there was a syntax error in the file, and if
DBIx::Class::AccessorGroup::set_component_class() was run before
Catalyst::Utils::ensure_class_loaded(), things would silently fail in
a way that left the file partially loaded.

Is there a reason that set_component_class() silently allows syntax
errors on the require?  It's mentioned in the comment, so I assume it
is intentional, but it has the bad side effect of having the file be
included in %INC, which means that any further attempts to require the
file will silently succeed as well!  At the least, could it try to
tell the difference between a syntax error and a non-existent file?

If anyone else has had similar problems, the easiest work-around is to
always 'use' the resultset_class before calling the accessor:

  package App::Model::Schema::User;
  use base qw/DBIx::Class/;
  use App::Model::RS::User;
  ...
  __PACKAGE__->resultset_class('App::Model::RS::User');

Thanks!

Nathan Kurz
nate at verse.com

ps. I saw a BUG comment in DBIx::Class::Componentized about files with
syntax errors being set in %INC, and I wonder if this is related.



More information about the Dbix-class mailing list