Fix FinderMethods#exists? sql generation to make picky sql servers happy #1139

Closed
wants to merge 6 commits into
from

Projects

None yet

4 participants

@iaddict
iaddict commented May 19, 2011

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

@iaddict
iaddict commented Aug 17, 2011

A test case has been added.

@mhfs
mhfs commented Feb 28, 2012

@iaddict out of curiosity, since exists? is extensively tested, does the existent tests break against SQL Server?

@rafaelfranca
Member

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.

@carlosantoniodasilva

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

@rafaelfranca rafaelfranca added a commit that closed this pull request Jun 10, 2012
@rafaelfranca rafaelfranca Add test to column alias in `exists?` SQL.
This behavior was added in dd286a4

Closes #1139.

Fixes #2553, #1141, #1623 and #2062.
179276e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment