Uploaded image for project: 'Doctrine DBAL'
  1. Doctrine DBAL
  2. DBAL-497

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: 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

        shaneneuerburg Shane Neuerburg created issue -
        shaneneuerburg Shane Neuerburg made changes -
        Field Original Value New Value
        Summary SQLServerPlatform modifies limit query incorrectly when field names start with "from" SQLServerPlatform modifies limit query incorrectly when column names start with "from"
        shaneneuerburg Shane Neuerburg made changes -
        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 is 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);
        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 is 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:
        {code}
        $query = preg_replace('/\sFROM/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM", $query);
        {code}
        Becomes this:
        {code}
        $query = preg_replace('/\sFROM\s/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM ", $query);
        {code}
        shaneneuerburg Shane Neuerburg made changes -
        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 is 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:
        {code}
        $query = preg_replace('/\sFROM/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM", $query);
        {code}
        Becomes this:
        {code}
        $query = preg_replace('/\sFROM\s/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM ", $query);
        {code}
        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:
        {code}
        $query = preg_replace('/\sFROM/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM", $query);
        {code}
        Becomes this:
        {code}
        $query = preg_replace('/\sFROM\s/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM ", $query);
        {code}
        beberlei Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.4 [ 10320 ]
        Resolution Fixed [ 1 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: