Minimal change to query generation of FinderMethods#exists? that makes SQLServer and others happy that do not like columns without an alias.
Without this patch MS-SQLServer doesn't like the generated SQL and barks for FinderMethods#exists?, ie:
ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: No column was specified for column 2 of 't'.: SELECT t.* FROM (SELECT ROW_NUMBER() OVER(ORDER BY huhu.id) AS _row_num, 1 FROM huhu WHERE huhu.[id] = 83287) AS t WHERE t._row_num BETWEEN 1 AND 1
Minimal change to query generation of exists? that makes SQLServer an…
…d others happy that do not work without a column alias.
Merge remote-tracking branch 'upstream/master'
+ added test case for sql server issue with exists? and missing alias…
… clause (commit 0eae392)
A test case has been added.
@iaddict out of curiosity, since exists? is extensively tested, does the existent tests break against SQL Server?
This can't be merged automatically.
If you still have this issue, please rebase it and I'll glad to put this is in discussion with the Core Team.
This seems to be recurrent, I've already closed 3 issues explaining the same problem, linked above. Unfortunately this pull request does not apply anymore, as @rafaelfranca pointed, so if you can bring it up-to-date, we can go ahead with it. Thanks
Add test to column alias in `exists?` SQL.
This behavior was added in dd286a4
Fixes #2553, #1141, #1623 and #2062.