Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-497

SQLServerPlatform modifies limit query incorrectly when column names start with "from"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.4
    • Component/s: Platforms
    • Security Level: All
    • Labels:
    • Environment:
      OS X using FreeTDS driver, unixODBC
      SQL Server 2008

      Description

      I am working with a table that has columns that start with the word "from" (fromNumber, fromCity, etc). When SQLServerPlatform->doModifyLimitQuery is called, "from" in the names are incorrectly replaced. I suggest adding a whitespace requirement after FROM in the preg_replace on this line:
      https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L848

      So this:

      $query = preg_replace('/\sFROM/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM", $query);
      

      Becomes this:

      $query = preg_replace('/\sFROM\s/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM ", $query);
      

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Shane Neuerburg
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: