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

MSSQL sql_concat_join totally broken

XMLWordPrintable

    • MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • MOODLE_28_STABLE, MOODLE_29_STABLE
    • MDL-49293-master
    • 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

      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.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            David Monllaó David Monllaó
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Rajesh Taneja Rajesh Taneja
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.