mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-25276 dml - fix/implement sql_cast2int/real() across the 5 drivers. Tests passing.
This commit is contained in:
parent
a018adf038
commit
9882b2c824
@ -1052,7 +1052,19 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
/// SQL helper functions
|
||||
|
||||
public function sql_cast_char2int($fieldname, $text=false) {
|
||||
return ' CAST(' . $fieldname . ' AS INT) ';
|
||||
if (!$text) {
|
||||
return ' CAST(' . $fieldname . ' AS INT) ';
|
||||
} else {
|
||||
return ' CAST(' . $this->sql_compare_text($fieldname) . ' AS INT) ';
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_cast_char2real($fieldname, $text=false) {
|
||||
if (!$text) {
|
||||
return ' CAST(' . $fieldname . ' AS REAL) ';
|
||||
} else {
|
||||
return ' CAST(' . $this->sql_compare_text($fieldname) . ' AS REAL) ';
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_ceil($fieldname) {
|
||||
|
@ -1052,6 +1052,10 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
return ' CAST(' . $fieldname . ' AS SIGNED) ';
|
||||
}
|
||||
|
||||
public function sql_cast_char2real($fieldname, $text=false) {
|
||||
return ' CAST(' . $fieldname . ' AS DECIMAL) ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'LIKE' part of a query.
|
||||
*
|
||||
|
@ -1447,6 +1447,14 @@ class oci_native_moodle_database extends moodle_database {
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_cast_char2real($fieldname, $text=false) {
|
||||
if (!$text) {
|
||||
return ' CAST(' . $fieldname . ' AS FLOAT) ';
|
||||
} else {
|
||||
return ' CAST(' . $this->sql_compare_text($fieldname) . ' AS FLOAT) ';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'LIKE' part of a query.
|
||||
*
|
||||
|
@ -1152,7 +1152,19 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
/// SQL helper functions
|
||||
|
||||
public function sql_cast_char2int($fieldname, $text = false) {
|
||||
return ' CAST('.$fieldname.' AS INT) ';
|
||||
if (!$text) {
|
||||
return ' CAST(' . $fieldname . ' AS INT) ';
|
||||
} else {
|
||||
return ' CAST(' . $this->sql_compare_text($fieldname) . ' AS INT) ';
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_cast_char2real($fieldname, $text=false) {
|
||||
if (!$text) {
|
||||
return ' CAST(' . $fieldname . ' AS REAL) ';
|
||||
} else {
|
||||
return ' CAST(' . $this->sql_compare_text($fieldname) . ' AS REAL) ';
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_ceil($fieldname) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user