Commit d64fcb4
committed
Pass AR tests by moving DISTINCT to GROUP BY in windowed SQL.
* Tests now passing.
test_count_eager_with_has_many_and_limit_and_high_offset
test_eager_with_has_many_and_limit_and_high_offset
* SQL like this:
SELECT DISTINCT TOP (2) [__rnt].id
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [posts].[id] ASC) AS [__rn], [posts].id
FROM [posts]
LEFT OUTER JOIN [authors] ON [authors].[id] = [posts].[author_id]
LEFT OUTER JOIN [comments] ON [comments].[post_id] = [posts].[id]
WHERE (authors.name = N'David')
) AS [__rnt]
WHERE [__rnt].[__rn] > (10)
Now like this:
SELECT TOP (2) [__rnt].id
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [posts].[id] ASC) AS [__rn], [posts].id
FROM [posts]
LEFT OUTER JOIN [authors] ON [authors].[id] = [posts].[author_id]
LEFT OUTER JOIN [comments] ON [comments].[post_id] = [posts].[id]
WHERE (authors.name = N'David')
GROUP BY [posts].id
) AS [__rnt]
WHERE [__rnt].[__rn] > (10)1 parent e10adcd commit d64fcb4
File tree
3 files changed
+25
-3
lines changed- lib/arel/visitors
- test/cases
3 files changed
+25
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
2 | 9 | | |
3 | 10 | | |
4 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
165 | | - | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
| |||
316 | 321 | | |
317 | 322 | | |
318 | 323 | | |
319 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
320 | 335 | | |
321 | 336 | | |
322 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
0 commit comments