[Catalyst] Pulling My Hair Out with DBIx::Schema For Authentication and Authorization

hkclark at gmail.com hkclark at gmail.com
Wed Mar 22 01:49:12 CET 2006


On 3/21/06, Brandon Black <blblack at gmail.com> wrote:
> I haven't even gotten around to using the DBIC::Schema auth/session
> stuff myself yet, so I could be totally off base here, but my first
> guess would be that you're missing the corresponding ->belongs_to's
> that go with your ->has_many's.
>
> If:
>
> Role->has_many(map_user_role => 'MyApp::Db::Schema::UserRole' => 'role');
> User->has_many(map_user_role => 'MyApp::Db::Schema::UserRole' => 'user');
>
> I would expect yuo to also have:
>
> UserRole->belongs_to(user => 'MyApp::Db::Schema::User');
> UserRole->belongs_to(role => 'MyApp::Db::Schema::Role');
>
> -- Brandon
>

Hi Brandon,

Many thanks for the note.  I added these two lines to
lib/MyApp/Db/Schema/UserRole.pm:
  __PACKAGE__->belongs_to(user => 'MyApp::Db::Schema::User');
  __PACKAGE__->belongs_to(role => 'MyApp::Db::Schema::Role');

But I still got the same same error:
SELECT me.user, me.role FROM user_role me WHERE ( username = ? ): test01
DBD::SQLite::db prepare_cached failed: no such table: user_role(1) at
dbdimp.c line 269 at
/usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Storage/DBI.pm line 448.

Note the the "no such table: user_role", but 'user_role does exist:
  $ sqlite3 myapp.db
  SQLite version 3.2.2
  Enter ".help" for instructions
  sqlite> select * from user_role;
  1|1
  1|2
  2|2
  sqlite>

Regards,
H



More information about the Catalyst mailing list