[jifty-devel] Regarding refers_to and by on JDBI columns

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Mon Jul 16 14:46:23 EDT 2007


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:

my $linked_foo = $bar->foo;

rather than:

my $linked_foo = $bar->foo->first;


On 7/16/07, Nelson Elhage <nelhage at bestpractical.com> wrote:
>
> On Sat, Jul 14, 2007 at 10:19:00AM -0500, Andrew Sterling Hanenkamp wrote:
> > I just found out that my intuition on how "by" works on columns is not
> > correct .However, after looking through the code, it seems that it
> > would be a decent idea to make the code work the way I expected. What
> > I expect to work is this:
> >
> > package App::Model::Foo;
> > use Jifty::DBI::Schema;
> > use App::Record schema {
> >    column name => type is 'text';
> >    column bar => refers_to App::Model::Bar;
> > };
> >
> > package App::Model::Bar;
> > use Jifty::DBI::Schema;
> > use App::Record schema {
> >    column name => type is 'text';
> >    column foo => refers_to App::Model::Foo by 'bar';
> > };
>
> In order to get the behavior you want, replace
>
> refers_to App::Model::Foo by 'bar';
>
> with
>
> refers_to App::Model::FooCollection by 'bar';
>
> I'm not sure if we want your version to work; I think I would rather see
> it die or at least warn that you're using `by' in an invalid place,
> since to me referring to a model and referring to a collection are
> very distinct and it makes sense to make them clearly different.
>
>
> - Nelson
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070716/78842b83/attachment.htm


More information about the jifty-devel mailing list