lib/spiderfw/model/storage/db/adapters/mysql.rb in spiderfw-0.6.31 vs lib/spiderfw/model/storage/db/adapters/mysql.rb in spiderfw-0.6.32
- old
+ new
@@ -149,16 +149,16 @@
return curr[:in_transaction] ? true : false
end
def do_commit
- curr[:conn].commit if curr[:conn]
+ curr[:conn].commit unless curr[:conn].blank?
curr[:in_transaction] = false
end
def do_rollback
- curr[:conn].rollback if curr[:conn]
+ curr[:conn].rollback unless curr[:conn].blank?
curr[:in_transaction] = false
end
def rollback_savepoint(name=nil)
connection.query("ROLLBACK TO #{name}")
@@ -210,18 +210,18 @@
end
else
return res
end
rescue => exc
- release
+ release if !in_transaction?
if (exc.message =~ /Duplicate entry/)
raise Spider::Model::Storage::DuplicateKey
else
raise exc
end
ensure
query_finished
- release if curr[:conn] && !in_transaction?
+ release if !curr[:conn].blank? && !in_transaction?
end
end
def prepare(sql)
debug("mysql preparing: #{sql}")