diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-12-14 08:18:05 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-12-14 08:19:47 -0700 |
commit | 4358b0d1f89f5258eec545b2b2d742a12e3eb5bc (patch) | |
tree | 18012b1ebd8a7402aff69a3b34ce720bc1dd7f7d /activerecord/lib/active_record | |
parent | 9a17ce8878d847faf39f3acd329166612fa75042 (diff) | |
download | rails-4358b0d1f89f5258eec545b2b2d742a12e3eb5bc.tar.gz rails-4358b0d1f89f5258eec545b2b2d742a12e3eb5bc.tar.bz2 rails-4358b0d1f89f5258eec545b2b2d742a12e3eb5bc.zip |
Deprecate limit strings with commas
Some backends allow `LIMIT 1,2` as a shorthand for `LIMIT 1 OFFSET 2`.
Supporting this in Active Record massively complicates using bind
parameters for limit and offset, and it's trivially easy to build an
invalid SQL query by also calling `offset` on the same `Relation`.
This is a niche syntax that is only supported by a few adapters, and can
be trivially worked around by calling offset explicitly.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index dbecb842b5..f7115c7a91 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -677,6 +677,12 @@ module ActiveRecord end def limit!(value) # :nodoc: + if ::String === value && value.include?(",") + ActiveSupport::Deprecation.warn(<<-WARNING) + Passing a string to limit in the form "1,2" is deprecated and will be + removed in Rails 5.1. Please call `offset` explicitly instead. + WARNING + end self.limit_value = value self end |