Reputation: 152
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 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();
Upvotes: 2
Views: 447
Reputation: 109
Have you tried update_or_create
instead of create
? If a row exists create
will fail.
Upvotes: 1