We prepend a check against the thread-local level to Logger#add, but because it proceeds to check against the thread-global level, only setting a quieter thread-local level works. The quietest of the two wins. Fix by reimplementing #add entirely.
It's unfortunate to have to do this, but I've already patched upstream Logger to prefer the level instance method over the @level instance variable, so we'll be able to avoid touching #add at all in the future. See https://github.com/ruby/logger/pull/41.
Previously in some places we used symbol keys, and in some places we used
string keys. That made it pretty confusing to figure out in a particular
place what type of configuration object you were working with.
Now internally, all configuration hashes are keyed by symbols and
converted to such on the way in.
A few exceptions:
- `DatabaseConfigurations#to_h` still returns strings for backward compatibility
- Same for `legacy_hash`
- `default_hash` previously could return strings, but the associated
comment mentions it returns symbol-key `Hash` and now it always does
Because this is a change in behavior, a few method renames have happened:
- `DatabaseConfig#config` is now `DatabaseConfig#configuration_hash` and returns a symbol-key `Hash`
- `ConnectionSpecification#config` is now `ConnectionSpecification#underlying_configuration_hash` and returns the `Hash` of the underlying `DatabaseConfig`
- `DatabaseConfig#config` was added back, returns `String`-keys for backward compatibility, and is deprecated in favor of the new `configuration_hash`
Co-authored-by: eileencodes <eileencodes@gmail.com>
In 7254d23764, an autoload for
`ConnectionAdapters::AbstractAdapter` was added to `active_record.rb`.
Later in d6b923adbd, a manual require for
that class was added to `active_record/base.rb` as some constants under
`ConnectionAdapters` weren't defined until `AbstractAdapter` was loaded.
In 1efd88283e, the require was removed and
replaced with an autoload in `active_record.rb`, above the previous one.
Because the first autoload was for the `ConnectionAdapters` constant and
the second one tried to create it, the autoload would fire immediately.
Rather than fixing the autoload problem, the require had effectively
just been moved from `active_record/base.rb` to `active_record.rb`.
Instead of defining autoloads for constants under `ConnectionAdapters`
in the `abstract_adapter.rb` file, we can create a separate, autoloaded
`connection_adapters.rb` file for this purpose.
To avoid a "circular require considered harmful" warning from Ruby, we
have to fix the module nesting in `schema_creation.rb`, as a followup to
e4108fc619.
`AbstractAdapter` loads many other dependencies, so making it autoload
properly has a noticeable impact on the load time of `active_record.rb`.
Benchmark:
$ cat test.rb
require "bundler/setup"
before = ObjectSpace.each_object(Module).count
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
require "active_record"
finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
after = ObjectSpace.each_object(Module).count
puts "took #{finish - start} and created #{after - before} modules"
Before:
$ ruby test.rb
took 0.47532399999909103 and created 901 modules
After:
$ ruby test.rb
took 0.3299509999342263 and created 608 modules
When this case was his previously, an error would be thrown like:
`<NoMethodError: "undefined method config for...">` because we were
erroneously calling `config` on a `Hash`.
This commit adds a test for this case, and fixes the hash access.
These tests are causing the Ruby master build to fail in CI. The Docker
image we use is based on Ubuntu Bionic which provides SQLite 3.22.0, and
the features required to use `insert_all` and `upsert_all` are not
available in that version.
Current Ruby 2.7 implementation behaves differently from 2.6 (by design)
where receiving an empty keyword arguments.
Thus, for now we need this if branch everywhere we're asserting such a method call
in order for the CI to pass.
We could revert this workaround if Ruby 2.7 decides to revert back to the 2.6 behavior,
or maybe we'll need to fix Minitest::Mock once the 2.7 spec became stable.
Before this patch, column names could only be passed as a positional
argument when no other options were supplied:
remove_index :reports, :report_id
Passing column names positionally along with other options would fail:
remove_index :reports, :report_id, unique: true
# => ArgumentError: wrong number of arguments (given 3, expected 1..2)
In 3809c80cd5, adding an index with a
name that's already in use was changed from an error to a warning, to
allow other statements in the same migration to complete successfully.
In 55d0d57bfc this decision was reversed,
but instead of allowing the statement to execute and raise an adapter-
specific error as it did before, an `ArgumentError` was raised instead.
This interferes with a legitimate use case: on MySQL, it's possible to
drop an index and add another one with the same name in a single `ALTER`
statement. Right now an `ArgumentError` is raised when trying to do so,
even though the resulting statement would execute successfully.
There's no corresponding `ArgumentError` raised when attempting to add a
duplicate column, so I think we can safely remove the check and allow
the adapter to raise its own error about duplicate indexes again.
This commit allows ActiveJob to serialize classes and modules without a custom serializer. This allows for workflows like:
```
class EmailJob < ApplicationJob
queue_as :default
def perform(template_class, *arguments)
template_class.new(*arguments).send!
end
end
module Email
class FooTemplate ... end
class BarTemplate ... end
end
EmailJob.perform_later(Email::FooTemplate, ...)
EmailJob.perform_later(Email::BarTemplate, ...)
```
Currently this is only achieveable through a custom serializer or through constantizing in each instance.
`OptimizedFileSystemResolver` builds a regular expression to match view
template paths. Prior to this patch, only file globbing special
characters were escaped when building this regular expression, leaving
other regular expression special characters unescaped.
This patch properly escapes all regular expression special characters,
and adds test coverage for paths that include these characters.
Fixes#37107.
* boot when there is folders to watch
* raise argument error when paths are empty
* add space between curly braces
* Revert "add space between curly braces"
This reverts commit 90cff20c87.
* Revert "raise argument error when paths are empty"
This reverts commit 349adff0f5.
* stop lazy loading listem gem
* back with any?
* require listen gem at top of the file
* improve
* remove scope resolution operator
The `InsertAll` class currently calls `exec_query`, which doesn't give
the query cache enough information to know that it needs to be cleared.
By adding an `exec_insert_all` method that calls `exec_query` internally
we can configure the query cache to clear when that method is called.