I am using Mysql 5.6 with a threaded connection pool with 4.7.0 of Sequel. 
 I am noticing that the following simplified snippet fails to rollback:

DB.transaction do
  ModelClass.filter(:some_id => var_id).delete
  raise Sequel::Rollback
end

I am seeing that the delete will occur even though a rollback happens.  I 
debugged this in mysql log and I am seeing that the delete call is 
occurring on a different connection than the transaction call.

    23 Query BEGIN

   35 Query DELETE FROM `model_class` WHERE (`some_id` = 123)

   23 Query ROLLBACK

Therefore, the delete goes through.  If I change my code to:
DB.transaction do
 DB[:model_class].filter(:some_id => var_id).delete
 raise Sequel::Rollback
end

The delete is correctly rolled back and I see in the mysql logs that the 
same connection is used.  If I have to use a Sequel Dataset 
(DB[:model_class]), I am not able to use convenient model methods like 
"save".  Instead I have to use "insert" on the dataset which will not run 
all the conveniences of a model save (i.e. after_save callback, etc.).  Is 
there any way to continue using the ModelClass instead of a Sequel Dataset? 
 I've unsuccessfully tried prepared transactions, DB.synchronize, etc.

Also, I see at the bottom 
of http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html, 
find_or_create is called on a model class which has the same problem as my 
first example above.

Thanks in advance for the help, and please let me know if you have any 
questions.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to