This commit is contained in:
Rafael Mendonça França 2021-04-15 23:34:30 +00:00
parent 7ce853ecb0
commit 7b198e6024
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
3 changed files with 7 additions and 7 deletions

View File

@ -1,10 +1,10 @@
* Add setting for enumerating column names in SELECT statements.
Adding a column to a Postgres database while the application is running can
Adding a column to a PostgresSQL database, for example, while the application is running can
change the result of wildcard `SELECT *` queries, which invalidates the result
of cached prepared statements and raises a PreparedStatementCacheExpired error.
of cached prepared statements and raises a `PreparedStatementCacheExpired` error.
When truthy, ActiveRecord will avoid wildcards and always include column names
When enabled, Active Record will avoid wildcards and always include column names
in `SELECT` queries, which will return consistent results and avoid prepared
statement errors.

View File

@ -131,10 +131,10 @@ module ActiveRecord
##
# :singleton-method:
# Force enumeration of all columns in SELECT statements
# Force enumeration of all columns in SELECT statements.
# e.g. `SELECT first_name, last_name FROM ...` instead of `SELECT * FROM ...`
# This avoids PreparedStatementCacheExpired errors when a column is added
# to a Postgres database while the app is running.
# This avoids +PreparedStatementCacheExpired+ errors when a column is added
# to the database while the app is running.
class_attribute :enumerate_columns_in_select_statements, instance_accessor: false, default: false
mattr_accessor :maintain_test_schema, instance_accessor: false

View File

@ -473,7 +473,7 @@ in controllers and views. This defaults to `false`.
* `config.active_record.queues.destroy` allows specifying the Active Job queue to use for destroy jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `nil`.
* `config.active_record.enumerate_columns_in_select_statements` when truthy, will always include column names in `SELECT` statements, and avoid wildcard `SELECT * FROM ...` queries. This avoids prepared statement cache errors when adding columns to a Postgres database. Defaults to `false`.
* `config.active_record.enumerate_columns_in_select_statements` when true, will always include column names in `SELECT` statements, and avoid wildcard `SELECT * FROM ...` queries. This avoids prepared statement cache errors when adding columns to a PostgresSQL database for example. Defaults to `false`.
The MySQL adapter adds one additional configuration option: