`#first_or_initialize` does not use attributes to data acquisition.
Therefore, there is a possibility of updating the different record than the one
specified in the key, I think this is not expected behavior.
To suppress warning ('warning: method redefined; discarding old sum')
remove the method before override it.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
If run the test over the `rake` command, because of the test patterns is passed
via `rake_run` method, do not need to be obtained from the argv.
This probably fixes#24372.
There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
- Rename max to statement_limit
- Remove magic number 1000 from everywhere
- Defined StatementPool::DEFAULT_STATEMENT_LIMIT and started using it everywhere
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Awaken waiting threads even if the current thread (the previously
exclusive thread) hadn't taken a share lock.
This only happens in code that wasn't run within an executor, since that
always take an outermost share lock.
Make sure we handle explicitly passed nil's to lock_version as well.
An explicitly passed nil value is now converted to 0 on LockingType,
so that we don't end up with ActiveRecord::StaleObjectError in update record
optimistic locking
Fixes#24695
Previously these methods could return either a DateTime or a Time
depending on how the ActiveSupport::TimeWithZone instance had
been constructed. Changing to always return an instance of Time
eliminates a possible stack level too deep error in to_time where
it was wrapping a DateTime instance.
As a consequence of this the internal time value is now always an
instance of Time in the UTC timezone, whether that's as the UTC
time directly or a representation of the local time in the timezone.
There should be no consequences of this internal change and if
there are it's a bug due to leaky abstractions.
`DateTime#getlocal` is newly added public API.
It's responsible is same as `DateTime#utc`, so `calculations.rb` is
a best plase to define this method.
For keeping consistency with `DateTime#utc`, defines `#localtime` and
defines `getlocal` as an alias method.
In Ruby 2.4 the `to_time` method for both `DateTime` and `Time` will
preserve the timezone of the receiver when converting to an instance
of `Time`. Since Rails 5.0 will support Ruby 2.2, 2.3 and later we
need to introduce a compatibility layer so that apps that upgrade do
not break. New apps will have a config initializer file that defaults
to match the new Ruby 2.4 behavior going forward.
For information about the changes to Ruby see:
https://bugs.ruby-lang.org/issues/12189https://bugs.ruby-lang.org/issues/12271Fixes#24617.