Jean Boussier
46e43f57f6
Merge pull request #43078 from Shopify/ar-query-log-default-context
...
Make ActiveRecord::QueryLogs default behavior to return the context content
2021-08-23 17:44:40 +02:00
Jean Boussier
e12514ac43
Merge pull request #43076 from Shopify/ar-query-logs-nesting
...
Make `QueryLogs.set_context` restore previous values
2021-08-23 16:38:13 +02:00
Jean Boussier
6ea85aff71
Make QueryLogs.set_context
restore previous values
...
It's really the least surpising behavior for block based APIs like this one
and is consistent with `with_tags`.
2021-08-23 16:08:40 +02:00
Jean Boussier
9f035e2222
Make ActiveRecord::QueryLogs default behavior to return the context content
...
This should cover the vast majority of use cases, e.g.
```ruby
config.active_record.query_log_tags = [:api_client_id]
ActiveRecord::QueryLogs.set_context(api_client_id: api_client.id) do
# ...
end
```
2021-08-23 15:58:37 +02:00
Eileen M. Uchitelle
a81aeb63a0
Merge pull request #43050 from intrip/42912-restore-db-connection-on-schema-load-name
...
Reestablish connection to previous database after after running db:schema:load:name
2021-08-23 09:20:02 -04:00
Petrik
d6527e64b3
Don't use redundant curly braces in where
examples [ci-skip]
...
In 411ccbdab2608c62aabdb320d52cb02d446bb39c redundant curly braces for
hash arguments were removed from most of the code base.
The docs of the `where` methods still use redundant curly braces, so
lets remove them as well.
2021-08-22 17:20:42 +02:00
Xavier Noria
194866854f
Restore autoloading test for STI
...
This commit restores the test deleted in
fc7c029467
Active Record should not test things about autoloading, this would
belong to the railties test suite probably. However, there, it feels
a bit too distant from here.
Imperfect, but on a second thought I believe this trade-off is better.
2021-08-22 01:13:00 +02:00
Xavier Noria
38e82daee8
Delete AS::Dependencies.safe_constantize
2021-08-20 17:51:05 +02:00
Xavier Noria
3e3504bdaa
Delete AS::Dependencies.constantize
2021-08-20 09:47:22 +02:00
Jacopo
718c71e051
Reestablish connection to previous database after after running db:schema:load:name
...
After running `db:schema:load:name` the previous connection is restored.
Fixes #42912
2021-08-20 08:56:07 +02:00
Jonathan Hefner
074c7f50c5
Merge pull request #43018 from ChaelCodes/document-order
...
[DOCS] Improve Documentation for ActiveRecord's order Method [ci-skip]
2021-08-19 09:20:11 -05:00
Rachael Wright-Munn
d6a38d2c43
Improve Documentation around the options that can be passed to order.
...
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2021-08-19 09:16:25 -05:00
Ryuta Kamizono
64a3bb892f
Merge pull request #43052 from p8/activerecord/change-joins-docs
...
Improve description of ActiveRecord.joins [ci-skip]
2021-08-19 21:26:44 +09:00
Petrik
bdd7e24bf2
Improve description of ActiveRecord.joins [ci-skip]
...
Joins is the plural of join. So "a joins" doesn't seem correct.
To make it clear joins is a SQL term, we can upcase it just like the
descriptions for GROUP, HAVING and SELECT.
2021-08-19 14:05:01 +02:00
Rafael Mendonça França
cabe311f67
Make DatabaseConnectionError
a subclass of ConnectionNotEstablished
...
Before the introduction of this exception, we where raising
a `ConnectionNotEstablished` and users might be rescuing that exception
already.
As the goal of the new exception was to be more specific, we should be
subclassing `ConnectionNotEstablished` to keep the old behaviour.
2021-08-18 18:44:52 +00:00
Rafael Mendonça França
614fc3d827
Delay the exclusion of the configs to the last minute
...
The framework still rely on the configuration object being modified
in initializers, so we need to delay the exclusion to the last minute.
2021-08-18 00:04:25 +00:00
Rafael Mendonça França
bc00484d2c
No need to check if the logs are enable to run those tests
2021-08-17 23:35:49 +00:00
Rafael Mendonça França
8af78700d2
Improve taggings API by introducing a null object
...
Instead of adding chains of `&.` we should use a null object to allow
the taggings definition to be more concise.
2021-08-17 23:35:44 +00:00
Rafael Mendonça França
16242464db
Allow tag values to be static
2021-08-17 22:59:24 +00:00
Rafael Mendonça França
1e3e1a0e72
No need for memoization
...
At this point the application name can't change.
2021-08-17 22:41:03 +00:00
Rafael Mendonça França
84376c3e03
Move default tagging configuration to the railtie
...
All other tags are there, so there is no need to keep them separated.
2021-08-17 22:38:27 +00:00
Rafael Mendonça França
6d983e86da
Remove more unneeded methods that should be configs
2021-08-17 22:35:22 +00:00
Rafael Mendonça França
8d6073da7d
Some stylistics changes
2021-08-17 22:18:30 +00:00
Rafael Mendonça França
e214f25463
Do not change the framework if all we want are configs
...
The value of the configs in the base classes were not being used in
the code. We only needed configs, so we can just use that.
2021-08-17 22:13:00 +00:00
Eileen M. Uchitelle
efaeca94e6
Merge pull request #43034 from eileencodes/add-new-kwarg-configs_for
...
Replace kwarg for displaying all configurations
2021-08-17 10:03:27 -04:00
eileencodes
9da8fef162
Replace kwarg for displaying all configurations
...
In #42794 we added the ability to hide some configurations for database
tasks. This is useful if you want your application to connect to a
database but if it's a separate service not run any tasks against it.
After adding this functionality I realized that the `configs_for`
argument no longer makes sense. `include_replicas` would include all of
them but ones with `database_tasks: false` aren't necessarily replicas.
This change deprecates `include_replicas` in favor of `include_hidden`
which will display all configurations. When not passed, this will
continue to return all writing connections that we want to perform tasks
on.
2021-08-17 09:27:18 -04:00
Ryuta Kamizono
49fee6572c
Fix typo [ci skip]
2021-08-17 12:41:08 +09:00
Eileen M. Uchitelle
86aeadc481
Merge pull request #42794 from westonganger/multi_db_config_database_tasks_option
...
Add database config option `database_tasks: false`
2021-08-16 15:29:29 -04:00
Weston Ganger
a77dd104ea
Implement db config option database_tasks: false
2021-08-16 11:18:49 -07:00
Eugene Kenny
f1229b8fbc
Merge pull request #43013 from basecamp/encryption-store-attributes
...
Make active record encryption work with store attributes
2021-08-15 22:57:46 +01:00
Jorge Manrubia
6eb4ee4bed
Encryption scheme is commong (no need to instantiate 1 per attribute)
...
See https://github.com/rails/rails/pull/43009#discussion_r689068941
Remove `table_exists?` check that became unnecessary after #43009
Co-authored-by: Haroon Ahmed <haroon.ahmed25@gmail.com>
2021-08-15 23:20:39 +02:00
Jorge Manrubia
24f2502dc0
Remove table_exists?
check that became unnecessary after #43009
...
Co-authored-by: Haroon Ahmed <haroon.ahmed25@gmail.com>
2021-08-15 23:20:31 +02:00
Jorge Manrubia
34ac8fc1f1
Make active record encryption work with store attributes
...
Fix: https://github.com/rails/rails/issues/43012
2021-08-14 11:06:51 +02:00
Jean Boussier
02d989e72c
Merge pull request #43009 from basecamp/encryption-lenght-validation
...
Move length-validation for encrypted columns after schema is loaded
2021-08-13 10:17:23 +02:00
Kasper Timm Hansen
0965b67bf7
Merge pull request #42967 from p8/main
...
Clean up missing dots in changelogs
2021-08-13 02:24:40 +02:00
Jorge Manrubia
f0fe547e20
Move length-validation for encrypted columns after schema is loaded
...
Doing it before meant it required a database connection at class loading
time, which was a source a trouble.
See https://github.com/rails/rails/pull/42991#discussion_r687659296
2021-08-12 22:52:50 +02:00
Jean Boussier
6fce5576ea
Set record_timestamps = true in AR::InternalMetadata
...
Fix: https://github.com/rails/rails/issues/42983
The usefulness of these timestamps is a bit questionable,
but I suppose they could be useful for debugging, and
removing them would require to ship a migration etc.
Since `record_timestamps` is now a `class_attribute` we
can simply force it to `true` in just that class.
2021-08-11 10:05:07 +02:00
Jeremiah
b7560426b5
Simplify pluck(:value).first
to pick(:value)
2021-08-10 10:12:09 -05:00
Keeran Raj Hawoldar
2408615154
Add QueryLogTags to Rails
...
Co-authored-by: Eileen M. Uchitelle <eileencodes@users.noreply.github.com>
Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>
2021-08-09 15:21:08 +01:00
Eileen M. Uchitelle
843c0a3fcd
Merge pull request #42938 from Modern-Treasury/rh/multidb-tasks
...
Add database specific setup and reset tasks for multidb configurations
2021-08-09 08:21:40 -04:00
Xavier Noria
fc7c029467
Deletes classic test related to STI
...
Without classic, this test would be testing that Zeitwerk works. That
belongs to the test suite of Zeitwerk.
Active Record has the class available, whether it was already loaded or
pending autoloading, is not AR's concern.
2021-08-09 13:40:03 +02:00
Xavier Noria
36e716cdc1
Implement support for before_remove_const in zeitwek mode
...
This needs Zeitwerk 2.5 for the on_unload hook.
2021-08-09 13:15:10 +02:00
Ryan Hall
0a296be9e1
Add database specific setup and reset tasks
2021-08-08 13:52:47 -07:00
Petrik de Heus
6828334555
Add missing dots to changelogs
2021-08-07 18:53:10 +02:00
Ryuta Kamizono
9576a4c77f
Merge pull request #42963 from jordannb/fix-unknown-attr-ref-err-doc
...
API Docs: Use Arel.sql examples that require Arel.sql
2021-08-07 13:42:45 +09:00
Ryuta Kamizono
4261e4dd85
nodoc field_ordered_value
[ci skip]
2021-08-07 13:27:43 +09:00
Jordan Bostrom
18c0c568da
docs: use Arel.sql examples that require Arel.sql
2021-08-06 16:58:38 -05:00
Ryuta Kamizono
f9468ad191
Avoid class_eval
2021-08-06 18:03:33 +09:00
Rafael Mendonça França
549ef603ad
Fix indentation
2021-08-06 03:41:59 +00:00
Rafael França
e2e74cf93a
Merge pull request #39723 from hahmed/db/friendly-error-when-no-db
...
Create database via UI when ActiveRecord::NoDatabaseError
2021-08-05 23:41:17 -04:00