Skip to content

Conversation

@bpokosh
Copy link

@bpokosh bpokosh commented Apr 19, 2011

I have a query that does a select DISTINCT with multiple columns, like this: select('DISTINCT requests.id, requests.created_at'). This is in combination with an inner join (which is why I need to filter out the duplicates) and a limit and offset (for pagination).

The problem I had was in the Arel visitors. The name of the table had to be substituted with __rnt in the select statement. It was using a sub instead of gsub call so only the first column in the statement was being changed. The other problem was the regular expression in the sub call was looking for the table name surrounded by brackets. Adding the brackets in the select statement fixes this, but I lose compatability with other database (mysql in this case).

I'm having trouble getting the test suite working so I do not have tests with this request, but I'm hoping someone more familiar with the library can tell me if this was a legitimate issue or if I am simply using it wrong.

metaskills added a commit that referenced this pull request Apr 27, 2011
Select DISTINCT with limit and offset problem
@metaskills metaskills merged commit 444da38 into rails-sqlserver:master Apr 27, 2011
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