Skip to content

Conversation

@nickveys
Copy link

Issue #306, and PR #329 broke compatibility with a couple of queries we were using. Two regressions were introduced.

First, if the COUNT(DISTINCT) had an alias applied to it, the alias would be used in the PARTITION BY value expression, which was invalid SQL, according to the Transact-SQL docs it cannot use aliases.

Second, if the query (already having a COUNT(DISTINCT) and order clause) itself used a select call like this:

Model.select('COUNT(DISTINCT)...')
     .select('something as x, something_else as y')
     ....
     .order(:something)

the outer select would lose some of the aliased columns due to the regex used when stripping out the aliases into select_frags.

Added a test to verify this, the issues are intertwined so it's just one test.

Thanks for the great gem!

@metaskills
Copy link
Member

Closing this PR since it can not be applied to master now due to the 4.2 work.

http://metaskills.net/2015/01/25/activerecord-sqlserver-v4.2.0---code-name-kantishna/

Perhaps you can help solve some of these remaining issues instead. https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/milestones/4-2-stable

@metaskills metaskills closed this Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants