[Catalyst] how to reuse Catalyst Schema for non-web purposes?
Matt S Trout
dbix-class at trout.me.uk
Thu Apr 23 17:51:53 GMT 2009
On Thu, Apr 23, 2009 at 08:12:23AM +1000, kakimoto at tpg.com.au wrote:
> -------------------- Execution of test - start ------------------------
> kakimoto at dev-machine:~/projects/myApp/t$ prove -v userSubscriptions.t
> userSubscriptions.t ..
> ok 1 - use myApp::Schema::UserSubscriptions;
> ok 2 - The object isa myApp::Schema::UserSubscriptions
> ok 3 - myApp::Schema::UserSubscriptions->can('subscriptions_id')
> ok 4 - myApp::Schema::UserSubscriptions->can('name')
> ok 5 - myApp::Schema::UserSubscriptions->can('user_id')
> ok 6 - myApp::Schema::UserSubscriptions->can('comments')
> ok 7 - myApp::Schema::UserSubscriptions->can('rea_agent_code')
> 1..7
> Can't call method "resolve" on an undefined value at
> /usr/local/lib/perl5/site_perl/5.8.9/DBIx/Class/Row.pm line 720.
> # Looks like your test exited with 255 just after 7.
> Dubious, test returned 255 (wstat 65280, 0xff00)
> All 7 subtests passed
>
> foreach my $new_subscription ( @user_subscriptions )
> {
> my $new_user_sub = $package_name->new();
> isa_ok ( $new_user_sub, $package_name );
>
> foreach my $attr ( keys %{$new_subscription} )
> {
> can_ok ($new_user_sub, $attr);
> $new_user_sub->$attr($new_subscription);
> }
> $new_user_sub->insert();
> }
Right, so, you've created a row object directly with new(), never
associated it with a live, connected $schema, and then you're trying
to ->insert. The error message could be better, but of -course- that
doesn't work. You wanted to create a $schema and do -
$schema->resultset('User')->new({});
I suspect. Please don't just guess how to use DBIx::Class outside of
Catalyst, read the DBIx::Class manual - and please ask further DBIx::Class
specific questions on the relevant list; this isn't really anything to
do with Catalyst ...
--
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 Catalyst
mailing list