From: Aran Deltac Date: Thu, 25 May 2006 17:13:31 +0000 (+0000) Subject: Merge 'DBIx-Class-current' into 'reorganize_tests' X-Git-Tag: v0.07002~75^2~165^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5f761f70098f84199318b56cc80e3589b8506be;hp=ae51573612aec70814b81bfe0c3683b824564368;p=dbsrgits%2FDBIx-Class.git Merge 'DBIx-Class-current' into 'reorganize_tests' --- diff --git a/Changes b/Changes index f26e8b0..cd9962b 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for DBIx::Class + - marked DB.pm as deprecated and noted it will be removed by 1.0 - add ResultSetColumn - refactor ResultSet code to resolve attrs as late as poss - merge prefetch attrs into join attrs diff --git a/TODO b/TODO index 136e01a..e22c6ba 100644 --- a/TODO +++ b/TODO @@ -51,4 +51,10 @@ SQLT modules so an app can do its own deploy without SQLT on the target system +2006-05-25 by mst (TODOed by bluefeet) + Add the search attributes "limit" and "rows_per_page". + limit: work as expected just like offset does + rows_per_page: only be used if you used the page attr or called $rs->page + rows: modify to be an alias that gets used to populate either as appropriate, + if you haven't specified one of the others diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index aa5eeb3..9e67f5c 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -31,7 +31,7 @@ sub resultset_instance { =head1 NAME -DBIx::Class::DB - Non-recommended classdata schema component +DBIx::Class::DB - (DEPRECATED) classdata schema component =head1 SYNOPSIS @@ -54,8 +54,8 @@ DBIx::Class::DB - Non-recommended classdata schema component This class is designed to support the Class::DBI connection-as-classdata style for DBIx::Class. You are *strongly* recommended to use a DBIx::Class::Schema -instead; DBIx::Class::DB will continue to be supported but new development -will be focused on Schema-based DBIx::Class setups. +instead; DBIx::Class::DB will not undergo new development and will be moved +to being a CDBICompat-only component before 1.0. =head1 METHODS diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 00f4c82..9f2a8fa 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -409,24 +409,22 @@ example of the recommended way to use it: my $genus = $schema->resultset('Genus')->find(12); + my $coderef2 = sub { + $genus->extinct(1); + $genus->update; + }; + my $coderef1 = sub { - my ($schema, $genus, $code) = @_; $genus->add_to_species({ name => 'troglodyte' }); $genus->wings(2); $genus->update; - $schema->txn_do($code, $genus); # Can have a nested transaction + $schema->txn_do($coderef2); # Can have a nested transaction return $genus->species; }; - my $coderef2 = sub { - my ($genus) = @_; - $genus->extinct(1); - $genus->update; - }; - my $rs; eval { - $rs = $schema->txn_do($coderef1, $schema, $genus, $coderef2); + $rs = $schema->txn_do($coderef1); }; if ($@) { # Transaction failed diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 98387b4..a38572c 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -522,12 +522,11 @@ exception) an exception is thrown that includes a "Rollback failed" message. For example, my $author_rs = $schema->resultset('Author')->find(1); + my @titles = qw/Night Day It/; my $coderef = sub { - my ($author, @titles) = @_; - # If any one of these fails, the entire transaction fails - $author->create_related('books', { + $author_rs->create_related('books', { title => $_ }) foreach (@titles); @@ -536,16 +535,14 @@ For example, my $rs; eval { - $rs = $schema->txn_do($coderef, $author_rs, qw/Night Day It/); + $rs = $schema->txn_do($coderef); }; - if ($@) { - my $error = $@; - if ($error =~ /Rollback failed/) { - die "something terrible has happened!"; - } else { - deal_with_failed_transaction(); - } + if ($@) { # Transaction failed + die "something terrible has happened!" # + if ($@ =~ /Rollback failed/); # Rollback failed + + deal_with_failed_transaction(); } In a nested transaction (calling txn_do() from within a txn_do() coderef) only diff --git a/t/53delete_related.t b/t/53delete_related.t index 5c47959..e0cfe12 100644 --- a/t/53delete_related.t +++ b/t/53delete_related.t @@ -27,3 +27,4 @@ cmp_ok($artist2_cds, '<', $total_cds, 'need more cds than related cds'); ok($artist2->delete_related('cds', {title => {like => '%'}})); cmp_ok($schema->resultset('CD')->count, '==', ($total_cds - $artist2_cds), 'too many cds were deleted'); +