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

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Wed Jul 18 21:20:23 EDT 2007


On 7/18/07, Jesse Vincent <jesse at bestpractical.com> wrote:
>
>
> Hm. (FWIW, "references" is the new way to spell "refers_to")
>

Good to know. I hadn't caught that. Of course, I've been stuck in Drupal
hell for the past two months.

What about
>
> column foo => references Jifty::Model::Foo,
>    backreference is 'bar';
>
> ?
>
>

Sounds fine to me. I'm not too picky as long as it's possible.

Yet, I'm still picky. It still seems backwards (no pun intended) to make
what is, effectively, a subroutine declaration in an outside class. If
"references" is the new "refers_to", how about having this alternative:

column bar => backreference to Jifty::Model::Bar by 'foo';

I think backreference has potential for stating this as well:

column bars => backreference to Jifty::Model::BarCollection by 'foo';

Since that's really what a Collection reference is. And we can take it
further:

column bars => backreference to Jifty::Model::BarCollection via
Jifty::Model::FooBar by 'foo';

which could be a superb way of automatically handling simple many-to-many
references with a link table.
 (I.e., "simple" implying that you don't have any extra columns recorded in
the link table that you care about.)

With this syntax, I don't see any problem with making backreference an alias
for reference either since there's no conflict, but if we do, we can
deprecate the old use of reference for Collections (or not) and remove it
someday. The "backreference" is just syntactic sugar that *implies* "is
virtual" (but doesn't explicitly need to mean anything different from
"reference").

Anyway, that's my opinion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070718/41d4cb0b/attachment.htm


More information about the jifty-devel mailing list