This project is archived and is in readonly mode.
[PATCH] Check and immediately return value from an average if it's already a BigDecimal
-
Neeraj Singh
+1
Looks good to me.
-
Andrew White
I don't think the value is ever a BigDecimal, as it doesn't have a to_d method so would raise a NoMethodError if it ever was.
-
Jeremy Kemper
- Milestone set to 2.3.6
- State changed from new to open
It is when the driver returns typecasted results, like mysql2.
Brian, this whole method should probably return self for non-Strings.
-
Brian Lopez
Was hoping to fix and repost the patch this weekend but didn't end up having time. I'll try and get it up today or tomorrow
-
Brian Lopez
Here's the updated patch, still looking into test failures to see if they're from this or something else
-
Brian Lopez
Ok, here's the patch with updated and passing tests (based on master)
-
Jeremy Kemper
Hey Brian, this changes behavior on nil results too, though. Think it should be confined to just letting pre-typecasted values through.
-
Brian Lopez
Was worried that wouldn't be desired - in our short chat on IRC about it you mentioned returning 0 for nil which is why I put it in there.
It does make sense to me that a sum/avg/count should return a Numeric in all cases, but then again it does seem a better fit to return exactly what the db is giving us (even null).Updated patch coming soon...
-
Brian Lopez
new patch per code-review
-
Repository
- State changed from open to committed
(from [7aad851c2e0d4579aa33a54a069a767b53cca406]) Allow pre-casted values (other than nil) to pass through from calculations un-touched
[#4514 [PATCH] Check and immediately return value from an average if it's already a ... state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/7aad851c2e0d4579aa33a54a069a76... -
Brian Lopez
Attaching the backport for 2.3
-
Repository
(from [6dbc75fd7625c0248d269cc3127910cb4c888ed9]) Allow pre-casted values (other than nil) to pass through from calculations un-touched
[#4514 [PATCH] Check and immediately return value from an average if it's already a ... state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/6dbc75fd7625c0248d269cc3127910... -
Santiago Pastorino
- Milestone cleared.
- State changed from committed to open
This break test_should_average_field test.
Patchs for master and 2-3-stable added. -
Santiago Pastorino
A better master patch here. I will redo the one for 2-3-stable later
-
Santiago Pastorino
For master without checking types
-
Santiago Pastorino
For 2-3-stable here
-
Repository
- State changed from open to committed
(from [ad73a3aec4665d8a44060640e51075fd732c33a1]) type_cast_calculated_value refactor: value is never a Fixnum here. Fix test since SQLite returns Float.
[#4514 [PATCH] Check and immediately return value from an average if it's already a ... state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/ad73a3aec4665d8a44060640e51075... -
Repository
(from [5f3bd55726703e08ba595555e1cf428c57832603]) type_cast_calculated_value refactor: value is never a Fixnum here. Fix test since SQLite returns Float.
[#4514 [PATCH] Check and immediately return value from an average if it's already a ... state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/5f3bd55726703e08ba595555e1cf42... -
Andreas Mayer
May this be related to ticket #6103 average() returns integer values instead of decimals ?
