| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
* Introduce `falsey` to represent both `nil` and `false`.
* Keep consistent order between abstract description and examples.
|
|\
| |
| | |
Update documentation to ActionController::ConditionalGet
|
| |
| |
| |
| | |
Two implemented but undocumented features are to help indicate that cache is fresh for 3 hours, and it may continue to be served stale for up to an additional 60 seconds to parallel requests for the same resource or up to 5 minutes while errors are being returned back while the initial synchronous revalidation is attempted.
|
|\ \
| | |
| | | |
Fix tests in `activerecord/test/cases/tasks/database_tasks_test.rb`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
After #33637 some tests in `activerecord/test/cases/tasks/database_tasks_test.rb`
don't assert anything.
We used to stub `ActiveRecord::Base::configurations` method in those
tests like `ActiveRecord::Base.stub(:configurations, @configurations) {}`.
Since #33637 `ActiveRecord::Base::configurations` is a `ActiveRecord::DatabaseConfigurations`
object(not a Hash object) we can't do so anymore.
`ActiveRecord::DatabaseConfigurations` object builds during `ActiveRecord::Base::configurations=`.
We can replace `ActiveRecord::Base.stub(:configurations, @configurations) {}` to
```
begin
old_configurations = ActiveRecord::Base.configurations
ActiveRecord::Base.configurations = @configurations
# ...
ensure
ActiveRecord::Base.configurations = old_configurations
end
```
Also I fixed tests in `activerecord/test/cases/tasks/legacy_database_tasks_test.rb`
But currently It looks like duplication of
`activerecord/test/cases/tasks/database_tasks_test.rb`.
We should improve those tests or remove them.
I've tried (in `activerecord/test/cases/tasks/legacy_database_tasks_test.rb` file):
```
def with_stubbed_configurations
old_configurations = ActiveRecord::Base.configurations.to_h
ActiveRecord::Base.configurations = @configurations
ActiveRecord::Base.stub(:configurations, ActiveRecord::Base.configurations.to_h) do
yield
end
ensure
ActiveRecord::Base.configurations = old_configurations
end
```
but it causes erros in tests cases.
After discussion we decided to remove
`activerecord/test/cases/tasks/legacy_database_tasks_test.rb`
Related to #33637
|
|/ /
| |
| |
| |
| | |
This method used to take a block, but that's no longer the case so we
can delete the block from the method signature.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The rake tasks which became deprecate now does not load the environment.
Therefore, even if the application specifies the behavior of deprecating,
the message is output to stderr ignoring the specification.
It seems that this is not the expected behavior.
We should respect the setting even in the rake tasks.
|
|\ \
| |/
|/| |
Update link for `Rack socket hijacking API`
|
|/
|
|
|
| |
- Use valid `fragment identifier` in the URL
- Use `https`
|
|\
| |
| | |
Update changelog with new default cache store in test env
|
| |
| |
| |
| | |
[ci skip]
|
|\ \
| |/
|/|
| |
| | |
tgxworld/regression_setting_children_record_in_parent_before_save
Fix regression setting children record in parent before_save callback.
|
| | |
|
|\ \
| | |
| | | |
Make null_store the default cache store in test environment config
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`_create_record` is passed `attribute_names` only.
```
% git grep -n '_create_record(attribute_names'
lib/active_record/attribute_methods/dirty.rb:173: def _create_record(attribute_names = attribute_names_for_partial_writes)
lib/active_record/counter_cache.rb:162: def _create_record(attribute_names = self.attribute_names)
lib/active_record/locking/optimistic.rb:64: def _create_record(attribute_names = self.attribute_names)
lib/active_record/persistence.rb:738: def _create_record(attribute_names = self.attribute_names)
```
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
Change some comments to conform to the style used in other comments
[ci skip]
|
| | | | |
|
|\ \ \ \
| |/ / /
|/| | | |
add mysql and sqlite3 default test
|
|/ / /
| | |
| | |
| | | |
[Gannon McGibbon + Kenji Suzuki]
|
|\ \ \
| | | |
| | | | |
Part 3: Multi-db Improvements, identifying replica configurations
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Changes the `configs_for` method from using traditional arguments to
using kwargs. This is so I can add the `include_replicas` kwarg without
having to always include `env_name` and `spec_name` in the method call.
`include_replicas` defaults to false because everywhere internally in
Rails we don't want replicas. `configs_for` is for iterating over
configurations to create / run rake tasks, so we really don't ever need
replicas in that case.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Checks if the config has a "replica" key, if so the configuration is for
a replica database. This is useful for excluding replicas from the
configurations list when creating the rake tasks or running rake tasks.
For example, we don't want to create the primary and primary_readonly.
They're the same database.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This allows the user to add `replica: true` to the database config to
signify the connection should be treated as readonly. This will be
useful so we can ignore structure dumps or migrations (or creating /
deleting etc) the readonly connection for the databases. These are
paired with a write database which is where the create/drop/migrate
should be run. This allows us to ask the connection if it's for a
replica readonly db or a primary write db.
|
| |_|/
|/| |
| | |
| | |
| | |
| | |
| | |
| | | |
These were added for avoiding warnings and for testing in
e4c529ea1d94ef548975e45b91a7fec045aeefbc and 6ea7065a18671872f1486cff3fdaeb4f78fa6332.
Now the default is `:random`, and since the tests added with it are
removed. That config is unnecessary.
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
steakknife/steakknife/improve-template-generator-actions
add github to template actions, template actions minor refactor
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Faster permitted_scalar_filter
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When running with code triage and derailed benchmarks and focusing on this file:
Before
16199 /Users/rschneeman/Documents/projects/rails/actionpack/lib/action_controller/metal/strong_parameters.r
After
2280 /Users/rschneeman/Documents/projects/rails/actionpack/lib/action_controller/metal/strong_parameters.rb
|
|\ \ \ \ \
| |/ / / /
|/| | | | |
Emit warning for unknown inflection rule when generating model.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
For words like "abuse", Rails cannot derive its singular form from
plural form "abuses" without defining custom inflection rule.
`rails generate model` and its families now emit warning for this case.
|
|/ / / /
| | | |
| | | |
| | | | |
Since #29860, `travel_back` automatically called at the end of the test.
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | | |
Typo in form_helpers.md guide
[ci skip]
|
|/ / / / |
|
|\ \ \ \
| | | | |
| | | | | |
Add hooks to ActiveJob around retries and discards
|
| | | | | |
|
| | | | | |
|
| |_|/ /
|/| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This restores an ability that `update` with ids on a relation which is
described at https://github.com/rails/rails/issues/33470#issuecomment-411203013.
I personally think that the `update` with two arguments on a relation is
not a designed feature, since that is totally not using a relation
state, and also is not documented.
But removing any feature should not be suddenly happened in a stable
version even if that is not documented.
|
|\ \ \ \
| | | | |
| | | | | |
Refactor Active Record configurations
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
While the three-tier config makes it easier to define databases for
multiple database applications, it quickly became clear to offer full
support for multiple databases we need to change the way the connections
hash was handled.
A three-tier config means that when Rails needed to choose a default
configuration (in the case a user doesn't ask for a specific
configuration) it wasn't clear to Rails which the default was. I
[bandaid fixed this so the rake tasks could work](#32271) but that fix
wasn't correct because it actually doubled up the configuration hashes.
Instead of attemping to manipulate the hashes @tenderlove and I decided
that it made more sense if we converted the hashes to objects so we can
easily ask those object questions. In a three tier config like this:
```
development:
primary:
database: "my_primary_db"
animals:
database; "my_animals_db"
```
We end up with an object like this:
```
@configurations=[
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
@env_name="development",@spec_name="primary",
@config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>,
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90
@env_name="development",@spec_name="animals",
@config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
]>
```
The configurations setter takes the database configuration set by your
application and turns them into an
`ActiveRecord::DatabaseConfigurations` object that has one getter -
`@configurations` which is an array of all the database objects.
The configurations getter returns this object by default since it acts
like a hash in most of the cases we need. For example if you need to
access the default `development` database we can simply request it as we
did before:
```
ActiveRecord::Base.configurations["development"]
```
This will return primary development database configuration hash:
```
{ "database" => "my_primary_db" }
```
Internally all of Active Record has been converted to use the new
objects. I've built this to be backwards compatible but allow for
accessing the hash if needed for a deprecation period. To get the
original hash instead of the object you can either add `to_h` on the
configurations call or pass `legacy: true` to `configurations.
```
ActiveRecord::Base.configurations.to_h
=> { "development => { "database" => "my_primary_db" } }
ActiveRecord::Base.configurations(legacy: true)
=> { "development => { "database" => "my_primary_db" } }
```
The new configurations object allows us to iterate over the Active
Record configurations without losing the known environment or
specification name for that configuration. You can also select all the
configs for an env or env and spec. With this we can always ask
any object what environment it belongs to:
```
db_configs = ActiveRecord::Base.configurations.configurations_for("development")
=> #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800
@configurations=[
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
@env_name="development",@spec_name="primary",
@config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>,
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90
@env_name="development",@spec_name="animals",
@config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
]>
db_config.env_name
=> "development"
db_config.spec_name
=> "primary"
db_config.config
=> { "adapter"=>"sqlite3", "database"=>"db/development.sqlite3" }
```
The configurations object is more flexible than the configurations hash
and will allow us to build on top of the connection management in order
to add support for primary/replica connections, sharding, and
constructing queries for associations that live in multiple databases.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Do not recompute length
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
We can get a speed gain by moving the length calculation and assignment out of the loop.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
eileencodes/add-migrations_paths_option-to-migration-generator
Add migrations_paths option to migration generator
|
| | |/ / / /
| |/| | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Adds an option to the migration generator to allow setting the
migrations paths for that migration. This is useful for applications
that use multiple databases and put migrations per database in their own
directories.
```
bin/rails g migration CreateHouses address:string --migrations-paths=db/kingston_migrate
invoke active_record
create db/kingston_migrate/20180830151055_create_houses.rb
```
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
[ci skip] Document permitted_scalar_filter
|
|/ / / / / / |
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Use `delete_if` instead of `reject` to avoid an extra allocation.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
`attributes_with_values_for_update` is no longer used since ae2d36c, and
`attributes_with_values_for_create` is internally used only one place.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
It should be done only once in `Persistence` module.
https://github.com/rails/rails/blob/c83e30da27eafde79164ecb376e8a28ccc8d841f/activerecord/lib/active_record/persistence.rb#L721
https://github.com/rails/rails/blob/c83e30da27eafde79164ecb376e8a28ccc8d841f/activerecord/lib/active_record/persistence.rb#L740
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
Follow up #32937 [ci skip]
|