plataformatec/devise — pull request #2444 by julp (2013-05-29 19:06:05+00:00)
Title: Fix empty transactions created by devise

Hello,

this is not a big deal but, by taking a look to logs, rails (3.2.13) and database, I found some traces with an empty transaction:

statement: BEGIN
statement: COMMIT
statement: BEGIN
statement: COMMIT

It sounded weird to me, I was first wondering if I hadn't a bug somewhere but after some digging, I found that it happens when an unchanged object is saved (via save(!) or update_attribute(s) methods).

As far as I understand, ActiveRecord (?) starts a transaction before to check/know if the record has been changed and does nothing if so (ie does not execute an UPDATE statement).

Must it be considered as an ActiveRecord bug? Is it relevant to update the object only if we assume by ourselves that it is unchanged like I suggest it in this PR?

Thanks.