Skip to content

Commit 8f3ad09

Browse files
committed
Use a lazy match in add_order_by_for_association_limiting! to allow sub selects to be used. Resolves ticket #11
1 parent 8f636ef commit 8f3ad09

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
MASTER
33

4+
* Use a lazy match in add_order_by_for_association_limiting! to allow sub selects to be used. Resolves
5+
ticket #11.
6+
47
* Add default rake task back for testing. Runs the namespaced sqlserver:test_sqlserver_odbc.
58
Resolves ticket #10 [Ken Collins]
69

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def add_order_by_for_association_limiting!(sql, options)
698698
# Disertation http://gist.github.com/24073
699699
# Information http://weblogs.sqlteam.com/jeffs/archive/2007/12/13/select-distinct-order-by-error.aspx
700700
return sql if options[:order].blank?
701-
columns = sql.match(/SELECT\s+DISTINCT(.*)FROM/)[1].strip
701+
columns = sql.match(/SELECT\s+DISTINCT(.*?)FROM/)[1].strip
702702
sql.sub!(/SELECT\s+DISTINCT/,'SELECT')
703703
sql << "GROUP BY #{columns} ORDER BY #{order_to_min_set(options[:order])}"
704704
end

0 commit comments

Comments
 (0)