Skip to content

Commit e429ecc

Browse files
committed
The number of rows provided for a FETCH clause must be greater then zero
67 failures, 29 errors, 2 skips
1 parent fbd8a6e commit e429ecc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/arel/visitors/sqlserver.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def visit_Orders_And_Let_Fetch_Happen o, collector
115115
end
116116

117117
def visit_Make_Fetch_Happen o, collector
118+
if o.limit
119+
value = case o.limit.expr
120+
when Numeric then o.limit.expr
121+
when Arel::Nodes::Unary then o.limit.expr.expr
122+
end
123+
o.limit = nil if value == 0
124+
end
118125
o.offset = Nodes::Offset.new(0) if o.limit && !o.offset
119126
collector = visit o.offset, collector if o.offset
120127
collector = visit o.limit, collector if o.limit

0 commit comments

Comments
 (0)