-
Bug
-
Resolution: Fixed
-
Critical
-
2.3.6, 2.4.3, 2.5
-
MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
-
MOODLE_24_STABLE, MOODLE_25_STABLE
-
master_
MDL-39572 -
- Run phpunit tests in ALL supported databases.
The arguments used in the MSSQL version of sql_order_by_text() appear to be incorrect. In current master:
public function sql_order_by_text($fieldname, $numchars=32) {
|
return ' CONVERT(varchar, ' . $fieldname . ', ' . $numchars . ')';
|
}
|
But according to these docs: http://msdn.microsoft.com/en-us/library/ms187928.aspx
The CONVERT function accepts length as part of the 1st argument and the 3rd argument is used for date and time styles.
The result that this function is always converting text fields using the MSSQL default length of 30 characters.
Steps to reproduce
- Install a new site on MSSQL.
- Add the test.php file (attached to this bug) to the root code folder.
- Visit [site-url]/test.php in a web browser.
Expected behaviour
The script would output:
Without using sql_order_by_text(): 123456789a123456789b123456789c123456789d
|
With sql_order_by_text() default length: 123456789a123456789b123456789c12
|
With sql_order_by_text() 35 char length: 123456789a123456789b123456789c12345
|
Actual behaviour
The script outputs:
Without using sql_order_by_text(): 123456789a123456789b123456789c123456789d
|
With sql_order_by_text() default length: 123456789a123456789b123456789c
|
With sql_order_by_text() 35 char length: 123456789a123456789b123456789c
|
e.g. the default length is incorrect (30 instead of 32 characters) and changing the length has no effect.
- Discovered while testing
-
MDLSITE-2398 Detect assertions in methods not named test*
-
- Open
-