Project

General

Profile

Bug #19698

Updated by Peter Amstutz over 1 year ago

save_with_unique_name works like this: 

 <pre> 
       conn.exec_query 'SAVEPOINT save_with_unique_name' 
       begin 
         save! 
       rescue ActiveRecord::RecordNotUnique => rn 
         # tries different names, uses  
         # "ROLLBACK TO SAVEPOINT"  
         # to recover from transaction errors 
       ensure 
         conn.exec_query 'RELEASE SAVEPOINT save_with_unique_name' 
       end 
 </pre> 

 It seems that if some other transaction error happens, then 

 # transaction is aborted 
 # the "ensure" block runs "RELEASE SAVEPOINT" 
 # because the transaction is aborted, it rejects "RELEASE SAVEPOINT" 
 # it raises a new error about not being able to accept "RELEASE SAVEPOINT" instead of propagating the original error 

 The result is a cryptic error about ignoring commands in a failed transaction and not the original error that gives some indication of what was wrong. 

Back