mirror of https://github.com/rails/rails
remove deprecated support for PG ranges with exclusive lower bounds.
addresses 91949e48cf (commitcomment-9144563)
This commit is contained in:
parent
5cc08e1977
commit
a076256d63
|
@ -1,3 +1,7 @@
|
|||
* Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
|
||||
|
||||
*Yves Senn*
|
||||
|
||||
* Remove deprecation when modifying a relation with cached arel.
|
||||
This raises an `ImmutableRelation` error instead.
|
||||
|
||||
|
|
|
@ -25,16 +25,7 @@ module ActiveRecord
|
|||
to = type_cast_single extracted[:to]
|
||||
|
||||
if !infinity?(from) && extracted[:exclude_start]
|
||||
if from.respond_to?(:succ)
|
||||
from = from.succ
|
||||
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
||||
Excluding the beginning of a Range is only partialy supported
|
||||
through `#succ`. This is not reliable and will be removed in
|
||||
the future.
|
||||
MSG
|
||||
else
|
||||
raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')"
|
||||
end
|
||||
raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')"
|
||||
end
|
||||
::Range.new(from, to, extracted[:exclude_end])
|
||||
end
|
||||
|
|
|
@ -230,36 +230,14 @@ _SQL
|
|||
assert_nil_round_trip(@first_range, :int8_range, 39999...39999)
|
||||
end
|
||||
|
||||
def test_exclude_beginning_for_subtypes_with_succ_method_is_deprecated
|
||||
tz = ::ActiveRecord::Base.default_timezone
|
||||
|
||||
silence_warnings {
|
||||
assert_deprecated {
|
||||
range = PostgresqlRange.create!(date_range: "(''2012-01-02'', ''2012-01-04'']")
|
||||
assert_equal Date.new(2012, 1, 3)..Date.new(2012, 1, 4), range.date_range
|
||||
}
|
||||
assert_deprecated {
|
||||
range = PostgresqlRange.create!(ts_range: "(''2010-01-01 14:30'', ''2011-01-01 14:30'']")
|
||||
assert_equal Time.send(tz, 2010, 1, 1, 14, 30, 1)..Time.send(tz, 2011, 1, 1, 14, 30, 0), range.ts_range
|
||||
}
|
||||
assert_deprecated {
|
||||
range = PostgresqlRange.create!(tstz_range: "(''2010-01-01 14:30:00+05'', ''2011-01-01 14:30:00-03'']")
|
||||
assert_equal Time.parse('2010-01-01 09:30:01 UTC')..Time.parse('2011-01-01 17:30:00 UTC'), range.tstz_range
|
||||
}
|
||||
assert_deprecated {
|
||||
range = PostgresqlRange.create!(int4_range: "(1, 10]")
|
||||
assert_equal 2..10, range.int4_range
|
||||
}
|
||||
assert_deprecated {
|
||||
range = PostgresqlRange.create!(int8_range: "(10, 100]")
|
||||
assert_equal 11..100, range.int8_range
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_exclude_beginning_for_subtypes_without_succ_method_is_not_supported
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(num_range: "(0.1, 0.2]") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(float_range: "(0.5, 0.7]") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(int4_range: "(1, 10]") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(int8_range: "(10, 100]") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(date_range: "(''2012-01-02'', ''2012-01-04'']") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(ts_range: "(''2010-01-01 14:30'', ''2011-01-01 14:30'']") }
|
||||
assert_raises(ArgumentError) { PostgresqlRange.create!(tstz_range: "(''2010-01-01 14:30:00+05'', ''2011-01-01 14:30:00-03'']") }
|
||||
end
|
||||
|
||||
def test_update_all_with_ranges
|
||||
|
|
Loading…
Reference in New Issue