This project is archived and is in readonly mode.
update_counters should update nil values
Reported by Emilio Tagua | June 26th, 2008 @ 05:50 PM | in 2.1.1
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.
Comments and changes to this ticket
- 
        

Emilio Tagua June 26th, 2008 @ 05:32 PM
Changed to use COALESCE instead of custom query for each DBMS.
 - 
        

Jeremy Kemper June 26th, 2008 @ 09:34 PM
- State changed from new to open
 - Milestone set to 2.1.1
 - Assigned user set to Jeremy Kemper
 
 - 
        

Repository July 16th, 2008 @ 12:26 AM
- 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]
 - 
            
        

Mislav August 7th, 2008 @ 05:57 PM
The code is a bit shorter, nicer, and adds a missing test. +1 from me
 - 
            
        

 
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>