Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-49293

MSSQL sql_concat_join totally broken

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Run unit tests (for ALL DB drivers, specifically for the 2 SQL*Server ones, aka mssql and sqlsrv):
      vendor/bin/phpunit --filter test_concat_join

      Show
      Run unit tests (for ALL DB drivers, specifically for the 2 SQL*Server ones, aka mssql and sqlsrv): vendor/bin/phpunit --filter test_concat_join
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-49293-master

      Description

      We have a major flaw in our mssql sql_concat_join function.

      This works as expected:
      SELECT 'X' + '-' + 'Y';
      == Expected result: XY
      == Actual result: XY

      However, this does not:
      SELECT 1 + '-' + 2;
      == Expected result: 1-2
      == Actual result: 3

      We should be using the CONCAT() function:
      SELECT CONCAT(1, '-', 2);
      == Expected result: 1-2
      == Actual result: 1-2

      Unless we cast the integer to a string in this issue somehow (and we don't have a DML function to cast from int to string), then the fix for this is to actually CONCAT things in the CONCAT function. A pretty big change.

      Thankfully the only uses of this are in the unit tests.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Sep/15