aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/integer.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.Ryuta Kamizono2014-12-121-1/+5
|
* Fix out of range error messageRyuta Kamizono2014-11-251-1/+1
|
* Speed up integer casting from DBSean Griffin2014-11-181-0/+5
| | | | | | | | We don't have the check the range when the value is coming from the DB, so override type_cast_from_database to short-circuit the extra work. The difference is huge but the absolute gain is quite small. That being said this is a hotspot and it showed up on the radar when benchmarking discourse.
* Revert "[PERF] Speed up integer type casting from DB"Godfrey Chan2014-11-171-4/+1
| | | | | | This reverts commit 6f7910a and 52c70d4. Query params are type cased through the same method, so this approach doesn't work.
* :nail_care: Put escape clause first, keeps @sgrif happy :grin:Godfrey Chan2014-11-171-1/+2
| | | | See comment on 6f7910a
* [PERF] Speed up integer type casting from DBGodfrey Chan2014-11-171-1/+3
| | | | | | | | | | | | | | | | | | | We don't have the check the range when the value is coming from the DB, so override type_cast_from_database to short-circuit the extra work. type_cast_from_database (small) 3437507.5 (±29.2%) i/s - 14223135 in 4.996973s type_cast_from_database (large) 3158588.7 (±28.3%) i/s - 13265628 in 4.992121s type_cast (small) 481984.8 (±14.2%) i/s - 2352012 in 5.005694s type_cast (large) 477331.8 (±14.2%) i/s - 2332824 in 5.012365s Comparison: type_cast_from_database (small): 3437507.5 i/s type_cast_from_database (large): 3158588.7 i/s - 1.09x slower type_cast (small): 481984.8 i/s - 7.13x slower type_cast (large): 477331.8 i/s - 7.20x slower The difference is huge but the absolute gain is quite small. That being said this is a hotspot and it showed up on the radar when benchmarking discourse.
* Use the correct values for int max and minSean Griffin2014-10-311-9/+13
| | | | | We had accidentally gone one power of two too far. In addition, we need to handle minimum values as well as the maximum.
* Treat strings greater than int max value as out of rangeSean Griffin2014-10-311-1/+20
| | | | | | | | | | | Sufficiently large integers cause `find` and `find_by` to raise `StatementInvalid` instead of `RecordNotFound` or just returning `nil`. Given that we can't cast to `nil` for `Integer` like we would with junk data for other types, we raise a `RangeError` instead, and rescue in places where it would be highly unexpected to get an exception from casting. Fixes #17380
* Removed unused `klass` definitions from typesSean Griffin2014-06-061-4/+0
| | | | Only `Date` and `Time` are handled.
* Move types to the top level `ActiveRecord` namespaceSean Griffin2014-05-271-0/+27
`ActiveRecord::ConnectionAdapters::Type::Value` => `ActiveRecord::Type::Value`