开发者

DBIx::Class undefined value exception when trying to use ->create()

I'm trying to create a new row using DBIx::Class from within Catalyst, with the following code:

$c->model('Session')->resultset('UserPreference')->create(
                {
                 appname => 'rss_reader',
                 username => $username,
                 data => $data,
                },
               );

But, I hit this error every time:

Caught exception in App::Controller::rss->dbo "Can't call method "resolve" on an undefined value at /etg/source/Linux/pkg/perl-5.8.8/lib/site_perl/5.8.8/DBIx/Class/Row.pm line 1309."

I see a few mailing lists talking about this error being thrown as an incorrect blanket error when the query fails for whatever reason (perms, constraints,etc.), but it looks just fine AND even running with DBIC_TRACE=1, I don't even see the generated query in my console.

I should mention I don't think there's something bad with 开发者_StackOverflow社区the permissions,etc. since using the database handle manually works:

my $stm=$c->model("Session")->storage->dbh->prepare("insert into user_preferences (username,appname,data) values ('mphillip','rss_reader','cookies')"); $stm->execute(); 


Have you tried update_or_create instead of create? If a row exists create will fail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜