Affects Version/s: 1.2.1
Fix Version/s: None
I have a Doctrine model which connects to a MSSQL database. I was trying to run the following query:
The code failed with a SQL Syntax exception so I took a look at the generated query and found the following (SELECT fields shortened for readabilty):
As you can see, the ORDER BY clauses on the inner_tbl and outer_tbl segments have AS clauses which do not belong there. If you fix the ORDER BY statements the query runs just fine.
So I decided to prod around the Mssql.php connection class and found the following:
Line 171 seems to be in charge of setting up the orderBy aliases but it is looking for a lower case ' as ' string which doesn't exist in this SQL expression. Changing that to a case insensitive regular expression search seems to fix the problem:
Here is the resulting SQL with the change:
This seems to fix the problem but I don't know if it'll create a regression. It's a start though. Anyone have any thoughts on this?