Gaetan de Menten wrote:

> What I had envisioned is kind of a mix of both: to be able to reuse an
> explicit relation, like you do in the has_association case, but also
> have a "shortcut" syntax for when you don't want to/don't care about
> the relation to the intermediary table, something like:
>
>     has_association('twos', of_kind='ThingTwo', secondary='Cat')
>
> this would automatically create a relation to Cat behind the scene.

For some reason, I am not sure that I like this.  Just reading the
syntax doesn't immediately make it clear what is going on.  I think I
prefer your second suggestion, since its a bit more explicit, and easier
to understand...

> I'm also wondering if it wouldn't make more sense to reuse
> the has_and_belongs_to_many statement instead of making a new
> has_association statement. The reasoning is that one ThingOne object
> can be related to many ThingTwo and vice versa, and this kind of
> relationship is described by an has_and_belongs_to_many relationship,
> so I think it's more consistent to use that term.
>
>     has_many('cats', of_kind='Cat')
>     has_and_belongs_to_many('twos', of_kind='ThingTwo',
> through='cats', via='two')
>
> in that case, the of_kind would be optional though (but if it's
> present we could check that we are indeed pointing to what we want),
> so we could see some relationships defined like this:
>
>     has_many('cats', of_kind='Cat')
>     has_and_belongs_to_many('twos', through='cats', via='two')

Yes, I think this works nicely, on all counts.  I am a solid
-1 on the `has_association` syntax and a solid +1 on through
`has_and_belongs_to_many` extension.

--
Jonathan LaCour
http://cleverdevil.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to