MDL-27325 mysql: Avoid some implicit casting from float to varchar/text

This commit is contained in:
Eloy Lafuente (stronk7)
2011-05-06 16:07:17 +02:00
parent 6531aff715
commit 7aa9e45f56
@@ -579,6 +579,10 @@ class mysqli_native_moodle_database extends moodle_database {
if ($column->meta_type == 'I' or $column->meta_type == 'F' or $column->meta_type == 'N') {
$value = 0; // prevent '' problems in numeric fields
}
// Any float value being stored in varchar or text field is converted to string to avoid
// any implicit conversion by MySQL
} else if (is_float($value) and ($column->meta_type == 'C' or $column->meta_type == 'X')) {
$value = "$value";
}
// workaround for problem with wrong enums in mysql - TODO: Out in Moodle 2.1
if (!empty($column->enums)) {