On Wed, May 18, 2011 at 2:11 AM, Alexander Hartmaier < [email protected]> wrote:
> Why not create another result class for the different table? > The overlapping methods can be put in a base class or a role used by both. > That's exactly what I'm doing. I've got two schemas and associated Result and ResultSet classes that use Roles to bring in common functionality. The problem is this: my %new_user = ( first => 'jane', last => 'Doe', email => ' [email protected]' ); my $schema = $user_other_schema ? $alt_schema : $original_schema; my $user = $schema->resultset( 'User' )->create( \%new_user ); Now, if $alt_schema's User class doesn't define an "email", because the underling table doesn't have that column, then things blow up. So, I'm wondering how to have a "virtual" email column in that class -- or some way to make DBIC happy that "email" is not a defined column. Or perhaps override create (or lower-level insert or update) and remove that column from the passed in data. What would be better is to have a layer between the app and the DBIC schema (i.e. $model->create_user( \%new_user ) ) where I could handle this easier, but this is an existing app and the app currently uses DBIC pretty extensively and assumes it has a $schema object to work with. Handling $user->email is easy, because I can just add that method. I suppose I can override $user->get_column( 'email' ) to filter those out. -- Bill Moseley [email protected]
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
