Skip to content

Commit b689b03

Browse files
committed
[Rails5] Patch up exists? distinct 1 as one queries.
1 parent a7860cc commit b689b03

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/arel/visitors/sqlserver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def distinct_One_As_One_Is_So_Not_Fetch o
170170
core = o.cores.first
171171
distinct = Nodes::Distinct === core.set_quantifier
172172
oneasone = core.projections.all? { |x| x == ActiveRecord::FinderMethods::ONE_AS_ONE }
173-
limitone = node_value(o.limit) == 1
173+
limitone = [nil, 0, 1].include? node_value(o.limit)
174174
if distinct && oneasone && limitone && !o.offset
175175
core.projections = [Arel.sql("TOP(1) 1 AS [one]")]
176176
o.limit = nil

0 commit comments

Comments
 (0)