[Dbix-class] using load_classes selectively

Matt S Trout dbix-class at trout.me.uk
Fri Feb 8 13:43:54 GMT 2008


On Fri, Feb 08, 2008 at 09:52:28AM +0000, Frazer Irving wrote:
> >
> >
> > On Feb 8, 2008 7:59 AM, Matt S Trout <dbix-class at trout.me.uk> wrote:
> >
> > >
> > > What business requirement is leading you to want on-demand loading?
> > >
> >
> Oops sorry about that last reply.
> 
> Basically I work on a poorly structured application, the in-house method of
> determining the columns for a table is to query the INFORMATION_SCHEMA of
> the mysql database at runtime, or to embed column names in SQL statements
> (eww). I have opted to place the results of INFORMATION_SCHEMA queries in
> __PACKAGE__->add_columns but this is going to result in a lot of unnecessary
> DB calls. I think I will write some additional code to pre-cache the column
> names somewhere.

Why don't you just use DBIx::Class::Schema::Loader ?

That can dump column and rel info to disk, or grab it at startup, and supports
only doing so for some tables.

> In the interim, can you tell me if my approach of placing calls to
> DB::Main->load_classes inside the body of DB::Main::Foo a sane approach? I
> happened upon it through experimentation.

Sane? ... well, I don't think anything that requires that approach is sane.
But once you -do- require something like that, it's probably not so horrific
a way of making it work :)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list