aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/value.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-14 08:34:14 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-12-14 08:40:02 -0700
commit574f255629a45cd67babcfb9bb8e163e091a53b8 (patch)
treeb940dcbf4f04b96c05f66691c73187fcfe46105d /activemodel/lib/active_model/type/value.rb
parent4358b0d1f89f5258eec545b2b2d742a12e3eb5bc (diff)
downloadrails-574f255629a45cd67babcfb9bb8e163e091a53b8.tar.gz
rails-574f255629a45cd67babcfb9bb8e163e091a53b8.tar.bz2
rails-574f255629a45cd67babcfb9bb8e163e091a53b8.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/active_model/type/value.rb')
-rw-r--r--activemodel/lib/active_model/type/value.rb5
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