Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 7aa9e45f56d74d9424baa3dde444870610cd1f90 1 parent 6531aff
@stronk7 stronk7 authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/dml/mysqli_native_moodle_database.php
View
4 lib/dml/mysqli_native_moodle_database.php
@@ -579,6 +579,10 @@ protected function normalise_value($column, $value) {
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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.