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.

update_counters should update nil values

#493

Sometimes i want to update a counter that hasn't a default value, therefore nil (null in the database) is the default.

With this patch update_counters will work on null values assuming they have a value of 0.

Tested in mysql, sqlite, sqlite3 and postgres.

Reported by Emilio Tagua · June 26th, 2008 @ 05:50 PM

State: resolved
Milestone: 2.1.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Emilio Tagua
    Emilio Tagua

    Changed to use COALESCE instead of custom query for each DBMS.

    June 26th, 2008 @ 05:32 PM

  2. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open
    • Milestone set to 2.1.1
    • Assigned user set to Jeremy Kemper

    June 26th, 2008 @ 09:34 PM

  3. Repository
    Repository
    • State changed from open to resolved

    (from [f253e98d844b121f29ff6879075ad975ac07fe6d]) update_counters should update nil values.

    This allows counter columns with default null instead of requiring default 0.

    [#493 state:resolved]

    http://github.com/rails/rails/co...

    July 16th, 2008 @ 12:26 AM

  4. Mislav
    Mislav

    The code is a bit shorter, nicer, and adds a missing test. +1 from me

    August 7th, 2008 @ 05:57 PM

  5. Mislav