diff options
| author | Sean Griffin <sean@seantheprogrammer.com> | 2015-12-14 08:34:14 -0700 |
|---|---|---|
| committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-15 10:15:24 +0100 |
| commit | af3dc42ee357a8f70148c9dc9572276a9824aeec (patch) | |
| tree | 71e4a043ffe26af38effac2881ca1909987d17a7 /activemodel/lib | |
| parent | e12c2a6d11a9ebc28b85f34230b11fb654503726 (diff) | |
| download | rails-af3dc42ee357a8f70148c9dc9572276a9824aeec.tar.gz rails-af3dc42ee357a8f70148c9dc9572276a9824aeec.tar.bz2 rails-af3dc42ee357a8f70148c9dc9572276a9824aeec.zip | |
Use a bind param for `LIMIT` and `OFFSET`
We currently generate an unbounded number of prepared statements when
`limit` or `offset` are called with a dynamic argument. This changes
`LIMIT` and `OFFSET` to use bind params, eliminating the problem.
`Type::Value#hash` needed to be implemented, as it turns out we busted
the query cache if the type object used wasn't exactly the same object.
This drops support for passing an `Arel::Nodes::SqlLiteral` to `limit`.
Doing this relied on AR internals, and was never officially supported
usage.
Fixes #22250.
Diffstat (limited to 'activemodel/lib')
| -rw-r--r-- | activemodel/lib/active_model/type/value.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/type/value.rb b/activemodel/lib/active_model/type/value.rb index 5fea0561a6..9d1f267b41 100644 --- a/activemodel/lib/active_model/type/value.rb +++ b/activemodel/lib/active_model/type/value.rb @@ -90,6 +90,11 @@ module ActiveModel scale == other.scale && limit == other.limit end + alias eql? == + + def hash + [self.class, precision, scale, limit].hash + end def assert_valid_value(*) end |
