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->foo;<br><br>rather than:<br><br>my $linked_foo = $bar->foo->first;<br><br><br><div><span class="gmail_quote">On 7/16/07, <b class="gmail_sendername">Nelson Elhage</b> <<a href="mailto:nelhage@bestpractical.com">
nelhage@bestpractical.com</a>> 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>> I just found out that my intuition on how "by" works on columns is not<br>> correct .However, after looking through the code, it seems that it<br>> would be a decent idea to make the code work the way I expected. What
<br>> I expect to work is this:<br>><br>> package App::Model::Foo;<br>> use Jifty::DBI::Schema;<br>> use App::Record schema {<br>> column name => type is 'text';<br>> column bar => refers_to App::Model::Bar;
<br>> };<br>><br>> package App::Model::Bar;<br>> use Jifty::DBI::Schema;<br>> use App::Record schema {<br>> column name => type is 'text';<br>> column foo => refers_to App::Model::Foo by 'bar';
<br>> };<br><br>In order to get the behavior you want, replace<br><br>refers_to App::Model::Foo by 'bar';<br><br>with<br><br>refers_to App::Model::FooCollection by 'bar';<br><br>I'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're using `by' 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>