<br><div class="gmail_quote">On Wed, May 18, 2011 at 2:11 AM, Alexander Hartmaier <span dir="ltr">&lt;<a href="mailto:alexander.hartmaier@t-systems.at">alexander.hartmaier@t-systems.at</a>&gt;</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&#39;s exactly what I&#39;m doing.  I&#39;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 =&gt; &#39;jane&#39;, last =&gt; &#39;Doe&#39;, email =&gt; &#39;<a href="mailto:jane_doe@example.com">jane_doe@example.com</a>&#39; );</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-&gt;resultset( &#39;User&#39; )-&gt;create( \%new_user );</div></div></blockquote><div class="gmail_quote"><div><br></div><div>Now, if $alt_schema&#39;s User class doesn&#39;t define an &quot;email&quot;, because the underling table doesn&#39;t have that column, then things blow up.</div>

<div><br></div><div>So, I&#39;m wondering how to have a &quot;virtual&quot; email column in that class -- or some way to make DBIC happy that &quot;email&quot; 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-&gt;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-&gt;email is easy, because I can just add that method.  I suppose I can override $user-&gt;get_column( &#39;email&#39; ) 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>