[Dbix-class] Emulating CDBI "temp" columns

Brandon Black blblack at gmail.com
Fri Jul 21 17:40:06 CEST 2006


On 7/21/06, Drew Taylor <taylor.andrew.j at gmail.com> wrote:
> 2) I'm using DBIC w/ Catalyst, and thus am using C::P::DBIC::Schema
> (latest version - no Loader). I'd like to have a base class common for
> all my table objects (ie. a common toJSON() method), but can't figure
> out how to do it in conjunction w/ the C::P::DBIC::Schema plugin.
>
> At first I just tried having My::Schema::User inherit directly from
> My::Schema::BaseClass, but that makes DBIC barf on Catalyst startup.

It shouldn't - I'm using just such a setup myself.  All of my source
classes inherit from various other base classes.  Just to be sure
we've got this straight:

Check that...

My::Schema ISA DBIx::Class::Schema
My::Schema::User ISA My::Schema::BaseClass
My::Schema::BaseClass ISA DBIx::Class
My::Schema->resultset('User') ISA DBIx::Class::ResultSet
My::Schema->resultset('User')->find('joebob') ISA My::Schema::User
My::Schema->resultset('User')->find('joebob')->toJSON works?

Then...

My::Model->config->{schema_class} IS My::Schema
$c-model('My::Model::User')->find('joebob')->toJSON works?

-- Brandon



More information about the Dbix-class mailing list