diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-01-22 14:20:01 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-02-23 12:47:30 +0100 |
commit | 91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3 (patch) | |
tree | 38baccfd5b5275cbb2636bee15da82691dd6d521 /activerecord/lib/active_record/connection_adapters | |
parent | 4cb47167e747e8f9dc12b0ddaf82bdb68c03e032 (diff) | |
download | rails-91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3.tar.gz rails-91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3.tar.bz2 rails-91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3.zip |
deprecate support for pg ranges with excluding beginnings.
The Ruby Range object does not support excluding beginnings.
We currently support excluding beginnings for some subtypes using
manually by incrementing them (now using the `#succ` method).
This is approach is flawed as it's not equal to an excluding beginning.
This commit deprecates the current support for excluding beginnings.
It also raises an `ArgumentError` for subtypes that do not implement the `succ`
method.
This is a temporary solution to get rid of the broken state. We might still
add complete support for excluding beginnings afterwards. (Probably with a
new `PGRange` object, which acts like a `Range` but has excluding beginnings.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb index 32f86bf01c..6f9b60b6c4 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb @@ -135,6 +135,18 @@ module ActiveRecord extracted = extract_bounds(value) from = type_cast_single extracted[:from] to = type_cast_single extracted[:to] + + if !infinity?(from) && extracted[:exclude_start] + if from.respond_to?(:succ) + from = from.succ + ActiveSupport::Deprecation.warn <<-MESSAGE +Excluding the beginning of a Range is only partialy supported through `#succ`. +This is not reliable and will be removed in the future. + MESSAGE + else + raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')" + end + end ::Range.new(from, to, extracted[:exclude_end]) end end |