[Dbix-class] create and create_related functioning differently
when AutoCommit = 0
Matt S Trout
dbix-class at trout.me.uk
Wed Oct 17 20:11:36 GMT 2007
On Tue, Oct 16, 2007 at 02:06:34PM -0500, Adam Dukes wrote:
> Hi,
>
> I'm running into a problem when using DBIx::Class::ResultSet::create
> with the schema's AutoCommit set to 0. When I use this schema to grab
> a Row object, and use add_to_* or create_related, the data is not
> commited to the database, and all changes rollback after completion.
>
> However, when I use the same schema to get a ResultSet, and use
> ResultSet::create to insert a new row, the value is created and
> inserted into the database immediately, and unaffected by rollback.
>
> Any suggestions on why AutoCommit = 0 is not affecting the create calls?
AutoCommit => 0 is strongly disrecommended for DBIx::Class.
Unless you're sharing the $dbh with legacy code, set it to 1 and use the
txn_* methods provided by the $schema - I use txn_do for everything, which
allows DBIC to handle depth and commit/rollback automatically for you.
If you try and use DBI transaction calls with DBIx::Class then you'll end up
with the storage object's state being out of sync and the results are
undefined.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list