Select DISTINCT with limit and offset problem #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.