[Dbix-class] DBIx::Class manual page and transactions

Sam Vilain sam at vilain.net
Mon May 8 02:17:15 CEST 2006


This example on the DBIx::Class manual page makes no sense:

  my $new_cd = $schema->resultset('CD')->new({ title => 'Spoon' });
  $new_cd->artist($cd->artist);
  $new_cd->insert; # Auto-increment primary key filled in after INSERT
  $new_cd->title('Fork');

  $schema->txn_do(sub { $new_cd->update }); # Runs the update in a transaction

The point of transactions is that you start the transaction, read in or otherwise lock the information which is influencing the update, then commit.

While it does communicate the API, it is a bad example as that is precisely the wrong place to wrap a transaction.

Sam.





More information about the Dbix-class mailing list