Moodle
  1. Moodle
  2. MDL-26374

When updating a bigint type value on a mssql table,the update_record function incorrectly quotes the value to be updated.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.10
    • Fix Version/s: None
    • Component/s: Database SQL/XMLDB
    • Environment:
      Windows
    • Database:
      Microsoft SQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      15966

      Description

      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.

        Activity

        Gabriel Rod created issue -
        Gabriel Rod made changes -
        Field Original Value New Value
        Summary When updating a bigint(and other numerics) type value on a mssql table,the update_record function incorrectly en quotes the value to be updated. When updating a bigint type value on a mssql table,the update_record function incorrectly quotes the value to be updated.
        Hide
        Gabriel Rod added a comment -

        skodak, I added you as watcher, sory if it bothered you, Im just so happy to contribute to moodle now, Ive been developing since 1.7 but I have never contributed.

        Show
        Gabriel Rod added a comment - skodak, I added you as watcher, sory if it bothered you, Im just so happy to contribute to moodle now, Ive been developing since 1.7 but I have never contributed.
        Hide
        Gabriel Rod added a comment -

        here is the example error

        Show
        Gabriel Rod added a comment - here is the example error
        Gabriel Rod made changes -
        Attachment screenshot-1.jpg [ 23002 ]
        Petr Škoda made changes -
        Assignee Michael Ketcham [ msketcham ] moodle.com [ moodle.com ]
        Security Could be a security issue [ 10030 ]
        Fix Version/s STABLE backlog [ 10463 ]
        Hide
        Petr Škoda added a comment -

        This should be already fixed in 2.0, if somebody create a fix for 1.9.x it will be most probably included in official distribution.

        Thanks for the report.

        Show
        Petr Škoda added a comment - This should be already fixed in 2.0, if somebody create a fix for 1.9.x it will be most probably included in official distribution. Thanks for the report.
        Martin Dougiamas made changes -
        Workflow MDL Workflow [ 67667 ] MDL Full Workflow [ 75858 ]
        Hide
        Dan Poltawski added a comment -

        Hi,

        We are no longer support 1.9.x for general bugfixes, I am closing this issue. This should be reolved in 2.0

        Show
        Dan Poltawski added a comment - Hi, We are no longer support 1.9.x for general bugfixes, I am closing this issue. This should be reolved in 2.0
        Dan Poltawski made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s STABLE backlog [ 10463 ]
        Resolution Won't Fix [ 2 ]
        Michael de Raadt made changes -
        Component/s Database SQL/XMLDB [ 10131 ]
        Component/s Database MS SQL [ 10633 ]

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: