diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-06-04 11:05:46 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-06-04 11:05:46 +1200 |
commit | e3c26e9926948587efcc8d31c729395093407df6 (patch) | |
tree | 358f418791a56620c32a48776739b4fdf39d3cb0 /activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | |
parent | b9a9b91a3e3b892ab72ff5c618181747d6b4be04 (diff) | |
parent | 8afa725f4b98a6e0ceee4792e8ebaebb6189e5f6 (diff) | |
download | rails-e3c26e9926948587efcc8d31c729395093407df6.tar.gz rails-e3c26e9926948587efcc8d31c729395093407df6.tar.bz2 rails-e3c26e9926948587efcc8d31c729395093407df6.zip |
Merge branch 'master' into patches
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 16d405d3bd..5358491cde 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -106,11 +106,16 @@ module ActiveRecord # SELECT * FROM suppliers LIMIT 10 OFFSET 50 def add_limit_offset!(sql, options) if limit = options[:limit] - sql << " LIMIT #{limit}" + sql << " LIMIT #{sanitize_limit(limit)}" if offset = options[:offset] - sql << " OFFSET #{offset}" + sql << " OFFSET #{offset.to_i}" end end + sql + end + + def sanitize_limit(limit) + limit.to_s[/,/] ? limit.split(',').map{ |i| i.to_i }.join(',') : limit.to_i end # Appends a locking clause to an SQL statement. |