Skip to content
This repository

ActiveRecord: .exists? generates invalid SQL for MSSQL #1623

Closed
arkadiyk opened this Issue · 6 comments

4 participants

arkadiy kraportov Carlos Antonio da Silva georgiev Brooke M. Fujita
arkadiy kraportov
 relation = relation.except(:select).select("1").limit(1)

The problem with MSSQL is a column has to have a name. Would it be possible to add a name? Something like this:

 relation = relation.except(:select).select("1 as _one").limit(1)

Thank you

georgiev

+1 - same break/same fix for Firebird

Brooke M. Fujita

+1 Hey, we are still stuck with Rails 3.0.6 because this issue is still pending... Any word on when we might see this fix?

georgiev

One word of caution here - "_one" is not a valid Firebird column name - extra attention should be payed when choosing the column name.

arkadiy kraportov

let's make it "one" or "o". As long as the column has a name MS SQL should be happy.

arkadiy kraportov

opened a pull request for that: #2062

Carlos Antonio da Silva carlosantoniodasilva closed this
Carlos Antonio da Silva

Closing this issue in favor of pull request #2062 and #1139. Thanks!

Rafael Mendonça França rafaelfranca referenced this issue from a commit
Rafael Mendonça França Add test to column alias in `exists?` SQL.
This behavior was added in dd286a4

Closes #1139.

Fixes #2553, #1141, #1623 and #2062.
179276e
Rafael Mendonça França rafaelfranca referenced this issue from a commit
Rafael Mendonça França Add test to column alias in `exists?` SQL.
This behavior was added in be4ecdc.

Closes #1139.

Fixes #2553, #1141, #1623 and #2062.
6cc5e9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.