HI: I have three tables described as Catalyst::Plugin::Authorization: Roles, UserRole, Users:
Roles.pm is: __PACKAGE__->add_columns( "id", "role", ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint( "role_2", ["role"] ); __PACKAGE__->has_many( map_user_role => 'K68::Db::K68::UserRole', { 'foreign.role_id' => 'self.id' } ); __PACKAGE__->many_to_many( "users" => "map_user_role", "user" ); UserRole.pm is: __PACKAGE__->add_columns( "user_id", "role_id", ); __PACKAGE__->set_primary_key( "user_id", "role_id" ); __PACKAGE__->belongs_to( "user" => "K68::Db::K68::Users", { 'foreign.id' => 'self.user_id' } ); __PACKAGE__->belongs_to( "role" => "K68::Db::K68::Roles", { 'foreign.id' => 'self.role_id' } ); Now I want to delete one record from UserRole. I know $admin_role is 'fadm1', and user_id is 1. I did: $c->model('K68::Roles')->search({role => $adm_role}) ->search_related('map_user_role',{user_id => $user_id})->delete; But it create a sql : DELETE FROM user_role WHERE ( ( ( user_id = '1' ) AND ( role = 'fadm1' ) ) ) so catalyst report an error : Unknown column 'role' in 'where clause' If I do so: $c->model('K68::Roles')->search({role => $adm_role}) ->search_related('map_user_role',{user_id => $user_id})->first->delete; it works. I want to know: why first way didn't work? thanks -- Thanks & Regards Chylli _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/