From: Peter Rabbitson Date: Mon, 22 Jul 2013 05:08:18 +0000 (+0200) Subject: Augment 84d8c2ad so that the custom join specification isn't so prominent X-Git-Tag: v0.08260~194 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5d2588ccdd92a01535fefd77c45240f75e8ec090;p=dbsrgits%2FDBIx-Class.git Augment 84d8c2ad so that the custom join specification isn't so prominent Also add a warning to (hopefully) deter folks from using these for simple shit, where a schema redesign would suffice. --- diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 71bfcaf..b4dc4d2 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -54,9 +54,16 @@ source, indicated by its class name. The condition argument describes the C clause of the C expression used to connect the two sources when creating SQL queries. -To create simple equality joins, supply a hashref containing the -remote table column name as the key(s), and the local table column -name as the value(s), for example given: +=head4 Simple equality + +To create simple equality joins, supply a hashref containing the remote +table column name as the key(s) prefixed by C<'foreign.'>, and the +corresponding local table column name as the value(s) prefixed by C<'self.'>. +Both C and C are pseudo aliases and must be entered +literally. They will be replaced with the actual correct table alias +when the SQL is produced. + +For example given: My::Schema::Author->has_many( books => 'My::Schema::Book', @@ -75,10 +82,6 @@ This describes a relationship between the C table and the C table where the C table has a column C containing the ID value of the C. -C and C are pseudo aliases and must be entered -literally. They will be replaced with the actual correct table alias -when the SQL is produced. - Similarly: My::Schema::Book->has_many( @@ -103,9 +106,11 @@ will result in the C clause: This describes the relationship from C to C, where the C table refers to a publisher and a type (e.g. "paperback"): +=head4 Multiple groups of simple equality conditions + As is the default in L, the key-value pairs will be -Ced in the result. C can be achieved with an arrayref, for -example a condition like: +Ced in the resulting C clause. An C can be achieved with +an arrayref. For example a condition like: My::Schema::Item->has_many( related_item_links => My::Schema::Item::Links, @@ -127,6 +132,12 @@ themselves in a peer fashion (without a "parent-child" designation) =head4 Custom join conditions + NOTE: The custom join condition specification mechanism is capable of + generating JOIN clauses of virtually unlimited complexity. This may limit + your ability to traverse some of the more involved relationship chains the + way you expect, *and* may bring your RDBMS to its knees. Exercise care + when declaring relationships as described here. + To specify joins which describe more than a simple equality of column values, the custom join condition coderef syntax can be used. For example: