[Dbix-class] class mapping

Sung Gong sung at bio.cc
Tue Mar 13 16:33:51 GMT 2012


Hi

I have a simple User table (mysql back-end) which is mapped into a
resultsource class User.pm. statically generated by the helper.

Just wondering any difference between
"MyApp::Schema::DB::Result::User" and "MyApp::Model::DB::User"?

Both ref($c->model("DB::User")->find(1)) and
ref($c->model("NECTAR::User")->new_result({})) return
MyApp::Model::DB::User.
Is this normally what I expect? (or MyApp::Schema::DB::Result::User)

One more question re the method 'new_result' of DBIx::Class::ResultSet:
I found $c->model("DB::User")->new_result({})->result_source->schema->storage
returns undef, whereas
$c->model("DB::User")->find(1)->result_source->schema->storage doesn't
(it shows DBIx::Class::Storage::DBI::mysql=HASH(0x1f21fdc0)).
Is this also sane?

Initially those questions were raised while using HTML::FormHandler -
modifying an existing user (e.g. ->find(1)) works well, whereas
creating a new user (->new_result) triggers some error messages:
can't call method "insert" on an undefined value at
/home/sung/perl5/lib/perl5/DBIx/Class/Row.pm line 351
...
DBIx::Class::Storage::txn_do('undef', 'undef') called at
/home/sung/perl5/lib/perl5/DBIx/Class/Storage/DBI.pm line 807

Anyone can help on this?
https://github.com/sung/Nectar-debug

Cheers,
Sung



More information about the DBIx-Class mailing list