Skip to content

Commit

Permalink
fix activerecord query_method regression with offset into Fixnum
Browse files Browse the repository at this point in the history
add test to show offset query_methods on mysql & mysql2

change test to cover public API
  • Loading branch information
denisj authored and arunagw committed Mar 13, 2012
1 parent 5f26ce6 commit f67944e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -270,7 +270,7 @@ def build_arel
arel.having(*@having_values.uniq.reject{|h| h.blank?}) unless @having_values.empty?

arel.take(connection.sanitize_limit(@limit_value)) if @limit_value
arel.skip(@offset_value) if @offset_value
arel.skip(@offset_value.to_i) if @offset_value

arel.group(*@group_values.uniq.reject{|g| g.blank?}) unless @group_values.empty?

Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/finder_test.rb
Expand Up @@ -1204,6 +1204,10 @@ def test_find_one_message_with_custom_primary_key
end
end

def test_finder_with_offset_string
assert_nothing_raised(ActiveRecord::StatementInvalid) { Topic.find(:all, :offset => "3") }
end

protected
def bind(statement, *vars)
if vars.first.is_a?(Hash)
Expand Down

0 comments on commit f67944e

Please sign in to comment.