MDL-25276 dml - fix/implement sql_cast2int/real() across the 5 drivers. Tests passing.

This commit is contained in:
Eloy Lafuente 2010-11-18 01:27:49 +00:00
parent a018adf038
commit 9882b2c824
4 changed files with 38 additions and 2 deletions

View File

@ -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) {

View File

@ -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.
*

View File

@ -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.
*

View File

@ -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) {