This project is archived and is in readonly mode.

#689 ✓committed
Dmitry Sokurenko

ActiveRecord::Base#destroy should write 1 line into log

Reported by Dmitry Sokurenko | July 24th, 2008 @ 11:41 AM | in 2.x

Currently SELECTs, INSERTs and UPDATEs generates exactly one line in the log. But DELETEs are logged in 3 lines, because the template for DELETE statements is written using heredocs. It's not convinient to read, nor to parse.

So now it is:

User Load (0.000362)   SELECT * FROM `users` WHERE `id` = 1
User Update (0.00050) UPDATE `users` SET `enabled = 0 WHERE `id` = 1
User Destroy (0.000333)    DELETE FROM `users`
 WHERE `id` = 1

Some other statement

With patch, it would be:

User Load (0.000362)   SELECT * FROM `users` WHERE `id` = 1
User Update (0.00050) UPDATE `users` SET `enabled = 0 WHERE `id` = 1
User Destroy (0.000333)    DELETE FROM `users`WHERE `id` = 1
Some other statement

So there is a patch and a test for it. Test is a little bit awkward, because I don't know any clean way to test log in Rails.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages