-
Bug
-
Resolution: Won't Fix
-
Critical
-
None
-
1.9.10
-
Windows
-
Microsoft SQL
-
MOODLE_19_STABLE
When updating a bigint type value on a mssql table,the update_record function incorrectly en quotes the value to be updated. Mssql doesn't supports quotes for these numeric types.
REPRODUCE:
Update any field that is of type bigint on a mssql table, setting a number with decimal point.
(When I was trying to upgrade from moodle 1.7 to 1.9, one of the queries moodle runs is something like this:
UPDATE mdl_scorm SET course = '690',name = N'Segunda Prueba de un paquete SCORM', whatgrade = '0.1' WHERE id = 10
But because whatgrade column is of type bigint, and moodle is putting quotes to the value, Mssql gives an error:
"Error converting data type varchar to bigint." thinking one is trying to insert a character in the decimal point.
So, when I take off the quotes, it runs perfectly
UPDATE mdl_scorm SET course = '690',name = N'Segunda Prueba de un paquete SCORM', whatgrade = 0.1 WHERE id = 10
I've tested with other similar types(float,numeric,double) and it doesn't happens.
I have the solution, just around line 1695 in /lib/dmllib.php:
} else if (is_float($value) and ($column->type == 'bigint')) {
//can't cast, DB specific types and php types might be different or not supported ie: decimal, bigint,double
//above is_float(), its enough to validate its sanitized.
$update[] = "$key = $value";//mssql doesn't allows '' on bigint for example
} else {
Thanks.
PS: I would like to push my code to your server what do I need to do. I'd like to be a core developer.
I see i should not push to github cus your original files are on cvs right?
How can I collaborate? I have a lot of bug fixes since moodle 1.7 although it is not supported anymore, but now Im migrating to 1.9 and want to contribute to everything i find, as the one above.
thanks again.