]> git.mjollnir.org Git - moodle.git/commitdiff
Bug #5582 - sort by numerical field doesn't work properly with decimals; merged from...
authorskodak <skodak>
Thu, 25 May 2006 15:57:20 +0000 (15:57 +0000)
committerskodak <skodak>
Thu, 25 May 2006 15:57:20 +0000 (15:57 +0000)
mod/data/field/number/field.class.php

index 072a415645980689b25807a1411c8d98cf5e757f..78600b4ff90da663cffad504e4be503f01d5427b 100755 (executable)
@@ -48,8 +48,8 @@ class data_field_number extends data_field_base {
         global $CFG;
 
         switch ($CFG->dbtype) {
-            case 'mysql':      // DECIMAL would be more accurate but only MySQL 5 supports it.
-                return 'CAST('.$fieldname.' AS SIGNED)';  
+            case 'mysql':   // string in an arithmetic operation is converted to a floating-point number
+                return '('.$fieldname.'+0.0)';  
 
             default:
                 return 'CAST('.$fieldname.' AS REAL)';