[Catalyst] Problems using DBIx with update_or_create()

Nathan Kurz nate at verse.com
Sat Feb 25 18:16:04 CET 2006


On Fri, Feb 24, 2006 at 07:01:07PM +0000, Matt S Trout wrote:
> On Fri, Feb 24, 2006 at 10:22:11AM -0700, Nathan Kurz wrote:
> > I'm having a small problem using Catalyst and the
> > DBIx method update_or_create().  My code looks like this:
> > 
> >     my $user = Notate::Model::DB::User->update_or_create({
> >        email => $email,
> >        password => md5_hex($password),
> >     });
> > 
> > When I run it, I get an exception that the object method
> > 'update_or_create' could not be found.  When I use 'create()',
> > everything works as expected.  I think this is just a small problem
> > with ResultSetProxy.pm missing some functions.  Or am I doing
> > something fundamentally wrong?
> 
> No, that's almost certainly the case. ResultSetProxy is designed to support
> old usage until people convert over to the Schema approach. If you're still
> using DB.pm you should be able to get at the schema object my calling
> 
> One::Of::My::Classes->schema_instance

Thanks!  So for a new usage, I should be using DBIC::Schema instead of
DBIC?  I hadn't known I was using an outdated approach, and certainly
did not intend to.  I went through the tutorial in the manual
(supplemented with looking at the Parley as an example), and used what
it gave me as a place to start from.  From what I can tell, the
tutorial (otherwise excellent) makes no mention of the new usage.

Do I still want to be using Authentication::Store::DBIC, or is there a
corresponding Authentication::Store::DBIC::Schema that should be used
instead?  Or is DBIC:Schema compatible with DBIC once it's set up?  

And is there a canonical Catalyst DBIC::Schema example I should follow?

Thanks!

Nathan Kurz
nate at verse.com



More information about the Catalyst mailing list