[DBAL-497] SQLServerPlatform modifies limit query incorrectly when column names start with "from" Created: 18/Apr/13  Updated: 20/Apr/13  Resolved: 20/Apr/13

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.3.3
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Shane Neuerburg Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: sqlserver
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);


 Comments   
Comment by Shane Neuerburg [ 18/Apr/13 ]

Pull request:
https://github.com/doctrine/dbal/pull/306

Generated at Wed Sep 03 04:56:22 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.