<br><div class="gmail_quote">On Wed, May 18, 2011 at 2:11 AM, Alexander Hartmaier <span dir="ltr"><<a href="mailto:alexander.hartmaier@t-systems.at">alexander.hartmaier@t-systems.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
Why not create another result class for the different table?<br>
The overlapping methods can be put in a base class or a role used by both.<br></div></blockquote><div><br></div><div>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.</div>
<div><br></div><div>The problem is this:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div class="gmail_quote"><div>my %new_user = ( first => 'jane', last => 'Doe', email => '<a href="mailto:jane_doe@example.com">jane_doe@example.com</a>' );</div>
</div><div class="gmail_quote"><div><br></div></div><div class="gmail_quote"><div>my $schema = $user_other_schema ? $alt_schema : $original_schema;</div></div><div class="gmail_quote"><div><br></div></div><div class="gmail_quote">
<div>my $user = $schema->resultset( 'User' )->create( \%new_user );</div></div></blockquote><div class="gmail_quote"><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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.</div><div><br></div><div> </div></div>-- <br>
Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a><br>