To me "refers App::Model::Foo by 'bar'" seems like a good place for syntactic sugar if nothing else. Treat that the same as "refers App::Model::FooCollection by 'bar'" but then make the accessor perform the extra "dereference" required so that the syntax for accessing your record is just:
<br><br>my $linked_foo = $bar-&gt;foo;<br><br>rather than:<br><br>my $linked_foo = $bar-&gt;foo-&gt;first;<br><br><br><div><span class="gmail_quote">On 7/16/07, <b class="gmail_sendername">Nelson Elhage</b> &lt;<a href="mailto:nelhage@bestpractical.com">
nelhage@bestpractical.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Sat, Jul 14, 2007 at 10:19:00AM -0500, Andrew Sterling Hanenkamp wrote:
<br>&gt; I just found out that my intuition on how &quot;by&quot; works on columns is not<br>&gt; correct .However, after looking through the code, it seems that it<br>&gt; would be a decent idea to make the code work the way I expected. What
<br>&gt; I expect to work is this:<br>&gt;<br>&gt; package App::Model::Foo;<br>&gt; use Jifty::DBI::Schema;<br>&gt; use App::Record schema {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;column name =&gt; type is &#39;text&#39;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;column bar =&gt; refers_to App::Model::Bar;
<br>&gt; };<br>&gt;<br>&gt; package App::Model::Bar;<br>&gt; use Jifty::DBI::Schema;<br>&gt; use App::Record schema {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;column name =&gt; type is &#39;text&#39;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;column foo =&gt; refers_to App::Model::Foo by &#39;bar&#39;;
<br>&gt; };<br><br>In order to get the behavior you want, replace<br><br>refers_to App::Model::Foo by &#39;bar&#39;;<br><br>with<br><br>refers_to App::Model::FooCollection by &#39;bar&#39;;<br><br>I&#39;m not sure if we want your version to work; I think I would rather see
<br>it die or at least warn that you&#39;re using `by&#39; in an invalid place,<br>since to me referring to a model and referring to a collection are<br>very distinct and it makes sense to make them clearly different.<br>
<br><br>- Nelson<br>_______________________________________________<br>jifty-devel mailing list<br><a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br></blockquote></div><br>