Hi,

On Sep 30, 2008, at 1:25 PM, Matt S Trout wrote:
On Mon, Sep 29, 2008 at 05:39:25PM +0100, Pedro Melo wrote:
On Sep 29, 2008, at 4:50 PM, Matt S Trout wrote:

On Sun, Sep 28, 2008 at 05:56:11PM +0100, Oliver Gorwits wrote:
Ideally, DBIC would instead populate the relationship_info details
after someone has set up __PACKAGE__->many_to_many(...). That would
avoid this guesswork.

That would make no sense at all since many-to-many is NOT A
RELATIONSHIP.

I've been in this list for some years now that I've seen this phrase
written several times.

<pedantic>
If I recall correctly my time at CS department where I was forced to
read the relational model (not the -for-dummies version that is SQL
today. but the true horrid version), many-to-many was in fact a
relationship.

In DBIx::Class terms, that's not how we model it.

I know and understand that, but from the outside, can you understand that given that many_to_many is discussed in DBIx::Class::Relationships its only natural to people arriving at DBIx::Class to assume that many_to_many is a relation type like any other.

I'm not saying that they are right, I'm just saying that its one of the things that I teach to people who ask me about it: even with many_to_many defined in ::Relationship, its actually not. Just a bit of sugar.


Having said that, it is trivial to use your own base class for your
sources in a way that you can catch many-to-many declarations and
cache the result somewhere private (your own version of
relationship_info()).

Please if you do that call it something -other- than relationship_info.

I say that this is possible because I have code running in production
that does exactly that: creates a parallel relationship_info()

Much DBIC code and extension stuff assumes that anything in there is
a relationship in the DBIC sense.

if you start putting many-to-many stuff in there, your code is broken. It
just might not have caused you any bugs yet.

I did not start to put many_to_many in relationship_info(), I used a different name for my relationship introspection code. relationship_info() is critical for *_related() to work, and I didn't want to mess that up.

In case my point was not clear enough, I agree that relationship_info() should only return relations that can be used in *_related() methods.

But if we have a documented way (cf. ::Relationships) to declare all this types, I think it makes sense to have a method (a different one most likely) to return the information about all the relationships you declared, including many_to_many. This makes it easier to do a lot of things (like the current recursive insert/update stuff, or a documentation generation tool).

Best regards,
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: [EMAIL PROTECTED]
Use XMPP!



_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to