Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#689

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.

Reported by Dmitry Sokurenko · July 24th, 2008 @ 11:41 AM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Clemens Kofler
    Clemens Kofler
    • Tag changed from activerecord, bug, patch to activerecord, enhancement, logging, patch, tested

    +1. Doesn't hurt and increases readability.

    July 25th, 2008 @ 12:06 AM

  2. josh
    josh
    • State changed from new to open

    Interesting

    October 28th, 2008 @ 04:32 PM

  3. Repository
    Repository

    (from [8f0f07863727edaad1e59df4ab4ec159016917e7]) Make #destroy write 1 line into log (instead of 3) (Dmitry Sokurenko) [#689 ActiveRecord::Base#destroy should write 1 line into log status:committed] http://github.com/rails/rails/co...

    October 29th, 2008 @ 10:23 AM

  4. DHH
    DHH
    • State changed from open to committed

    October 29th, 2008 @ 11:16 AM