[Bast-commits] r4439 - in DBIx-Class/0.08/branches/replication_dedux: . lib/DBIx lib/DBIx/Class lib/DBIx/Class/Storage t

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Fri May 30 16:59:14 BST 2008


Author: jnapiorkowski
Date: 2008-05-30 16:59:13 +0100 (Fri, 30 May 2008)
New Revision: 4439

Modified:
   DBIx-Class/0.08/branches/replication_dedux/
   DBIx-Class/0.08/branches/replication_dedux/Changes
   DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class.pm
   DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Relationship.pm
   DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/ResultSource.pm
   DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/TxnScopeGuard.pm
   DBIx-Class/0.08/branches/replication_dedux/t/03podcoverage.t
   DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t
   DBIx-Class/0.08/branches/replication_dedux/t/81transactions.t
Log:
 r13492 at dev (orig r4434):  matthewt | 2008-05-30 09:36:16 -0500
 throw exception for multi-has_many prefetch
 r13493 at dev (orig r4435):  ash | 2008-05-30 09:40:31 -0500
 Make irc/mailing list much more prominent in the docs
 r13494 at dev (orig r4436):  ash | 2008-05-30 10:13:36 -0500
 Tidy up TxnScopeGuard and its tests a bit
 r13495 at dev (orig r4437):  ribasushi | 2008-05-30 10:19:58 -0500
 Adjust prefetch tests to not blow up after r4434
 r13496 at dev (orig r4438):  castaway | 2008-05-30 10:58:16 -0500
 Updating to new doc standard.
 Adding more examples of alternate calls.
 
 



Property changes on: DBIx-Class/0.08/branches/replication_dedux
___________________________________________________________________
Name: svk:merge
   - 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:4431
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
   + 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:4438
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510

Modified: DBIx-Class/0.08/branches/replication_dedux/Changes
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/Changes	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/Changes	2008-05-30 15:59:13 UTC (rev 4439)
@@ -1,5 +1,7 @@
 Revision history for DBIx::Class
 
+        - throw a clear exception when user tries multi-has_many prefetch
+        - SQLT parser prefixes index names with ${table}_idx_ to avoid clashes
         - mark ResultSetManager as deprecated and undocument it
         - pod fix (RT #32988)
         - add Test::Exception to test requirements (RT #34256)

Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Relationship.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Relationship.pm	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Relationship.pm	2008-05-30 15:59:13 UTC (rev 4439)
@@ -19,6 +19,7 @@
 
 =head1 SYNOPSIS
 
+  ## Creating relationships
   MyDB::Schema::Actor->has_many('actorroles' => 'MyDB::Schema::ActorRole',
                                 'actor');
   MyDB::Schema::Role->has_many('actorroles' => 'MyDB::Schema::ActorRole',
@@ -29,6 +30,7 @@
   MyDB::Schema::Role->many_to_many('actors' => 'actorroles', 'actor');
   MyDB::Schema::Actor->many_to_many('roles' => 'actorroles', 'role');
 
+  ## Using relationships
   $schema->resultset('Actor')->roles();
   $schema->resultset('Role')->search_related('actors', { Name => 'Fred' });
   $schema->resultset('ActorRole')->add_to_roles({ Name => 'Sherlock Holmes'});
@@ -113,15 +115,16 @@
 
 =over 4
 
-=item Arguments: $accessor_name, $related_class, $fk_column|$cond?, $attr?
+=item Arguments: $accessor_name, $related_class, $fk_column|\%cond|\@cond?, \%attr?
 
 =back
 
-Creates a relationship where the calling class stores the foreign class's
-primary key in one (or more) of its columns. This relationship defaults to
-using C<$accessor_name> as the foreign key in C<$related_class> to resolve the
-join, unless C<$fk_column> specifies the foreign key column in
-this class or C<$cond> specifies a reference to a join condition hash.
+Creates a relationship where the calling class stores the foreign
+class's primary key in one (or more) of its columns. This relationship
+defaults to using C<$accessor_name> as the column in this class
+to resolve the join against the primary key from C<$related_class>,
+unless C<$fk_column> specifies the foreign key column in this class or
+C<cond> specifies a reference to a join condition hash.
 
 =over
 
@@ -157,17 +160,34 @@
 
 
   # in a Book class (where Author has many Books)
-  My::DBIC::Schema::Book->belongs_to( author => 'My::DBIC::Schema::Author' );
+  My::DBIC::Schema::Book->belongs_to( 
+    author => 
+    'My::DBIC::Schema::Author', 
+    'author_id'
+  );
 
-  my $author_obj = $obj->author; # get author object
-  $obj->author( $new_author_obj ); # set author object
+  # OR (same result)
+  My::DBIC::Schema::Book->belongs_to(
+    author =>
+    'My::DBIC::Schema::Author',
+    { 'foreign.author_id' => 'self.author_id' } 
+  );
 
-The above belongs_to relationship could also have been specified as,
+  # OR (similar result but uglier accessor name)
+  My::DBIC::Schema::Book->belongs_to( 
+    author_id =>
+    'My::DBIC::Schema::Author'
+  );
 
-  My::DBIC::Schema::Book->belongs_to( author,
-                                      'My::DBIC::Schema::Author',
-                                      { 'foreign.author' => 'self.author' } );
+  # Usage
+  my $author_obj = $book->author; # get author object
+  $book->author( $new_author_obj ); # set author object
+  $book->author_id(); # get the plain id
 
+  # To retrieve the plain id if you used the ugly version:
+  $book->get_column('author_id');
+
+
 If the relationship is optional -- i.e. the column containing the foreign key
 can be NULL -- then the belongs_to relationship does the right thing. Thus, in
 the example above C<$obj-E<gt>author> would return C<undef>.  However in this
@@ -176,8 +196,12 @@
 operations work correctly.  The modified declaration is shown below:
 
   # in a Book class (where Author has_many Books)
-  __PACKAGE__->belongs_to(author => 'My::DBIC::Schema::Author',
-                          'author', {join_type => 'left'});
+  __PACKAGE__->belongs_to(
+    author => 
+    'My::DBIC::Schema::Author',
+    'author', 
+    { join_type => 'left' }
+  );
 
 
 Cascading deletes are off by default on a C<belongs_to>
@@ -194,7 +218,7 @@
 
 =over 4
 
-=item Arguments: $accessor_name, $related_class, $foreign_key_column|$cond?, $attr?
+=item Arguments: $accessor_name, $related_class, $foreign_key_column|\%cond|\@cond?, \%attr?
 
 =back
 
@@ -202,7 +226,7 @@
 foreign class store the calling class's primary key in one (or more) of its
 columns. This relationship defaults to using C<$accessor_name> as the foreign
 key in C<$related_class> to resolve the join, unless C<$foreign_key_column>
-specifies the foreign key column in C<$related_class> or C<$cond> specifies a
+specifies the foreign key column in C<$related_class> or C<cond> specifies a
 reference to a join condition hash.
 
 =over
@@ -212,9 +236,10 @@
 This argument is the name of the method you can call on a
 L<DBIx::Class::Row> object to retrieve a resultset of the related
 class restricted to the ones related to the row object. In list
-context it returns the row objects.
+context it returns the row objects. This is often called the
+C<relation(ship) name>.
 
-Use this accessor_name (relation name) in L<DBIx::Class::ResultSet/join>
+Use this accessor_name in L<DBIx::Class::ResultSet/join>
 or L<DBIx::Class::ResultSet/prefetch> to join to the foreign table
 indicated by this relationship.
 
@@ -231,45 +256,77 @@
 
 =item cond
 
-A hashref where the keys are C<foreign.$column_on_related_table> and
-the values are C<self.$foreign_key_column>. This is useful for
+A hashref where the keys are C<foreign.$foreign_key_column> and
+the values are C<self.$matching_column>. This is useful for
 relations that are across multiple columns.
 
+OR
+
+An arrayref containing an SQL::Abstract-like condition. For example a
+link table where two columns link back to the same table. This is an
+OR condition.
+
+  My::Schema::Item->has_many('rels', 'My::Schema::Relationships',
+                             [ { 'foreign.LItemID' => 'self.ID' },
+                               { 'foreign.RItemID' => 'self.ID'} ]);
 =back
 
   # in an Author class (where Author has_many Books)
-  My::DBIC::Schema::Author->has_many(books => 'My::DBIC::Schema::Book', 'author');
+  My::DBIC::Schema::Author->has_many(
+    books => 
+    'My::DBIC::Schema::Book', 
+    'author_id'
+  );
 
-  my $booklist = $obj->books;
-  my $booklist = $obj->books({
+  # OR (same result, assuming related_class is storing our PK)
+  My::DBIC::Schema::Author->has_many(
+    books => 
+    'My::DBIC::Schema::Book', 
+  );
+
+  # OR (same result)
+  My::DBIC::Schema::Author->has_many(
+    books => 
+    'My::DBIC::Schema::Book', 
+    { 'foreign.author_id' => 'self.id' },
+  );
+  
+
+  # Usage
+  # resultset of Books belonging to author 
+  my $booklist = $author->books;
+
+  # resultset of Books belonging to author, restricted by author name
+  my $booklist = $author->books({
     name => { LIKE => '%macaroni%' },
     { prefetch => [qw/book/],
   });
-  my @book_objs = $obj->books;
-  my $books_rs = $obj->books;
+
+  # array of Book objects belonging to author
+  my @book_objs = $author->books;
+
+  # force resultset even in list context
+  my $books_rs = $author->books;
   ( $books_rs ) = $obj->books_rs;
 
-  $obj->add_to_books(\%col_data);
+  # create a new book for this author, the relation fields are auto-filled
+  $author->create_related('books', \%col_data);
+  # alternative method for the above
+  $author->add_to_books(\%col_data);
 
-The above C<has_many> relationship could also have been specified with an
-explicit join condition:
 
-  My::DBIC::Schema::Author->has_many( books => 'My::DBIC::Schema::Book', {
-    'foreign.author' => 'self.author',
-  });
-
 Three methods are created when you create a has_many relationship.  The first
 method is the expected accessor method, C<$accessor_name()>.  The second is
 almost exactly the same as the accessor method but "_rs" is added to the end of
 the method name.  This method works just like the normal accessor, except that
-it returns a resultset no matter what, even in list context. The third method,
+it always returns a resultset, even in list context. The third method,
 named C<< add_to_$relname >>, will also be added to your Row items; this
 allows you to insert new related items, using the same mechanism as in
 L<DBIx::Class::Relationship::Base/"create_related">.
 
 If you delete an object in a class with a C<has_many> relationship, all
 the related objects will be deleted as well.  To turn this behaviour off,
-pass C<< cascade_delete => 0 >> in the C<$attr> hashref. However, any
+pass C<< cascade_delete => 0 >> in the C<attr> hashref. However, any
 database-level cascade or restrict will take precedence over a
 DBIx-Class-based cascading delete.
 
@@ -285,14 +342,14 @@
 
 =over 4
 
-=item Arguments: $accessor_name, $related_class, $foreign_key_column|$cond?, $attr?
+=item Arguments: $accessor_name, $related_class, $foreign_key_column|\%cond|\@cond?, \%attr?
 
 =back
 
 Creates an optional one-to-one relationship with a class. This relationship
 defaults to using C<$accessor_name> as the foreign key in C<$related_class> to
 resolve the join, unless C<$foreign_key_column> specifies the foreign key
-column in C<$related_class> or C<$cond> specifies a reference to a join
+column in C<$related_class> or C<cond> specifies a reference to a join
 condition hash.
 
 =over
@@ -301,9 +358,10 @@
 
 This argument is the name of the method you can call on a
 L<DBIx::Class::Row> object to retrieve the instance of the foreign
-class matching this relationship.
+class matching this relationship. This is often called the
+C<relation(ship) name>.
 
-Use this accessor_name (relation name) in L<DBIx::Class::ResultSet/join>
+Use this accessor_name in L<DBIx::Class::ResultSet/join>
 or L<DBIx::Class::ResultSet/prefetch> to join to the foreign table
 indicated by this relationship.
 
@@ -326,23 +384,29 @@
 
 =back
 
-  My::DBIC::Schema::Author->might_have( pseudonym =>
-                                        'My::DBIC::Schema::Pseudonym' );
+  # Author may have an entry in the pseudonym table
+  My::DBIC::Schema::Author->might_have(
+    pseudonym =>
+    'My::DBIC::Schema::Pseudonym',
+    'author_id',
+  );
 
-  my $pname = $obj->pseudonym; # to get the Pseudonym object
+  # OR (same result, assuming the related_class stores our PK)
+  My::DBIC::Schema::Author->might_have(
+    pseudonym =>
+    'My::DBIC::Schema::Pseudonym',
+  );
 
-The above might_have relationship could have been specified as:
+  # OR (same result)
+  My::DBIC::Schema::Author->might_have(
+    pseudonym =>
+    'My::DBIC::Schema::Pseudonym',
+    { 'foreign.author_id' => 'self.id' },
+  );
 
-  My::DBIC::Schema::Author->might_have( pseudonym =>
-                                        'My::DBIC::Schema::Pseudonym',
-                                        'author' );
+  # Usage
+  my $pname = $author->pseudonym; # to get the Pseudonym object
 
-Or even:
-
-  My::DBIC::Schema::Author->might_have( pseudonym =>
-                                        'My::DBIC::Schema::Pseudonym',
-                                        { 'foreign.author' => 'self.author' } );
-
 If you update or delete an object in a class with a C<might_have>
 relationship, the related object will be updated or deleted as well. To
 turn off this behavior, add C<< cascade_delete => 0 >> to the C<$attr>
@@ -356,20 +420,77 @@
 
 =over 4
 
-=item Arguments: $accessor_name, $related_class_name, $join_condition?, $attr?
+=item Arguments: $accessor_name, $related_class, $foreign_key_column|\%cond|\@cond?, \%attr?
 
 =back
 
-  My::DBIC::Schema::Book->has_one(isbn => 'My::DBIC::Schema::ISBN');
+Creates a one-to-one relationship with a class. This relationship
+defaults to using C<$accessor_name> as the foreign key in C<$related_class> to
+resolve the join, unless C<$foreign_key_column> specifies the foreign key
+column in C<$related_class> or C<cond> specifies a reference to a join
+condition hash.
 
-  my $isbn_obj = $obj->isbn; # to get the ISBN object
+=over
 
-Creates a one-to-one relationship with another class. This is just like
-C<might_have>, except the implication is that the other object is always
-present. The only difference between C<has_one> and C<might_have> is that
-C<has_one> uses an (ordinary) inner join, whereas C<might_have> uses a
-left join.
+=item accessor_name
 
+This argument is the name of the method you can call on a
+L<DBIx::Class::Row> object to retrieve the instance of the foreign
+class matching this relationship. This is often called the
+C<relation(ship) name>.
+
+Use this accessor_name in L<DBIx::Class::ResultSet/join>
+or L<DBIx::Class::ResultSet/prefetch> to join to the foreign table
+indicated by this relationship.
+
+=item related_class
+
+This is the class name of the table which contains a foreign key
+column containing PK values of this class.
+
+=item foreign_key_column
+
+The column name on the related class that contains the foreign key.
+
+OR
+
+=item cond
+
+A hashref where the keys are C<foreign.$column_on_related_table> and
+the values are C<self.$foreign_key_column>. This is useful for
+relations that are across multiple columns.
+
+=back
+
+  # Every book has exactly one ISBN
+  My::DBIC::Schema::Book->has_one(
+    isbn => 
+    'My::DBIC::Schema::ISBN',
+    'book_id',
+  );
+
+  # OR (same result, assuming related_class stores our PK)
+  My::DBIC::Schema::Book->has_one(
+    isbn => 
+    'My::DBIC::Schema::ISBN',
+  );
+
+  # OR (same result)
+  My::DBIC::Schema::Book->has_one(
+    isbn => 
+    'My::DBIC::Schema::ISBN',
+    { 'foreign.book_id' => 'self.id' },
+  );
+
+  # Usage
+  my $isbn_obj = $book->isbn; # to get the ISBN object
+
+Creates a one-to-one relationship with another class. This is just
+like C<might_have>, except the implication is that the other object is
+always present. The only difference between C<has_one> and
+C<might_have> is that C<has_one> uses an (ordinary) inner join,
+whereas C<might_have> defaults to a left join.
+
 The has_one relationship should be used when a row in the table has exactly one
 related row in another table. If the related row might not exist in the foreign
 table, use the L<DBIx::Class::Relationship/might_have> relationship.
@@ -384,7 +505,7 @@
 
 =over 4
 
-=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, $attr?
+=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, \%attr?
 
 =back
 
@@ -456,7 +577,7 @@
 relation names are then used in the many_to_many call.
 
 In the above example, the Actor class will have 3 many_to_many accessor methods
-set: C<$roles>, C<$add_to_roles>, C<$set_roles>, and similarly named accessors
+set: C<roles>, C<add_to_roles>, C<set_roles>, and similarly named accessors
 will be created for the Role class for the C<actors> many_to_many
 relationship.
 
@@ -469,7 +590,7 @@
 
 =head1 AUTHORS
 
-Matt S. Trout <mst at shadowcatsystems.co.uk>
+see L<DBIx::Class>
 
 =head1 LICENSE
 

Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/ResultSource.pm	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/ResultSource.pm	2008-05-30 15:59:13 UTC (rev 4439)
@@ -905,6 +905,16 @@
       $self->throw_exception(
         "Can't prefetch has_many ${pre} (join cond too complex)")
         unless ref($rel_info->{cond}) eq 'HASH';
+      my $dots = @{[$as_prefix =~ m/\./g]} + 1; # +1 to match the ".${as_prefix}"
+      if (my ($fail) = grep { @{[$_ =~ m/\./g]} == $dots }
+                         keys %{$collapse}) {
+        my ($last) = ($fail =~ /([^\.]+)$/);
+        $self->throw_exception(
+          "Can't prefetch multiple has_many rels ${last} and ${pre}"
+          .(length($as_prefix) ? "at the same level (${as_prefix})"
+                               : "at top level"
+        ));
+      }
       #my @col = map { (/^self\.(.+)$/ ? ("${as_prefix}.$1") : ()); }
       #              values %{$rel_info->{cond}};
       $collapse->{".${as_prefix}${pre}"} = [ $rel_source->primary_columns ];

Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/TxnScopeGuard.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/TxnScopeGuard.pm	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/TxnScopeGuard.pm	2008-05-30 15:59:13 UTC (rev 4439)
@@ -18,25 +18,32 @@
   $self->[0] = 1;
 }
 
+sub dismiss {
+  my $self = shift;
+  
+  $self->[0] = 1;
+}
+
 sub DESTROY {
   my ($dismiss, $storage) = @{$_[0]};
 
   return if $dismiss;
 
   my $exception = $@;
+  Carp::cluck("A DBIx::Class:: went out of scope without explicit commit/dismiss")
+    unless $exception; 
+  {
+    local $@;
+    eval { $storage->txn_rollback };
+    my $rollback_exception = $@;
+    if($rollback_exception) {
+      my $exception_class = "DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION";
 
-  $DB::single = 1;
-
-  local $@;
-  eval { $storage->txn_rollback };
-  my $rollback_exception = $@;
-  if($rollback_exception) {
-    my $exception_class = "DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION";
-
-    $storage->throw_exception(
-      "Transaction aborted: ${exception}. "
-      . "Rollback failed: ${rollback_exception}"
-    ) unless $rollback_exception =~ /$exception_class/;
+      $storage->throw_exception(
+        "Transaction aborted: ${exception}. "
+        . "Rollback failed: ${rollback_exception}"
+      ) unless $rollback_exception =~ /$exception_class/;
+    }
   }
 }
 

Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class.pm	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class.pm	2008-05-30 15:59:13 UTC (rev 4439)
@@ -49,6 +49,18 @@
 
 DBIx::Class - Extensible and flexible object <-> relational mapper.
 
+=head1 GETTING HELP/SUPPORT
+
+The community can be found via:
+
+  Mailing list: http://lists.scsys.co.uk/mailman/listinfo/dbix-class/
+
+  SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
+
+  SVNWeb: http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/
+
+  IRC: irc.perl.org#dbix-class
+
 =head1 SYNOPSIS
 
 Create a schema class called DB/Main.pm:
@@ -170,16 +182,6 @@
 are generally made to CPAN before the branch for the next release is
 merged back to trunk for a major release.
 
-The community can be found via:
-
-  Mailing list: http://lists.scsys.co.uk/mailman/listinfo/dbix-class/
-
-  SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
-
-  SVNWeb: http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/
-
-  IRC: irc.perl.org#dbix-class
-
 =head1 WHERE TO GO NEXT
 
 L<DBIx::Class::Manual::DocMap> lists each task you might want help on, and

Modified: DBIx-Class/0.08/branches/replication_dedux/t/03podcoverage.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/03podcoverage.t	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/t/03podcoverage.t	2008-05-30 15:59:13 UTC (rev 4439)
@@ -76,6 +76,7 @@
     'DBIx::Class::Relationship::ManyToMany'             => { skip => 1 },
     'DBIx::Class::Relationship::ProxyMethods'           => { skip => 1 },
     'DBIx::Class::ResultSetProxy'                       => { skip => 1 },
+    'DBIx::Class::ResultSetManager'                     => { skip => 1 },
     'DBIx::Class::ResultSourceProxy'                    => { skip => 1 },
     'DBIx::Class::Storage::DBI'                         => { skip => 1 },
     'DBIx::Class::Storage::DBI::DB2'                    => { skip => 1 },

Modified: DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t	2008-05-30 15:59:13 UTC (rev 4439)
@@ -368,17 +368,23 @@
         $pr_tracks_rs = $pr_cd_rs->first->tracks;
         $pr_tracks_count = $pr_tracks_rs->count;
     };
-    ok(! $@, 'exception on attempt to prefetch several same level has_many\'s (1 -> M + M)');
-    is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
 
-    is($pr_tracks_count, $tracks_count, 'equal count of prefetched relations over several same level has_many\'s (1 -> M + M)');
+    my $o_mm_exc = $@;
+    ok(! $o_mm_exc, 'exception on attempt to prefetch several same level has_many\'s (1 -> M + M)');
 
-    for ($pr_tracks_rs, $tracks_rs) {
-        $_->result_class ('DBIx::Class::ResultClass::HashRefInflator');
-    }
+    SKIP: {
+        skip "1 -> M + M prefetch died", 3 if $o_mm_exc;
+    
+        is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
+        is($pr_tracks_count, $tracks_count, 'equal count of prefetched relations over several same level has_many\'s (1 -> M + M)');
 
-    is_deeply ([$pr_tracks_rs->all], [$tracks_rs->all], 'same structure returned with and without prefetch over several same level has_many\'s (1 -> M + M)');
+        for ($pr_tracks_rs, $tracks_rs) {
+            $_->result_class ('DBIx::Class::ResultClass::HashRefInflator');
+        }
 
+        is_deeply ([$pr_tracks_rs->all], [$tracks_rs->all], 'same structure returned with and without prefetch over several same level has_many\'s (1 -> M + M)');
+    };
+
     #( M -> 1 -> M + M )
     my $note_rs = $schema->resultset('LinerNotes')->search ({ notes => 'Buy Whiskey!' });
     my $pr_note_rs = $note_rs->search ({}, {
@@ -399,16 +405,23 @@
         $pr_tags_rs = $pr_note_rs->first->cd->tags;
         $pr_tags_count = $pr_tags_rs->count;
     };
-    ok(! $@, 'exception on attempt to prefetch several same level has_many\'s (M -> 1 -> M + M)');
-    is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
 
-    is($pr_tags_count, $tags_count, 'equal count of prefetched relations over several same level has_many\'s (M -> 1 -> M + M)');
+    my $m_o_mm_exc = $@;
+    ok(! $m_o_mm_exc, 'exception on attempt to prefetch several same level has_many\'s (M -> 1 -> M + M)');
 
-    for ($pr_tags_rs, $tags_rs) {
-        $_->result_class ('DBIx::Class::ResultClass::HashRefInflator');
-    }
+    SKIP: {
+        skip "M -> 1 -> M + M prefetch died", 3 if $m_o_mm_exc;
+    
+        is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
 
-    is_deeply ([$pr_tags_rs->all], [$tags_rs->all], 'same structure returned with and without prefetch over several same level has_many\'s (M -> 1 -> M + M)');
+        is($pr_tags_count, $tags_count, 'equal count of prefetched relations over several same level has_many\'s (M -> 1 -> M + M)');
+
+        for ($pr_tags_rs, $tags_rs) {
+            $_->result_class ('DBIx::Class::ResultClass::HashRefInflator');
+        }
+
+        is_deeply ([$pr_tags_rs->all], [$tags_rs->all], 'same structure returned with and without prefetch over several same level has_many\'s (M -> 1 -> M + M)');
+    };
 };
 
 eval { my $track = $schema->resultset('CD')->search ({ 'me.title' => 'Forkful of bees' }, { prefetch => [qw/tracks tags/] })->first->tracks->first };

Modified: DBIx-Class/0.08/branches/replication_dedux/t/81transactions.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/81transactions.t	2008-05-30 15:58:16 UTC (rev 4438)
+++ DBIx-Class/0.08/branches/replication_dedux/t/81transactions.t	2008-05-30 15:59:13 UTC (rev 4439)
@@ -8,7 +8,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 67;
+plan tests => 63;
 
 my $code = sub {
   my ($artist, @cd_titles) = @_;
@@ -238,30 +238,8 @@
     ok(($err eq ''), 'Pre-connection nested transactions.');
 }
 
-# Test txn_rollback with nested
-{
-  local $TODO = "Work out how this should work";
-  my $local_schema = DBICTest->init_schema();
-
-  my $artist_rs = $local_schema->resultset('Artist');
-  throws_ok {
-   
-    $local_schema->txn_begin;
-    $artist_rs->create({ name => 'Test artist rollback 1'});
-    $local_schema->txn_begin;
-    is($local_schema->storage->transaction_depth, 2, "Correct transaction depth");
-    $artist_rs->create({ name => 'Test artist rollback 2'});
-    $local_schema->txn_rollback;
-  } qr/Not sure what this should be.... something tho/, "Rolled back okay";
-  is($local_schema->storage->transaction_depth, 0, "Correct transaction depth");
-
-  ok(!$artist_rs->find({ name => 'Test artist rollback 1'}), "Test Artist not created")
-    || $artist_rs->find({ name => 'Test artist rollback 1'})->delete;
-}
-
 # Test txn_scope_guard
 {
-  local $TODO = "Work out how this should work";
   my $schema = DBICTest->init_schema();
 
   is($schema->storage->transaction_depth, 0, "Correct transaction depth");
@@ -276,7 +254,7 @@
     });
     
    $guard->commit;
-  } qr/No such column made_up_column.*?line 16/, "Error propogated okay";
+  } qr/No such column made_up_column .*? at .*?81transactions.t line \d+/, "Error propogated okay";
 
   ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created");
 
@@ -294,6 +272,7 @@
     # forcing a txn_rollback to happen
     outer($schema, 0);
   };
+  local $TODO = "Work out how this should work";
   is($@, "Not sure what we want here, but something", "Rollback okay");
 
   ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created");




More information about the Bast-commits mailing list