Update(ids, attributes)

reading

    # File vendor/rails/activerecord/lib/active_record/base.rb, line 

473
473: def update(id, attributes)
474: if id.is_a?(Array)
475: idx = -1
476: id.collect { |id| idx += 1; update(id,
attributes[idx]) }
477: else
478: object = find(id)
479: object.update_attributes(attributes)
480: object
481: end
482: end

it seems there is no way that a call to

update(ids, attributes)

could possibly do a ‘begin transaction;’ … ‘commit;’ as was guessing
it
might in the case of list input.

can that be right? if so why would this not be automatic for list
updates?

-a

===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| – bodhicaryavatara

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Dec 6, 2005, at 9:47 PM, Ara.T.Howard wrote:

it seems there is no way that a call to
update(ids, attributes)
could possibly do a ‘begin transaction;’ … ‘commit;’ as was
guessing it
might in the case of list input.

can that be right? if so why would this not be automatic for list
updates?

I imagine it was overlooked when implemented. Check out lib/
active_record/transactions.rb – #destroy and #save are wrapped;
update should be as well. Please post a bug to http://
dev.rubyonrails.org/newticket.

Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDloKVAQHALep9HFYRAt64AKCJ1EuHeeavbkNmIc0w0LZfUfpOQACgvxnl
NyPOO6yv2jjQmkgf4bRjDmE=
=CdFj
-----END PGP SIGNATURE-----

I don’t think this is a bug; you can always wrap the update in a
transaction
if desired. I would rather handle when explicit COMMITs are executed
than have the
code issue them automatically.

As the code stands, if an explicit transaction is not used then each
UPDATE is
COMMITted implicitly, as an AUTOCOMMIT – slow but workable, and easily
overridden
with an explicit transaction if desired.