mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-53944 dml: make char2real() for mysql to support decimals
- With the patch, 6 positions of scale accuracy are guaranteed per individual casted value. - Backed with unit tests, both for varchar and clob. - Added 2 missing tests about uses of the method with params and values. Note: 6 was picked because looking to all databases implementation postgres was found to be casting to real, aka, 6.
This commit is contained in:
parent
440b4c54ca
commit
4ae653024d
2 changed files with 22 additions and 4 deletions
|
@ -1504,7 +1504,11 @@ class mysqli_native_moodle_database extends moodle_database {
|
|||
}
|
||||
|
||||
public function sql_cast_char2real($fieldname, $text=false) {
|
||||
return ' CAST(' . $fieldname . ' AS DECIMAL) ';
|
||||
// Set to 65 (max mysql 5.5 precision) with 7 as scale
|
||||
// because we must ensure at least 6 decimal positions
|
||||
// per casting given that postgres is casting to that scale (::real::).
|
||||
// Can be raised easily but that must be done in all DBs and tests.
|
||||
return ' CAST(' . $fieldname . ' AS DECIMAL(65,7)) ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue