rails/rails — Issue #4409: Possible ActiveRecord regression since 3.0
Author: denisj
Created: 2012-01-11 12:00:14+00:00
State: open

I have sometime parameters like that

```
{ :offset => "150" }
```
sending after a javascript action. So when I try to create a sql query

```ruby
sql_query = Blog.send(:construct_finder_arel, { :offset => "150" }).to_sql
Blog.connection.select_values(sql_query)
```
I get

```
ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''150'' at line 1: SELECT `blogs`.* FROM `blogs` LIMIT 10 OFFSET '150'
```
because contrary to active_record 2.3, "offset" is not transformed into Fixnum.
In lib/active_record/connection_adapters/abstract/database_statements.rb line 201

```ruby
def add_limit_offset!(sql, options)
if limit = options[:limit]
sql << " LIMIT #{sanitize_limit(limit)}"
if offset = options[:offset]
sql << " OFFSET #{offset.to_i}"
end
end
sql
end
```
In active_record 3.0, lib/active_record/relation/query_methods.rb line 183

```ruby
arel = arel.skip(@offset_value) if @offset_value
```
This regression (if it is) seems to be in all versions since rails 3.0.