activerecord 5.2.6 → 6.0.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +956 -559
- data/MIT-LICENSE +3 -1
- data/README.rdoc +5 -3
- data/examples/performance.rb +1 -1
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +4 -3
- data/lib/active_record/association_relation.rb +10 -8
- data/lib/active_record/associations/alias_tracker.rb +0 -1
- data/lib/active_record/associations/association.rb +55 -19
- data/lib/active_record/associations/association_scope.rb +11 -7
- data/lib/active_record/associations/belongs_to_association.rb +36 -42
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +0 -4
- data/lib/active_record/associations/builder/association.rb +14 -18
- data/lib/active_record/associations/builder/belongs_to.rb +19 -52
- data/lib/active_record/associations/builder/collection_association.rb +3 -13
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +17 -40
- data/lib/active_record/associations/builder/has_many.rb +2 -0
- data/lib/active_record/associations/builder/has_one.rb +35 -1
- data/lib/active_record/associations/builder/singular_association.rb +2 -0
- data/lib/active_record/associations/collection_association.rb +19 -23
- data/lib/active_record/associations/collection_proxy.rb +14 -17
- data/lib/active_record/associations/foreign_association.rb +7 -0
- data/lib/active_record/associations/has_many_association.rb +2 -11
- data/lib/active_record/associations/has_many_through_association.rb +14 -14
- data/lib/active_record/associations/has_one_association.rb +28 -30
- data/lib/active_record/associations/has_one_through_association.rb +5 -5
- data/lib/active_record/associations/join_dependency/join_association.rb +16 -10
- data/lib/active_record/associations/join_dependency/join_part.rb +4 -4
- data/lib/active_record/associations/join_dependency.rb +47 -30
- data/lib/active_record/associations/preloader/association.rb +61 -41
- data/lib/active_record/associations/preloader/through_association.rb +48 -39
- data/lib/active_record/associations/preloader.rb +44 -33
- data/lib/active_record/associations/singular_association.rb +2 -16
- data/lib/active_record/associations/through_association.rb +1 -1
- data/lib/active_record/associations.rb +21 -16
- data/lib/active_record/attribute_assignment.rb +7 -11
- data/lib/active_record/attribute_decorators.rb +0 -2
- data/lib/active_record/attribute_methods/before_type_cast.rb +4 -2
- data/lib/active_record/attribute_methods/dirty.rb +111 -40
- data/lib/active_record/attribute_methods/primary_key.rb +15 -24
- data/lib/active_record/attribute_methods/query.rb +2 -3
- data/lib/active_record/attribute_methods/read.rb +15 -54
- data/lib/active_record/attribute_methods/serialization.rb +1 -2
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +1 -3
- data/lib/active_record/attribute_methods/write.rb +17 -25
- data/lib/active_record/attribute_methods.rb +28 -100
- data/lib/active_record/attributes.rb +13 -1
- data/lib/active_record/autosave_association.rb +12 -14
- data/lib/active_record/base.rb +2 -3
- data/lib/active_record/callbacks.rb +6 -21
- data/lib/active_record/coders/yaml_column.rb +13 -2
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +109 -18
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +17 -4
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +102 -124
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +18 -9
- data/lib/active_record/connection_adapters/abstract/quoting.rb +68 -17
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +20 -14
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +105 -72
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -3
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +175 -79
- data/lib/active_record/connection_adapters/abstract/transaction.rb +96 -57
- data/lib/active_record/connection_adapters/abstract_adapter.rb +197 -43
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +149 -217
- data/lib/active_record/connection_adapters/column.rb +17 -13
- data/lib/active_record/connection_adapters/connection_specification.rb +54 -45
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +6 -10
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +70 -14
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
- data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -7
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +4 -6
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +40 -32
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +14 -6
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +139 -19
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +6 -10
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +26 -10
- data/lib/active_record/connection_adapters/postgresql/column.rb +17 -31
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +26 -1
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +1 -4
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +8 -0
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +25 -7
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +9 -7
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +44 -7
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +14 -3
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +107 -91
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +63 -75
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +24 -27
- data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +168 -75
- data/lib/active_record/connection_adapters/schema_cache.rb +37 -14
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +11 -8
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +119 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +42 -7
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +43 -12
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +137 -147
- data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
- data/lib/active_record/connection_handling.rb +139 -26
- data/lib/active_record/core.rb +117 -66
- data/lib/active_record/counter_cache.rb +8 -30
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +78 -0
- data/lib/active_record/database_configurations.rb +233 -0
- data/lib/active_record/dynamic_matchers.rb +3 -4
- data/lib/active_record/enum.rb +44 -7
- data/lib/active_record/errors.rb +15 -7
- data/lib/active_record/explain.rb +1 -2
- data/lib/active_record/fixture_set/model_metadata.rb +33 -0
- data/lib/active_record/fixture_set/render_context.rb +17 -0
- data/lib/active_record/fixture_set/table_row.rb +152 -0
- data/lib/active_record/fixture_set/table_rows.rb +46 -0
- data/lib/active_record/fixtures.rb +144 -474
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +13 -6
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +68 -16
- data/lib/active_record/internal_metadata.rb +11 -3
- data/lib/active_record/locking/optimistic.rb +14 -7
- data/lib/active_record/locking/pessimistic.rb +3 -3
- data/lib/active_record/log_subscriber.rb +8 -27
- data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +87 -0
- data/lib/active_record/middleware/database_selector.rb +74 -0
- data/lib/active_record/migration/command_recorder.rb +54 -22
- data/lib/active_record/migration/compatibility.rb +79 -52
- data/lib/active_record/migration/join_table.rb +0 -1
- data/lib/active_record/migration.rb +104 -85
- data/lib/active_record/model_schema.rb +62 -11
- data/lib/active_record/nested_attributes.rb +2 -4
- data/lib/active_record/no_touching.rb +9 -2
- data/lib/active_record/null_relation.rb +0 -1
- data/lib/active_record/persistence.rb +232 -29
- data/lib/active_record/query_cache.rb +11 -4
- data/lib/active_record/querying.rb +33 -21
- data/lib/active_record/railtie.rb +95 -40
- data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
- data/lib/active_record/railties/controller_runtime.rb +30 -35
- data/lib/active_record/railties/databases.rake +199 -46
- data/lib/active_record/reflection.rb +51 -51
- data/lib/active_record/relation/batches.rb +13 -11
- data/lib/active_record/relation/calculations.rb +55 -49
- data/lib/active_record/relation/delegation.rb +35 -50
- data/lib/active_record/relation/finder_methods.rb +23 -28
- data/lib/active_record/relation/from_clause.rb +4 -0
- data/lib/active_record/relation/merger.rb +12 -17
- data/lib/active_record/relation/predicate_builder/array_handler.rb +5 -4
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +1 -4
- data/lib/active_record/relation/predicate_builder/base_handler.rb +1 -2
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +1 -2
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -4
- data/lib/active_record/relation/predicate_builder/range_handler.rb +3 -23
- data/lib/active_record/relation/predicate_builder.rb +5 -11
- data/lib/active_record/relation/query_attribute.rb +13 -8
- data/lib/active_record/relation/query_methods.rb +232 -69
- data/lib/active_record/relation/spawn_methods.rb +1 -2
- data/lib/active_record/relation/where_clause.rb +14 -11
- data/lib/active_record/relation/where_clause_factory.rb +1 -2
- data/lib/active_record/relation.rb +326 -81
- data/lib/active_record/result.rb +30 -12
- data/lib/active_record/sanitization.rb +32 -40
- data/lib/active_record/schema.rb +2 -11
- data/lib/active_record/schema_dumper.rb +22 -7
- data/lib/active_record/schema_migration.rb +6 -2
- data/lib/active_record/scoping/default.rb +4 -6
- data/lib/active_record/scoping/named.rb +25 -16
- data/lib/active_record/scoping.rb +8 -9
- data/lib/active_record/statement_cache.rb +30 -3
- data/lib/active_record/store.rb +87 -8
- data/lib/active_record/suppressor.rb +2 -2
- data/lib/active_record/table_metadata.rb +23 -15
- data/lib/active_record/tasks/database_tasks.rb +194 -25
- data/lib/active_record/tasks/mysql_database_tasks.rb +5 -6
- data/lib/active_record/tasks/postgresql_database_tasks.rb +5 -8
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -9
- data/lib/active_record/test_databases.rb +23 -0
- data/lib/active_record/test_fixtures.rb +243 -0
- data/lib/active_record/timestamp.rb +39 -26
- data/lib/active_record/touch_later.rb +5 -4
- data/lib/active_record/transactions.rb +64 -73
- data/lib/active_record/translation.rb +1 -1
- data/lib/active_record/type/adapter_specific_registry.rb +3 -13
- data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
- data/lib/active_record/type/serialized.rb +0 -1
- data/lib/active_record/type/time.rb +10 -0
- data/lib/active_record/type/type_map.rb +0 -1
- data/lib/active_record/type/unsigned_integer.rb +0 -1
- data/lib/active_record/type.rb +3 -5
- data/lib/active_record/type_caster/connection.rb +15 -14
- data/lib/active_record/type_caster/map.rb +1 -4
- data/lib/active_record/validations/associated.rb +0 -1
- data/lib/active_record/validations/uniqueness.rb +15 -27
- data/lib/active_record/validations.rb +3 -3
- data/lib/active_record.rb +10 -2
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +67 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +45 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values_list.rb +9 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/nodes.rb +68 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +256 -0
- data/lib/arel/select_manager.rb +271 -0
- data/lib/arel/table.rb +110 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors/depth_first.rb +203 -0
- data/lib/arel/visitors/dot.rb +296 -0
- data/lib/arel/visitors/ibm_db.rb +34 -0
- data/lib/arel/visitors/informix.rb +62 -0
- data/lib/arel/visitors/mssql.rb +156 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +158 -0
- data/lib/arel/visitors/oracle12.rb +65 -0
- data/lib/arel/visitors/postgresql.rb +109 -0
- data/lib/arel/visitors/sqlite.rb +38 -0
- data/lib/arel/visitors/to_sql.rb +888 -0
- data/lib/arel/visitors/visitor.rb +45 -0
- data/lib/arel/visitors/where_sql.rb +22 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/arel.rb +62 -0
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
- data/lib/rails/generators/active_record/migration/migration_generator.rb +2 -5
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +1 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -2
- data/lib/rails/generators/active_record/migration.rb +14 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +1 -1
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +10 -1
- metadata +116 -29
- data/lib/active_record/collection_cache_key.rb +0 -53
data/CHANGELOG.md
CHANGED
@@ -1,1026 +1,1423 @@
|
|
1
|
-
## Rails 5.
|
1
|
+
## Rails 6.0.5.1 (July 12, 2022) ##
|
2
|
+
|
3
|
+
* Change ActiveRecord::Coders::YAMLColumn default to safe_load
|
4
|
+
|
5
|
+
This adds two new configuration options The configuration options are as
|
6
|
+
follows:
|
7
|
+
|
8
|
+
* `config.active_storage.use_yaml_unsafe_load`
|
9
|
+
|
10
|
+
When set to true, this configuration option tells Rails to use the old
|
11
|
+
"unsafe" YAML loading strategy, maintaining the existing behavior but leaving
|
12
|
+
the possible escalation vulnerability in place. Setting this option to true
|
13
|
+
is *not* recommended, but can aid in upgrading.
|
14
|
+
|
15
|
+
* `config.active_record.yaml_column_permitted_classes`
|
16
|
+
|
17
|
+
The "safe YAML" loading method does not allow all classes to be deserialized
|
18
|
+
by default. This option allows you to specify classes deemed "safe" in your
|
19
|
+
application. For example, if your application uses Symbol and Time in
|
20
|
+
serialized data, you can add Symbol and Time to the allowed list as follows:
|
21
|
+
|
22
|
+
```
|
23
|
+
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
|
24
|
+
```
|
2
25
|
|
3
|
-
|
26
|
+
[CVE-2022-32224]
|
4
27
|
|
5
28
|
|
6
|
-
## Rails
|
29
|
+
## Rails 6.0.5 (May 09, 2022) ##
|
7
30
|
|
8
31
|
* No changes.
|
9
32
|
|
10
33
|
|
11
|
-
## Rails
|
34
|
+
## Rails 6.0.4.8 (April 26, 2022) ##
|
12
35
|
|
13
36
|
* No changes.
|
14
37
|
|
15
38
|
|
16
|
-
## Rails
|
39
|
+
## Rails 6.0.4.7 (March 08, 2022) ##
|
17
40
|
|
18
|
-
*
|
41
|
+
* No changes.
|
19
42
|
|
20
|
-
Carefully crafted input can cause a DoS via the regular expressions used
|
21
|
-
for validating the money format in the PostgreSQL adapter. This patch
|
22
|
-
fixes the regexp.
|
23
43
|
|
24
|
-
|
44
|
+
## Rails 6.0.4.6 (February 11, 2022) ##
|
25
45
|
|
26
|
-
|
46
|
+
* No changes.
|
27
47
|
|
28
|
-
*Aaron Patterson*
|
29
48
|
|
49
|
+
## Rails 6.0.4.5 (February 11, 2022) ##
|
50
|
+
|
51
|
+
* No changes.
|
30
52
|
|
31
|
-
|
53
|
+
|
54
|
+
## Rails 6.0.4.4 (December 15, 2021) ##
|
32
55
|
|
33
56
|
* No changes.
|
34
57
|
|
35
58
|
|
36
|
-
## Rails
|
59
|
+
## Rails 6.0.4.3 (December 14, 2021) ##
|
37
60
|
|
38
61
|
* No changes.
|
39
62
|
|
40
|
-
|
63
|
+
|
64
|
+
## Rails 6.0.4.2 (December 14, 2021) ##
|
41
65
|
|
42
66
|
* No changes.
|
43
67
|
|
44
68
|
|
45
|
-
## Rails
|
69
|
+
## Rails 6.0.4.1 (August 19, 2021) ##
|
46
70
|
|
47
71
|
* No changes.
|
48
72
|
|
49
73
|
|
50
|
-
## Rails
|
74
|
+
## Rails 6.0.4 (June 15, 2021) ##
|
51
75
|
|
52
|
-
*
|
76
|
+
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
53
77
|
|
54
|
-
|
55
|
-
associations, the callback for a `has_many` association was run while
|
56
|
-
another instance of the same callback on the same association hadn't
|
57
|
-
finished running. When control returned to the first instance of the
|
58
|
-
callback, the instance variable had changed, and subsequent associated
|
59
|
-
records weren't saved correctly. Specifically, the ID field for the
|
60
|
-
`belongs_to` corresponding to the `has_many` was `nil`.
|
78
|
+
Fixes #39065.
|
61
79
|
|
62
|
-
|
80
|
+
*Alex Ghiculescu*
|
63
81
|
|
64
|
-
|
82
|
+
* Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
|
65
83
|
|
66
|
-
|
84
|
+
Fixes #34255.
|
67
85
|
|
68
|
-
|
86
|
+
*Steven Weber*
|
87
|
+
|
88
|
+
* Reset statement cache for association if `table_name` is changed.
|
89
|
+
|
90
|
+
Fixes #36453.
|
69
91
|
|
70
92
|
*Ryuta Kamizono*
|
71
93
|
|
72
|
-
*
|
94
|
+
* Type cast extra select for eager loading.
|
73
95
|
|
74
|
-
*
|
96
|
+
*Ryuta Kamizono*
|
75
97
|
|
76
|
-
*
|
98
|
+
* Prevent collection associations from being autosaved multiple times.
|
77
99
|
|
78
|
-
Fixes #
|
100
|
+
Fixes #39173.
|
79
101
|
|
80
|
-
*
|
102
|
+
*Eugene Kenny*
|
81
103
|
|
82
|
-
*
|
83
|
-
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
104
|
+
* Resolve issue with insert_all unique_by option when used with expression index.
|
84
105
|
|
85
|
-
|
106
|
+
When the `:unique_by` option of `ActiveRecord::Persistence.insert_all` and
|
107
|
+
`ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
|
108
|
+
was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
|
86
109
|
|
87
|
-
|
110
|
+
Usage:
|
88
111
|
|
112
|
+
```ruby
|
113
|
+
create_table :books, id: :integer, force: true do |t|
|
114
|
+
t.column :name, :string
|
115
|
+
t.index "lower(name)", unique: true
|
116
|
+
end
|
89
117
|
|
90
|
-
|
118
|
+
Book.insert_all [{ name: "MyTest" }], unique_by: :index_books_on_lower_name
|
119
|
+
```
|
91
120
|
|
92
|
-
|
121
|
+
Fixes #39516.
|
93
122
|
|
94
|
-
|
123
|
+
*Austen Madden*
|
95
124
|
|
96
|
-
|
125
|
+
* Fix preloading for polymorphic association with custom scope.
|
97
126
|
|
98
|
-
*
|
127
|
+
*Ryuta Kamizono*
|
128
|
+
|
129
|
+
* Allow relations with different SQL comments in the `or` method.
|
130
|
+
|
131
|
+
*Takumi Shotoku*
|
132
|
+
|
133
|
+
* Resolve conflict between counter cache and optimistic locking.
|
134
|
+
|
135
|
+
Bump an Active Record instance's lock version after updating its counter
|
136
|
+
cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
|
137
|
+
upon subsequent transactions by maintaining parity with the corresponding
|
138
|
+
database record's `lock_version` column.
|
139
|
+
|
140
|
+
Fixes #16449.
|
141
|
+
|
142
|
+
*Aaron Lipman*
|
143
|
+
|
144
|
+
* Fix through association with source/through scope which has joins.
|
99
145
|
|
100
146
|
*Ryuta Kamizono*
|
101
147
|
|
102
|
-
*
|
148
|
+
* Fix through association to respect source scope for includes/preload.
|
103
149
|
|
104
|
-
|
150
|
+
*Ryuta Kamizono*
|
151
|
+
|
152
|
+
* Fix eager load with Arel joins to maintain the original joins order.
|
105
153
|
|
106
154
|
*Ryuta Kamizono*
|
107
155
|
|
108
|
-
*
|
156
|
+
* Fix group by count with eager loading + order + limit/offset.
|
109
157
|
|
110
|
-
|
158
|
+
*Ryuta Kamizono*
|
159
|
+
|
160
|
+
* Fix left joins order when merging multiple left joins from different associations.
|
111
161
|
|
112
162
|
*Ryuta Kamizono*
|
113
163
|
|
114
|
-
* Fix
|
164
|
+
* Fix index creation to preserve index comment in bulk change table on MySQL.
|
115
165
|
|
116
|
-
*
|
166
|
+
*Ryuta Kamizono*
|
117
167
|
|
118
|
-
*
|
168
|
+
* Change `remove_foreign_key` to not check `:validate` option if database
|
169
|
+
doesn't support the feature.
|
119
170
|
|
120
171
|
*Ryuta Kamizono*
|
121
172
|
|
122
|
-
*
|
173
|
+
* Fix the result of aggregations to maintain duplicated "group by" fields.
|
123
174
|
|
124
|
-
*
|
175
|
+
*Ryuta Kamizono*
|
176
|
+
|
177
|
+
* Do not return duplicated records when using preload.
|
125
178
|
|
179
|
+
*Bogdan Gusiev*
|
126
180
|
|
127
|
-
|
181
|
+
|
182
|
+
## Rails 6.0.3.7 (May 05, 2021) ##
|
128
183
|
|
129
184
|
* No changes.
|
130
185
|
|
131
186
|
|
132
|
-
## Rails
|
187
|
+
## Rails 6.0.3.6 (March 26, 2021) ##
|
133
188
|
|
134
|
-
*
|
189
|
+
* No changes.
|
135
190
|
|
136
|
-
*Ryuta Kamizono*
|
137
191
|
|
138
|
-
|
192
|
+
## Rails 6.0.3.5 (February 10, 2021) ##
|
139
193
|
|
140
|
-
|
194
|
+
* Fix possible DoS vector in PostgreSQL money type
|
141
195
|
|
142
|
-
|
196
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
197
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
198
|
+
fixes the regexp.
|
143
199
|
|
144
|
-
|
145
|
-
adapter.
|
200
|
+
Thanks to @dee-see from Hackerone for this patch!
|
146
201
|
|
147
|
-
|
202
|
+
[CVE-2021-22880]
|
148
203
|
|
149
|
-
*
|
204
|
+
*Aaron Patterson*
|
150
205
|
|
151
|
-
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
152
|
-
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
153
206
|
|
154
|
-
|
155
|
-
class DeveloperName < ActiveRecord::Type::String
|
156
|
-
def deserialize(value)
|
157
|
-
"Developer: #{value}"
|
158
|
-
end
|
159
|
-
end
|
207
|
+
## Rails 6.0.3.4 (October 07, 2020) ##
|
160
208
|
|
161
|
-
|
162
|
-
self.table_name = "developers"
|
209
|
+
* No changes.
|
163
210
|
|
164
|
-
attribute :name, DeveloperName.new
|
165
211
|
|
166
|
-
|
167
|
-
end
|
212
|
+
## Rails 6.0.3.3 (September 09, 2020) ##
|
168
213
|
|
169
|
-
|
170
|
-
developer.update_column :name, "name"
|
214
|
+
* No changes.
|
171
215
|
|
172
|
-
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
173
|
-
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
174
|
-
```
|
175
216
|
|
176
|
-
|
217
|
+
## Rails 6.0.3.2 (June 17, 2020) ##
|
177
218
|
|
178
|
-
*
|
219
|
+
* No changes.
|
179
220
|
|
180
|
-
*Emmanuel Byrd*
|
181
221
|
|
182
|
-
|
183
|
-
if the attribute does not exist.
|
222
|
+
## Rails 6.0.3.1 (May 18, 2020) ##
|
184
223
|
|
185
|
-
|
224
|
+
* No changes.
|
186
225
|
|
187
|
-
* Do not use prepared statement in queries that have a large number of binds.
|
188
226
|
|
189
|
-
|
227
|
+
## Rails 6.0.3 (May 06, 2020) ##
|
228
|
+
|
229
|
+
* Recommend applications don't use the `database` kwarg in `connected_to`
|
190
230
|
|
191
|
-
|
231
|
+
The database kwarg in `connected_to` was meant to be used for one-off scripts but is often used in requests. This is really dangerous because it re-establishes a connection every time. It's deprecated in 6.1 and will be removed in 6.2 without replacement. This change soft deprecates it in 6.0 by removing documentation.
|
192
232
|
|
193
233
|
*Eileen M. Uchitelle*
|
194
234
|
|
195
|
-
* Fix
|
235
|
+
* Fix support for PostgreSQL 11+ partitioned indexes.
|
196
236
|
|
197
|
-
|
237
|
+
*Sebastián Palma*
|
198
238
|
|
199
|
-
|
239
|
+
* Add support for beginless ranges, introduced in Ruby 2.7.
|
200
240
|
|
201
|
-
*
|
241
|
+
*Josh Goodall*
|
202
242
|
|
203
|
-
|
243
|
+
* Fix insert_all with enum values
|
204
244
|
|
205
|
-
|
245
|
+
Fixes #38716.
|
206
246
|
|
207
|
-
*
|
247
|
+
*Joel Blum*
|
208
248
|
|
209
|
-
*
|
249
|
+
* Regexp-escape table name for MS SQL
|
210
250
|
|
211
|
-
|
251
|
+
Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
|
212
252
|
|
213
|
-
*
|
253
|
+
*Larry Reid*
|
214
254
|
|
215
|
-
|
255
|
+
* Store advisory locks on their own named connection.
|
216
256
|
|
217
|
-
|
257
|
+
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
218
258
|
|
219
|
-
|
259
|
+
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
220
260
|
|
221
|
-
*
|
261
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
222
262
|
|
223
|
-
|
263
|
+
* Ensure `:reading` connections always raise if a write is attempted.
|
224
264
|
|
225
|
-
|
265
|
+
Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
|
226
266
|
|
227
|
-
*
|
267
|
+
*Eileen M. Uchitelle*
|
228
268
|
|
229
|
-
*
|
269
|
+
* Enforce fresh ETag header after a collection's contents change by adding
|
270
|
+
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
271
|
+
ActionController::ConditionalGet to ensure that when collection cache versioning
|
272
|
+
is enabled, requests using ConditionalGet don't return the same ETag header
|
273
|
+
after a collection is modified. Fixes #38078.
|
230
274
|
|
231
|
-
*
|
275
|
+
*Aaron Lipman*
|
276
|
+
|
277
|
+
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
|
278
|
+
|
279
|
+
*Joshua Flanagan*
|
280
|
+
|
281
|
+
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
232
282
|
|
283
|
+
Resolves #34889.
|
233
284
|
|
234
|
-
|
285
|
+
*Patrick Rebsch*
|
286
|
+
|
287
|
+
|
288
|
+
## Rails 6.0.2.2 (March 19, 2020) ##
|
235
289
|
|
236
290
|
* No changes.
|
237
291
|
|
238
292
|
|
239
|
-
## Rails
|
293
|
+
## Rails 6.0.2.1 (December 18, 2019) ##
|
240
294
|
|
241
|
-
*
|
295
|
+
* No changes.
|
242
296
|
|
243
|
-
Fixes #33008.
|
244
297
|
|
245
|
-
|
298
|
+
## Rails 6.0.2 (December 13, 2019) ##
|
246
299
|
|
247
|
-
*
|
300
|
+
* Share the same connection pool for primary and replica databases in the
|
301
|
+
transactional tests for the same database.
|
248
302
|
|
249
|
-
*
|
303
|
+
*Edouard Chin*
|
250
304
|
|
251
|
-
* Fix
|
305
|
+
* Fix the preloader when one record is fetched using `after_initialize`
|
306
|
+
but not the entire collection.
|
252
307
|
|
253
|
-
*
|
308
|
+
*Bradley Price*
|
254
309
|
|
255
|
-
* Fix
|
310
|
+
* Fix collection callbacks not terminating when `:abort` is thrown.
|
256
311
|
|
257
|
-
*Ryuta Kamizono*
|
312
|
+
*Edouard Chin*, *Ryuta Kamizono*
|
313
|
+
|
314
|
+
* Correctly deprecate `where.not` working as NOR for relations.
|
315
|
+
|
316
|
+
12a9664 deprecated where.not working as NOR, however
|
317
|
+
doing a relation query like `where.not(relation: { ... })`
|
318
|
+
wouldn't be properly deprecated and `where.not` would work as
|
319
|
+
NAND instead.
|
258
320
|
|
259
|
-
*
|
321
|
+
*Edouard Chin*
|
260
322
|
|
261
|
-
|
323
|
+
* Fix `db:migrate` task with multiple databases to restore the connection
|
324
|
+
to the previous database.
|
325
|
+
|
326
|
+
The migrate task iterates and establish a connection over each db
|
327
|
+
resulting in the last one to be used by subsequent rake tasks.
|
328
|
+
We should reestablish a connection to the connection that was
|
329
|
+
established before the migrate tasks was run
|
330
|
+
|
331
|
+
*Edouard Chin*
|
332
|
+
|
333
|
+
* Fix multi-threaded issue for `AcceptanceValidator`.
|
262
334
|
|
263
335
|
*Ryuta Kamizono*
|
264
336
|
|
265
|
-
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
266
337
|
|
267
|
-
|
338
|
+
## Rails 6.0.1 (November 5, 2019) ##
|
268
339
|
|
269
|
-
*
|
340
|
+
* Common Table Expressions are allowed on read-only connections.
|
270
341
|
|
271
|
-
|
342
|
+
*Chris Morris*
|
272
343
|
|
273
|
-
|
344
|
+
* New record instantiation respects `unscope`.
|
274
345
|
|
275
|
-
*
|
346
|
+
*Ryuta Kamizono*
|
276
347
|
|
277
|
-
|
348
|
+
* Fixed a case where `find_in_batches` could halt too early.
|
278
349
|
|
279
|
-
|
350
|
+
*Takayuki Nakata*
|
280
351
|
|
281
|
-
*
|
352
|
+
* Autosaved associations always perform validations when a custom validation
|
353
|
+
context is used.
|
282
354
|
|
283
|
-
|
355
|
+
*Tekin Suleyman*
|
284
356
|
|
285
|
-
|
357
|
+
* `sql.active_record` notifications now include the `:connection` in
|
358
|
+
their payloads.
|
286
359
|
|
287
|
-
*
|
360
|
+
*Eugene Kenny*
|
288
361
|
|
289
|
-
|
362
|
+
* A rollback encountered in an `after_commit` callback does not reset
|
363
|
+
previously-committed record state.
|
290
364
|
|
291
|
-
*
|
292
|
-
wrongly persists through record.
|
365
|
+
*Ryuta Kamizono*
|
293
366
|
|
294
|
-
|
367
|
+
* Fixed that join order was lost when eager-loading.
|
295
368
|
|
296
|
-
|
369
|
+
*Ryuta Kamizono*
|
297
370
|
|
298
|
-
*
|
299
|
-
query cache.
|
371
|
+
* `DESCRIBE` queries are allowed on read-only connections.
|
300
372
|
|
301
|
-
*
|
373
|
+
*Dylan Thacker-Smith*
|
302
374
|
|
375
|
+
* Fixed that records that had been `inspect`ed could not be marshaled.
|
303
376
|
|
304
|
-
|
377
|
+
*Eugene Kenny*
|
305
378
|
|
306
|
-
*
|
379
|
+
* The connection pool reaper thread is respawned in forked processes. This
|
380
|
+
fixes that idle connections in forked processes wouldn't be reaped.
|
307
381
|
|
308
|
-
*
|
382
|
+
*John Hawthorn*
|
309
383
|
|
310
|
-
*
|
384
|
+
* The memoized result of `ActiveRecord::Relation#take` is properly cleared
|
385
|
+
when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
|
386
|
+
is called.
|
311
387
|
|
312
|
-
|
313
|
-
have a specified precision then on assignment the value is rounded to
|
314
|
-
that precision. This behavior is now applied to time columns as well.
|
388
|
+
*Anmol Arora*
|
315
389
|
|
316
|
-
|
390
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
317
391
|
|
318
|
-
*
|
392
|
+
*Hiroyuki Ishii*
|
319
393
|
|
320
|
-
*
|
394
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
321
395
|
|
322
|
-
|
323
|
-
because until #24542 the quoting for time columns didn't remove the date
|
324
|
-
component. To ensure that values are consistent we now normalize the
|
325
|
-
date component to 2001-01-01 on reading and writing.
|
396
|
+
*Eugene Kenny*
|
326
397
|
|
327
|
-
|
398
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
328
399
|
|
329
|
-
|
400
|
+
In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
|
330
401
|
|
331
|
-
|
332
|
-
was removed however it only removed it when it was 2001-01-01. Now the
|
333
|
-
date component is removed irrespective of what the date is.
|
402
|
+
This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
|
334
403
|
|
335
|
-
*
|
404
|
+
*Eileen M. Uchitelle*
|
336
405
|
|
337
|
-
*
|
338
|
-
the parent class was getting deleted when the child was not.
|
406
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
339
407
|
|
340
|
-
|
408
|
+
*Kir Shatrov*
|
341
409
|
|
342
|
-
*Fernando Gorodscy*
|
343
410
|
|
344
|
-
|
411
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
345
412
|
|
346
|
-
|
413
|
+
* Preserve user supplied joins order as much as possible.
|
347
414
|
|
348
|
-
|
415
|
+
Fixes #36761, #34328, #24281, #12953.
|
349
416
|
|
350
417
|
*Ryuta Kamizono*
|
351
418
|
|
352
|
-
*
|
353
|
-
|
354
|
-
|
419
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
420
|
+
|
421
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
422
|
+
|
423
|
+
* Add a warning for enum elements with 'not_' prefix.
|
355
424
|
|
356
|
-
|
425
|
+
class Foo
|
426
|
+
enum status: [:sent, :not_sent]
|
427
|
+
end
|
428
|
+
|
429
|
+
*Edu Depetris*
|
430
|
+
|
431
|
+
* Make currency symbols optional for money column type in PostgreSQL
|
432
|
+
|
433
|
+
*Joel Schneider*
|
357
434
|
|
358
|
-
*Takumi Kagiyama*
|
359
435
|
|
360
|
-
|
436
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
437
|
+
|
438
|
+
* Add database_exists? method to connection adapters to check if a database exists.
|
439
|
+
|
440
|
+
*Guilherme Mansur*
|
441
|
+
|
442
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
361
443
|
|
362
|
-
Fixes #
|
444
|
+
Fixes #36022.
|
363
445
|
|
364
446
|
*Ryuta Kamizono*
|
365
447
|
|
366
|
-
*
|
448
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
449
|
+
|
450
|
+
Fixes #36465.
|
451
|
+
|
452
|
+
*Jeff Doering*
|
453
|
+
|
454
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
455
|
+
|
456
|
+
*Martin R. Schuster*
|
457
|
+
|
458
|
+
* Fix invalid schema when primary key column has a comment.
|
459
|
+
|
460
|
+
Fixes #29966.
|
367
461
|
|
368
|
-
*
|
462
|
+
*Guilherme Goettems Schneider*
|
369
463
|
|
370
|
-
*
|
371
|
-
|
464
|
+
* Fix table comment also being applied to the primary key column.
|
465
|
+
|
466
|
+
*Guilherme Goettems Schneider*
|
467
|
+
|
468
|
+
* Fix merging left_joins to maintain its own `join_type` context.
|
469
|
+
|
470
|
+
Fixes #36103.
|
372
471
|
|
373
472
|
*Ryuta Kamizono*
|
374
473
|
|
375
|
-
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
|
376
474
|
|
475
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
476
|
+
|
477
|
+
* Add `touch` option to `has_one` association.
|
478
|
+
|
479
|
+
*Abhay Nikam*
|
480
|
+
|
481
|
+
* Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
|
482
|
+
|
483
|
+
```ruby
|
484
|
+
all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
|
485
|
+
assert_equal all, PriceEstimate.all.map(&:estimate_of)
|
377
486
|
```
|
378
|
-
david_balance = customers(:david).balance
|
379
|
-
Customer.where(balance: [david_balance]).to_sql
|
380
487
|
|
381
|
-
|
382
|
-
|
488
|
+
In Rails 6.0:
|
489
|
+
|
490
|
+
```ruby
|
491
|
+
sapphire = treasures(:sapphire)
|
492
|
+
|
493
|
+
nor = all.reject { |e|
|
494
|
+
e.estimate_of_type == sapphire.class.polymorphic_name
|
495
|
+
}.reject { |e|
|
496
|
+
e.estimate_of_id == sapphire.id
|
497
|
+
}
|
498
|
+
assert_equal [cars(:honda)], nor
|
499
|
+
|
500
|
+
without_sapphire = PriceEstimate.where.not(
|
501
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
502
|
+
)
|
503
|
+
assert_equal nor, without_sapphire.map(&:estimate_of)
|
383
504
|
```
|
384
505
|
|
385
|
-
|
506
|
+
In Rails 6.1:
|
507
|
+
|
508
|
+
```ruby
|
509
|
+
sapphire = treasures(:sapphire)
|
510
|
+
|
511
|
+
nand = all - [sapphire]
|
512
|
+
assert_equal [treasures(:diamond), cars(:honda)], nand
|
513
|
+
|
514
|
+
without_sapphire = PriceEstimate.where.not(
|
515
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
516
|
+
)
|
517
|
+
assert_equal nand, without_sapphire.map(&:estimate_of)
|
518
|
+
```
|
386
519
|
|
387
|
-
*
|
520
|
+
*Ryuta Kamizono*
|
388
521
|
|
389
|
-
* Fix
|
522
|
+
* Fix dirty tracking after rollback.
|
390
523
|
|
391
|
-
Fixes #
|
524
|
+
Fixes #15018, #30167, #33868.
|
392
525
|
|
393
526
|
*Ryuta Kamizono*
|
394
527
|
|
395
|
-
*
|
528
|
+
* Add `ActiveRecord::Relation#cache_version` to support recyclable cache keys via
|
529
|
+
the versioned entries in `ActiveSupport::Cache`. This also means that
|
530
|
+
`ActiveRecord::Relation#cache_key` will now return a stable key that does not
|
531
|
+
include the max timestamp or count any more.
|
396
532
|
|
397
|
-
|
533
|
+
NOTE: This feature is turned off by default, and `cache_key` will still return
|
534
|
+
cache keys with timestamps until you set `ActiveRecord::Base.collection_cache_versioning = true`.
|
535
|
+
That's the setting for all new apps on Rails 6.0+
|
398
536
|
|
399
|
-
*
|
537
|
+
*Lachlan Sylvester*
|
400
538
|
|
401
|
-
*
|
539
|
+
* Fix dirty tracking for `touch` to track saved changes.
|
402
540
|
|
403
|
-
|
541
|
+
Fixes #33429.
|
404
542
|
|
405
|
-
*
|
543
|
+
*Ryuta Kamzono*
|
406
544
|
|
407
|
-
|
545
|
+
* `change_column_comment` and `change_table_comment` are invertible only if
|
546
|
+
`to` and `from` options are specified.
|
547
|
+
|
548
|
+
*Yoshiyuki Kinjo*
|
549
|
+
|
550
|
+
* Don't call commit/rollback callbacks when a record isn't saved.
|
408
551
|
|
409
|
-
|
552
|
+
Fixes #29747.
|
410
553
|
|
411
554
|
*Ryuta Kamizono*
|
412
555
|
|
413
|
-
*
|
556
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
414
557
|
|
415
|
-
|
558
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
559
|
+
associations, the callback for a `has_many` association was run while
|
560
|
+
another instance of the same callback on the same association hadn't
|
561
|
+
finished running. When control returned to the first instance of the
|
562
|
+
callback, the instance variable had changed, and subsequent associated
|
563
|
+
records weren't saved correctly. Specifically, the ID field for the
|
564
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
416
565
|
|
417
|
-
|
566
|
+
Fixes #28080.
|
418
567
|
|
419
|
-
*
|
568
|
+
*Larry Reid*
|
420
569
|
|
421
|
-
|
570
|
+
* Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options.
|
422
571
|
|
423
|
-
|
424
|
-
belongs_to :author
|
425
|
-
has_many :books, through: :author
|
426
|
-
has_many :subscriptions, through: :books
|
427
|
-
end
|
572
|
+
Before:
|
428
573
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
574
|
+
```ruby
|
575
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
576
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
577
|
+
add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
|
578
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
|
579
|
+
```
|
434
580
|
|
435
|
-
|
436
|
-
belongs_to :author
|
437
|
-
has_many :subscriptions
|
438
|
-
end
|
581
|
+
After:
|
439
582
|
|
440
|
-
|
441
|
-
|
442
|
-
|
583
|
+
```ruby
|
584
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
585
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
586
|
+
add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
|
587
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
|
588
|
+
```
|
589
|
+
|
590
|
+
*Ryuta Kamizono*
|
591
|
+
|
592
|
+
* Association loading isn't to be affected by scoping consistently
|
593
|
+
whether preloaded / eager loaded or not, with the exception of `unscoped`.
|
443
594
|
|
444
595
|
Before:
|
445
596
|
|
446
|
-
|
597
|
+
```ruby
|
598
|
+
Post.where("1=0").scoping do
|
599
|
+
Comment.find(1).post # => nil
|
600
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
601
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
602
|
+
end
|
603
|
+
```
|
447
604
|
|
448
605
|
After:
|
449
606
|
|
450
|
-
|
451
|
-
|
607
|
+
```ruby
|
608
|
+
Post.where("1=0").scoping do
|
609
|
+
Comment.find(1).post # => #<Post id: 1, ...>
|
610
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
611
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
612
|
+
end
|
613
|
+
```
|
614
|
+
|
615
|
+
Fixes #34638, #35398.
|
616
|
+
|
617
|
+
*Ryuta Kamizono*
|
618
|
+
|
619
|
+
* Add `rails db:prepare` to migrate or setup a database.
|
620
|
+
|
621
|
+
Runs `db:migrate` if the database exists or `db:setup` if it doesn't.
|
622
|
+
|
623
|
+
*Roberto Miranda*
|
452
624
|
|
453
|
-
|
625
|
+
* Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
|
454
626
|
|
455
|
-
*
|
627
|
+
*DHH*
|
456
628
|
|
457
|
-
*
|
458
|
-
|
459
|
-
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
629
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
630
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
460
631
|
|
461
|
-
Fixes #
|
632
|
+
Fixes #33249.
|
462
633
|
|
463
|
-
*
|
634
|
+
*Ryan H. Kerr*
|
464
635
|
|
465
|
-
*
|
466
|
-
SQL queries for association counting.
|
636
|
+
* Add `ActiveRecord::Relation#extract_associated` for extracting associated records from a relation.
|
467
637
|
|
468
|
-
|
638
|
+
```
|
639
|
+
account.memberships.extract_associated(:user)
|
640
|
+
# => Returns collection of User records
|
641
|
+
```
|
469
642
|
|
470
|
-
*
|
643
|
+
*DHH*
|
471
644
|
|
472
|
-
|
645
|
+
* Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
|
473
646
|
|
474
|
-
|
647
|
+
For example:
|
475
648
|
|
476
|
-
|
649
|
+
```
|
650
|
+
Post.where(id: 123).annotate("this is a comment").to_sql
|
651
|
+
# SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
|
652
|
+
```
|
477
653
|
|
478
|
-
|
654
|
+
This can be useful in instrumentation or other analysis of issued queries.
|
479
655
|
|
480
|
-
*
|
656
|
+
*Matt Yoho*
|
481
657
|
|
482
|
-
*
|
483
|
-
information.
|
658
|
+
* Support Optimizer Hints.
|
484
659
|
|
485
|
-
|
660
|
+
In most databases, a way to control the optimizer is by using optimizer hints,
|
661
|
+
which can be specified within individual statements.
|
486
662
|
|
487
|
-
|
663
|
+
Example (for MySQL):
|
488
664
|
|
489
|
-
|
490
|
-
|
491
|
-
and other debugging.
|
665
|
+
Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
|
666
|
+
# SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
|
492
667
|
|
493
|
-
|
494
|
-
recommended for use in the production environment since it relies
|
495
|
-
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
668
|
+
Example (for PostgreSQL with pg_hint_plan):
|
496
669
|
|
497
|
-
|
670
|
+
Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
|
671
|
+
# SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
|
498
672
|
|
499
|
-
|
673
|
+
See also:
|
674
|
+
|
675
|
+
* https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
|
676
|
+
* https://pghintplan.osdn.jp/pg_hint_plan.html
|
677
|
+
* https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
|
678
|
+
* https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
|
679
|
+
* https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
|
680
|
+
|
681
|
+
*Ryuta Kamizono*
|
682
|
+
|
683
|
+
* Fix query attribute method on user-defined attribute to be aware of typecasted value.
|
684
|
+
|
685
|
+
For example, the following code no longer return false as casted non-empty string:
|
500
686
|
|
501
687
|
```
|
502
|
-
|
503
|
-
|
504
|
-
# t.integer :lock_version
|
505
|
-
# t.timestamps
|
506
|
-
# end
|
507
|
-
class Post < ApplicationRecord
|
688
|
+
class Post < ActiveRecord::Base
|
689
|
+
attribute :user_defined_text, :text
|
508
690
|
end
|
509
691
|
|
510
|
-
|
511
|
-
# t.belongs_to :post
|
512
|
-
# end
|
513
|
-
class Comment < ApplicationRecord
|
514
|
-
belongs_to :post, touch: true, counter_cache: true
|
515
|
-
end
|
692
|
+
Post.new(user_defined_text: "false").user_defined_text? # => true
|
516
693
|
```
|
517
694
|
|
518
|
-
|
519
|
-
```
|
520
|
-
post = Post.create!
|
521
|
-
# => begin transaction
|
522
|
-
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
523
|
-
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
524
|
-
commit transaction
|
525
|
-
|
526
|
-
comment = Comment.create!(post: post)
|
527
|
-
# => begin transaction
|
528
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
529
|
-
|
530
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
531
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
532
|
-
|
533
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
534
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
535
|
-
rollback transaction
|
536
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
537
|
-
|
538
|
-
Comment.take.destroy!
|
539
|
-
# => begin transaction
|
540
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
541
|
-
|
542
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
543
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
544
|
-
|
545
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
546
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
547
|
-
rollback transaction
|
548
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
549
|
-
```
|
695
|
+
*Yuji Kamijima*
|
550
696
|
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
565
|
-
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
566
|
-
commit transaction
|
567
|
-
|
568
|
-
comment.destroy!
|
569
|
-
# => begin transaction
|
570
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
571
|
-
|
572
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
573
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
574
|
-
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
575
|
-
commit transaction
|
576
|
-
```
|
697
|
+
* Quote empty ranges like other empty enumerables.
|
698
|
+
|
699
|
+
*Patrick Rebsch*
|
700
|
+
|
701
|
+
* Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`,
|
702
|
+
allowing bulk inserts akin to the bulk updates provided by `update_all` and
|
703
|
+
bulk deletes by `delete_all`.
|
704
|
+
|
705
|
+
Supports skipping or upserting duplicates through the `ON CONFLICT` syntax
|
706
|
+
for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
|
707
|
+
for MySQL.
|
708
|
+
|
709
|
+
*Bob Lail*
|
577
710
|
|
578
|
-
|
711
|
+
* Add `rails db:seed:replant` that truncates tables of each database
|
712
|
+
for current environment and loads the seeds.
|
713
|
+
|
714
|
+
*bogdanvlviv*, *DHH*
|
715
|
+
|
716
|
+
* Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter.
|
579
717
|
|
580
718
|
*bogdanvlviv*
|
581
719
|
|
582
|
-
*
|
720
|
+
* Deprecate mismatched collation comparison for uniqueness validator.
|
721
|
+
|
722
|
+
Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
|
723
|
+
To continue case sensitive comparison on the case insensitive column,
|
724
|
+
pass `case_sensitive: true` option explicitly to the uniqueness validator.
|
725
|
+
|
726
|
+
*Ryuta Kamizono*
|
727
|
+
|
728
|
+
* Add `reselect` method. This is a short-hand for `unscope(:select).select(fields)`.
|
729
|
+
|
730
|
+
Fixes #27340.
|
731
|
+
|
732
|
+
*Willian Gustavo Veiga*
|
733
|
+
|
734
|
+
* Add negative scopes for all enum values.
|
583
735
|
|
584
736
|
Example:
|
585
737
|
|
586
|
-
|
738
|
+
class Post < ActiveRecord::Base
|
739
|
+
enum status: %i[ drafted active trashed ]
|
740
|
+
end
|
587
741
|
|
588
|
-
|
742
|
+
Post.not_drafted # => where.not(status: :drafted)
|
743
|
+
Post.not_active # => where.not(status: :active)
|
744
|
+
Post.not_trashed # => where.not(status: :trashed)
|
745
|
+
|
746
|
+
*DHH*
|
747
|
+
|
748
|
+
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
749
|
+
|
750
|
+
Fixes #35214.
|
751
|
+
|
752
|
+
*Juani Villarejo*
|
589
753
|
|
590
|
-
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
591
754
|
|
592
|
-
|
755
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
756
|
+
|
757
|
+
* No changes.
|
593
758
|
|
594
|
-
*kinnrot*
|
595
759
|
|
596
|
-
|
597
|
-
|
760
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
761
|
+
|
762
|
+
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
598
763
|
|
599
764
|
*Ryuta Kamizono*
|
600
765
|
|
601
|
-
*
|
602
|
-
migrating up, e.g. populating a new column.
|
766
|
+
* Ensure `update_all` series cares about optimistic locking.
|
603
767
|
|
604
|
-
*
|
768
|
+
*Ryuta Kamizono*
|
605
769
|
|
606
|
-
*
|
607
|
-
relation query methods.
|
770
|
+
* Don't allow `where` with non numeric string matches to 0 values.
|
608
771
|
|
609
|
-
|
610
|
-
```
|
611
|
-
Article.order("LENGTH(title)")
|
612
|
-
```
|
772
|
+
*Ryuta Kamizono*
|
613
773
|
|
614
|
-
|
615
|
-
```
|
616
|
-
Article.order(Arel.sql("LENGTH(title)"))
|
617
|
-
```
|
774
|
+
* Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`.
|
618
775
|
|
619
|
-
|
620
|
-
|
621
|
-
mistaken belief that only column names will be accepted.
|
776
|
+
`destroy_by` allows relation to find all the records matching the condition and perform
|
777
|
+
`destroy_all` on the matched records.
|
622
778
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
779
|
+
Example:
|
780
|
+
|
781
|
+
Person.destroy_by(name: 'David')
|
782
|
+
Person.destroy_by(name: 'David', rating: 4)
|
783
|
+
|
784
|
+
david = Person.find_by(name: 'David')
|
785
|
+
david.posts.destroy_by(id: [1, 2, 3])
|
786
|
+
|
787
|
+
`delete_by` allows relation to find all the records matching the condition and perform
|
788
|
+
`delete_all` on the matched records.
|
789
|
+
|
790
|
+
Example:
|
791
|
+
|
792
|
+
Person.delete_by(name: 'David')
|
793
|
+
Person.delete_by(name: 'David', rating: 4)
|
794
|
+
|
795
|
+
david = Person.find_by(name: 'David')
|
796
|
+
david.posts.delete_by(id: [1, 2, 3])
|
797
|
+
|
798
|
+
*Abhay Nikam*
|
799
|
+
|
800
|
+
* Don't allow `where` with invalid value matches to nil values.
|
801
|
+
|
802
|
+
Fixes #33624.
|
803
|
+
|
804
|
+
*Ryuta Kamizono*
|
805
|
+
|
806
|
+
* SQLite3: Implement `add_foreign_key` and `remove_foreign_key`.
|
807
|
+
|
808
|
+
*Ryuta Kamizono*
|
809
|
+
|
810
|
+
* Deprecate using class level querying methods if the receiver scope
|
811
|
+
regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
|
812
|
+
|
813
|
+
*Ryuta Kamizono*
|
814
|
+
|
815
|
+
* Allow applications to automatically switch connections.
|
816
|
+
|
817
|
+
Adds a middleware and configuration options that can be used in your
|
818
|
+
application to automatically switch between the writing and reading
|
819
|
+
database connections.
|
820
|
+
|
821
|
+
`GET` and `HEAD` requests will read from the replica unless there was
|
822
|
+
a write in the last 2 seconds, otherwise they will read from the primary.
|
823
|
+
Non-get requests will always write to the primary. The middleware accepts
|
824
|
+
an argument for a Resolver class and an Operations class where you are able
|
825
|
+
to change how the auto-switcher works to be most beneficial for your
|
826
|
+
application.
|
827
|
+
|
828
|
+
To use the middleware in your application you can use the following
|
829
|
+
configuration options:
|
627
830
|
|
628
|
-
Common and judged-safe string values (such as simple column
|
629
|
-
references) are unaffected:
|
630
831
|
```
|
631
|
-
|
832
|
+
config.active_record.database_selector = { delay: 2.seconds }
|
833
|
+
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
834
|
+
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
632
835
|
```
|
633
836
|
|
634
|
-
|
837
|
+
To change the database selection strategy, pass a custom class to the
|
838
|
+
configuration options:
|
635
839
|
|
636
|
-
|
637
|
-
|
638
|
-
|
840
|
+
```
|
841
|
+
config.active_record.database_selector = { delay: 10.seconds }
|
842
|
+
config.active_record.database_resolver = MyResolver
|
843
|
+
config.active_record.database_resolver_context = MyResolver::MyCookies
|
844
|
+
```
|
639
845
|
|
640
|
-
*
|
846
|
+
*Eileen M. Uchitelle*
|
641
847
|
|
642
|
-
*
|
643
|
-
when statement timeout exceeded.
|
848
|
+
* MySQL: Support `:size` option to change text and blob size.
|
644
849
|
|
645
850
|
*Ryuta Kamizono*
|
646
851
|
|
647
|
-
*
|
648
|
-
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
649
|
-
Check a format of `VERSION`: Allow a migration version number
|
650
|
-
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
651
|
-
Raise error if target migration doesn't exist.
|
652
|
-
|
653
|
-
*bogdanvlviv*
|
852
|
+
* Make `t.timestamps` with precision by default.
|
654
853
|
|
655
|
-
*
|
656
|
-
`db/schema.rb` when using the sqlite adapter.
|
854
|
+
*Ryuta Kamizono*
|
657
855
|
|
658
|
-
Fixes #30902.
|
659
856
|
|
660
|
-
|
857
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
661
858
|
|
662
|
-
* Remove deprecated
|
859
|
+
* Remove deprecated `#set_state` from the transaction object.
|
663
860
|
|
664
861
|
*Rafael Mendonça França*
|
665
862
|
|
666
|
-
* Remove deprecated
|
863
|
+
* Remove deprecated `#supports_statement_cache?` from the database adapters.
|
667
864
|
|
668
865
|
*Rafael Mendonça França*
|
669
866
|
|
670
|
-
* Remove deprecated
|
867
|
+
* Remove deprecated `#insert_fixtures` from the database adapters.
|
671
868
|
|
672
869
|
*Rafael Mendonça França*
|
673
870
|
|
674
|
-
* Remove deprecated
|
871
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
|
675
872
|
|
676
873
|
*Rafael Mendonça França*
|
677
874
|
|
678
|
-
*
|
875
|
+
* Do not allow passing the column name to `sum` when a block is passed.
|
679
876
|
|
680
877
|
*Rafael Mendonça França*
|
681
878
|
|
682
|
-
*
|
879
|
+
* Do not allow passing the column name to `count` when a block is passed.
|
683
880
|
|
684
881
|
*Rafael Mendonça França*
|
685
882
|
|
686
|
-
* Remove
|
883
|
+
* Remove delegation of missing methods in a relation to arel.
|
687
884
|
|
688
885
|
*Rafael Mendonça França*
|
689
886
|
|
690
|
-
* Remove
|
887
|
+
* Remove delegation of missing methods in a relation to private methods of the class.
|
691
888
|
|
692
889
|
*Rafael Mendonça França*
|
693
890
|
|
694
|
-
*
|
891
|
+
* Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
|
695
892
|
|
696
893
|
*Rafael Mendonça França*
|
697
894
|
|
698
|
-
*
|
895
|
+
* Change `SQLite3Adapter` to always represent boolean values as integers.
|
699
896
|
|
700
897
|
*Rafael Mendonça França*
|
701
898
|
|
702
|
-
* Remove
|
899
|
+
* Remove ability to specify a timestamp name for `#cache_key`.
|
703
900
|
|
704
901
|
*Rafael Mendonça França*
|
705
902
|
|
706
|
-
* Remove deprecated
|
903
|
+
* Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
|
707
904
|
|
708
905
|
*Rafael Mendonça França*
|
709
906
|
|
710
|
-
* Remove deprecated
|
907
|
+
* Remove deprecated `expand_hash_conditions_for_aggregates`.
|
711
908
|
|
712
909
|
*Rafael Mendonça França*
|
713
910
|
|
714
|
-
*
|
715
|
-
ar_internal_metadata's data for a test database.
|
911
|
+
* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
|
716
912
|
|
717
|
-
|
718
|
-
```
|
719
|
-
$ RAILS_ENV=test rails dbconsole
|
720
|
-
> SELECT * FROM ar_internal_metadata;
|
721
|
-
key|value|created_at|updated_at
|
722
|
-
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
723
|
-
```
|
913
|
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
|
724
914
|
|
725
|
-
|
726
|
-
```
|
727
|
-
$ RAILS_ENV=test rails dbconsole
|
728
|
-
> SELECT * FROM ar_internal_metadata;
|
729
|
-
key|value|created_at|updated_at
|
730
|
-
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
731
|
-
```
|
915
|
+
*Laerti Papa*
|
732
916
|
|
733
|
-
|
917
|
+
* Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
|
734
918
|
|
735
|
-
*
|
919
|
+
*Gannon McGibbon*
|
736
920
|
|
737
|
-
*
|
921
|
+
* Add support for endless ranges introduces in Ruby 2.6.
|
738
922
|
|
739
|
-
|
923
|
+
*Greg Navis*
|
924
|
+
|
925
|
+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
|
740
926
|
|
741
927
|
*Ryuta Kamizono*
|
742
928
|
|
743
|
-
* MySQL:
|
929
|
+
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
|
744
930
|
|
745
|
-
|
931
|
+
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
|
932
|
+
format for InnoDB tables. The default setting is `DYNAMIC`.
|
933
|
+
The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
|
746
934
|
|
747
935
|
*Ryuta Kamizono*
|
748
936
|
|
749
|
-
* Fix
|
937
|
+
* Fix join table column quoting with SQLite.
|
938
|
+
|
939
|
+
*Gannon McGibbon*
|
940
|
+
|
941
|
+
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
750
942
|
|
751
|
-
|
943
|
+
*Alfred Dominic*
|
944
|
+
|
945
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
752
946
|
|
753
947
|
*Ryuta Kamizono*
|
754
948
|
|
755
|
-
*
|
949
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
950
|
+
|
951
|
+
*Gannon McGibbon*
|
756
952
|
|
757
|
-
|
758
|
-
this datatype in Active Record. However, the serialization of
|
759
|
-
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
760
|
-
cast the bounds that make up the range. This led to subseconds being
|
761
|
-
dropped in SQL commands:
|
953
|
+
* Add the ability to prevent writes to a database for the duration of a block.
|
762
954
|
|
763
|
-
|
955
|
+
Allows the application to prevent writes to a database. This can be useful when
|
956
|
+
you're building out multiple databases and want to make sure you're not sending
|
957
|
+
writes when you want a read.
|
764
958
|
|
765
|
-
|
766
|
-
|
959
|
+
If `while_preventing_writes` is called and the query is considered a write
|
960
|
+
query the database will raise an exception regardless of whether the database
|
961
|
+
user is able to write.
|
767
962
|
|
768
|
-
|
963
|
+
This is not meant to be a catch-all for write queries but rather a way to enforce
|
964
|
+
read-only queries without opening a second connection. One purpose of this is to
|
965
|
+
catch accidental writes, not all writes.
|
769
966
|
|
770
|
-
|
771
|
-
# => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
|
967
|
+
*Eileen M. Uchitelle*
|
772
968
|
|
773
|
-
|
969
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
774
970
|
|
775
|
-
*
|
776
|
-
array.
|
971
|
+
*Gannon McGibbon*
|
777
972
|
|
778
|
-
|
973
|
+
* Allow spaces in postgres table names.
|
974
|
+
|
975
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
|
779
976
|
|
780
|
-
*
|
977
|
+
*Gannon McGibbon*
|
781
978
|
|
782
|
-
|
979
|
+
* Cached `columns_hash` fields should be excluded from `ResultSet#column_types`.
|
783
980
|
|
784
|
-
|
981
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
982
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
983
|
+
|
984
|
+
```ruby
|
985
|
+
class DeveloperName < ActiveRecord::Type::String
|
986
|
+
def deserialize(value)
|
987
|
+
"Developer: #{value}"
|
988
|
+
end
|
989
|
+
end
|
990
|
+
|
991
|
+
class AttributedDeveloper < ActiveRecord::Base
|
992
|
+
self.table_name = "developers"
|
993
|
+
|
994
|
+
attribute :name, DeveloperName.new
|
995
|
+
|
996
|
+
self.ignored_columns += ["name"]
|
997
|
+
end
|
998
|
+
|
999
|
+
developer = AttributedDeveloper.create
|
1000
|
+
developer.update_column :name, "name"
|
785
1001
|
|
786
|
-
|
787
|
-
|
1002
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
1003
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
1004
|
+
```
|
1005
|
+
|
1006
|
+
*Dmitry Tsepelev*
|
788
1007
|
|
789
|
-
|
1008
|
+
* Make the implicit order column configurable.
|
790
1009
|
|
791
|
-
|
1010
|
+
When calling ordered finder methods such as `first` or `last` without an
|
1011
|
+
explicit order clause, ActiveRecord sorts records by primary key. This can
|
1012
|
+
result in unpredictable and surprising behaviour when the primary key is
|
1013
|
+
not an auto-incrementing integer, for example when it's a UUID. This change
|
1014
|
+
makes it possible to override the column used for implicit ordering such
|
1015
|
+
that `first` and `last` will return more predictable results.
|
792
1016
|
|
793
|
-
|
794
|
-
when lock wait timeout exceeded.
|
1017
|
+
Example:
|
795
1018
|
|
796
|
-
|
1019
|
+
class Project < ActiveRecord::Base
|
1020
|
+
self.implicit_order_column = "created_at"
|
1021
|
+
end
|
797
1022
|
|
798
|
-
*
|
1023
|
+
*Tekin Suleyman*
|
799
1024
|
|
800
|
-
|
1025
|
+
* Bump minimum PostgreSQL version to 9.3.
|
801
1026
|
|
802
|
-
*
|
1027
|
+
*Yasuo Honda*
|
803
1028
|
|
804
|
-
|
1029
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
805
1030
|
|
806
|
-
*
|
1031
|
+
*Emmanuel Byrd*
|
807
1032
|
|
808
|
-
|
1033
|
+
* Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
|
809
1034
|
|
810
|
-
|
1035
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
|
811
1036
|
|
812
|
-
|
1037
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
|
813
1038
|
|
814
|
-
|
1039
|
+
Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
|
815
1040
|
|
816
|
-
|
1041
|
+
Example:
|
817
1042
|
|
818
|
-
|
1043
|
+
```
|
1044
|
+
class MySubclassedError < ActiveRecord::StatementInvalid
|
1045
|
+
def initialize(message, sql:, binds:)
|
1046
|
+
super(message, sql: sql, binds: binds)
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
```
|
819
1050
|
|
820
|
-
*
|
821
|
-
`references` only, as `references` can be implicitly called by `where`.
|
1051
|
+
*Gannon McGibbon*
|
822
1052
|
|
823
|
-
|
1053
|
+
* Add an `:if_not_exists` option to `create_table`.
|
1054
|
+
|
1055
|
+
Example:
|
1056
|
+
|
1057
|
+
create_table :posts, if_not_exists: true do |t|
|
1058
|
+
t.string :title
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
That would execute:
|
1062
|
+
|
1063
|
+
CREATE TABLE IF NOT EXISTS posts (
|
1064
|
+
...
|
1065
|
+
)
|
1066
|
+
|
1067
|
+
If the table already exists, `if_not_exists: false` (the default) raises an
|
1068
|
+
exception whereas `if_not_exists: true` does nothing.
|
1069
|
+
|
1070
|
+
*fatkodima*, *Stefan Kanev*
|
1071
|
+
|
1072
|
+
* Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
|
1073
|
+
|
1074
|
+
*Christophe Maximin*
|
1075
|
+
|
1076
|
+
* Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
|
1077
|
+
|
1078
|
+
*Gannon McGibbon*
|
1079
|
+
|
1080
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
1081
|
+
if the attribute does not exist.
|
824
1082
|
|
825
1083
|
*Sean Griffin*
|
826
1084
|
|
827
|
-
*
|
828
|
-
need to generate it, it can be created with `rails g application_record`.
|
1085
|
+
* Add support for hash and URL configs in database hash of `ActiveRecord::Base.connected_to`.
|
829
1086
|
|
830
|
-
|
1087
|
+
````
|
1088
|
+
User.connected_to(database: { writing: "postgres://foo" }) do
|
1089
|
+
User.create!(name: "Gannon")
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
|
1093
|
+
User.connected_to(database: { reading: config }) do
|
1094
|
+
User.count
|
1095
|
+
end
|
1096
|
+
````
|
1097
|
+
|
1098
|
+
*Gannon McGibbon*
|
1099
|
+
|
1100
|
+
* Support default expression for MySQL.
|
1101
|
+
|
1102
|
+
MySQL 8.0.13 and higher supports default value to be a function or expression.
|
1103
|
+
|
1104
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-table.html
|
831
1105
|
|
832
|
-
*
|
1106
|
+
*Ryuta Kamizono*
|
1107
|
+
|
1108
|
+
* Support expression indexes for MySQL.
|
1109
|
+
|
1110
|
+
MySQL 8.0.13 and higher supports functional key parts that index
|
1111
|
+
expression values rather than column or column prefix values.
|
1112
|
+
|
1113
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-index.html
|
833
1114
|
|
834
1115
|
*Ryuta Kamizono*
|
835
1116
|
|
836
|
-
*
|
837
|
-
|
838
|
-
|
1117
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
1118
|
+
|
1119
|
+
Fixes #33056.
|
1120
|
+
|
1121
|
+
*Federico Martinez*
|
1122
|
+
|
1123
|
+
* Add basic API for connection switching to support multiple databases.
|
1124
|
+
|
1125
|
+
1) Adds a `connects_to` method for models to connect to multiple databases. Example:
|
1126
|
+
|
1127
|
+
```
|
1128
|
+
class AnimalsModel < ApplicationRecord
|
1129
|
+
self.abstract_class = true
|
1130
|
+
|
1131
|
+
connects_to database: { writing: :animals_primary, reading: :animals_replica }
|
1132
|
+
end
|
839
1133
|
|
840
|
-
|
1134
|
+
class Dog < AnimalsModel
|
1135
|
+
# connected to both the animals_primary db for writing and the animals_replica for reading
|
1136
|
+
end
|
1137
|
+
```
|
841
1138
|
|
842
|
-
|
1139
|
+
2) Adds a `connected_to` block method for switching connection roles or connecting to
|
1140
|
+
a database that the model didn't connect to. Connecting to the database in this block is
|
1141
|
+
useful when you have another defined connection, for example `slow_replica` that you don't
|
1142
|
+
want to connect to by default but need in the console, or a specific code block.
|
843
1143
|
|
844
|
-
|
845
|
-
|
1144
|
+
```
|
1145
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
1146
|
+
Dog.first # finds dog from replica connected to AnimalsBase
|
1147
|
+
Book.first # doesn't have a reading connection, will raise an error
|
1148
|
+
end
|
1149
|
+
```
|
846
1150
|
|
847
1151
|
```
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
# With fix:
|
852
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
1152
|
+
ActiveRecord::Base.connected_to(database: :slow_replica) do
|
1153
|
+
SlowReplicaModel.first # if the db config has a slow_replica configuration this will be used to do the lookup, otherwise this will throw an exception
|
1154
|
+
end
|
853
1155
|
```
|
854
1156
|
|
855
|
-
*
|
1157
|
+
*Eileen M. Uchitelle*
|
856
1158
|
|
857
|
-
*
|
858
|
-
post-type-cast value for rendering in single-field form inputs.
|
1159
|
+
* Enum raises on invalid definition values
|
859
1160
|
|
860
|
-
|
1161
|
+
When defining a Hash enum it can be easy to use `[]` instead of `{}`. This
|
1162
|
+
commit checks that only valid definition values are provided, those can
|
1163
|
+
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
1164
|
+
raises an `ArgumentError`.
|
861
1165
|
|
862
|
-
|
863
|
-
`current_scope`, with the exception of `unscoped`.
|
1166
|
+
Fixes #33961
|
864
1167
|
|
865
|
-
|
1168
|
+
*Alberto Almagro*
|
866
1169
|
|
867
|
-
|
1170
|
+
* Reloading associations now clears the Query Cache like `Persistence#reload` does.
|
868
1171
|
|
869
|
-
|
1172
|
+
```
|
1173
|
+
class Post < ActiveRecord::Base
|
1174
|
+
has_one :category
|
1175
|
+
belongs_to :author
|
1176
|
+
has_many :comments
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
# Each of the following will now clear the query cache.
|
1180
|
+
post.reload_category
|
1181
|
+
post.reload_author
|
1182
|
+
post.comments.reload
|
1183
|
+
```
|
870
1184
|
|
871
|
-
|
872
|
-
recognize 't' and 'f' as was previously serialized.
|
1185
|
+
*Christophe Maximin*
|
873
1186
|
|
874
|
-
|
875
|
-
|
876
|
-
|
1187
|
+
* Added `index` option for `change_table` migration helpers.
|
1188
|
+
With this change you can create indexes while adding new
|
1189
|
+
columns into the existing tables.
|
877
1190
|
|
878
|
-
|
1191
|
+
Example:
|
879
1192
|
|
880
|
-
|
881
|
-
|
1193
|
+
change_table(:languages) do |t|
|
1194
|
+
t.string :country_code, index: true
|
1195
|
+
end
|
882
1196
|
|
883
|
-
|
884
|
-
until the end of the request or job.
|
1197
|
+
*Mehmet Emin İNAÇ*
|
885
1198
|
|
886
|
-
|
1199
|
+
* Fix `transaction` reverting for migrations.
|
887
1200
|
|
888
|
-
|
889
|
-
`
|
1201
|
+
Before: Commands inside a `transaction` in a reverted migration ran uninverted.
|
1202
|
+
Now: This change fixes that by reverting commands inside `transaction` block.
|
890
1203
|
|
891
|
-
*
|
1204
|
+
*fatkodima*, *David Verhasselt*
|
892
1205
|
|
893
|
-
*
|
1206
|
+
* Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
|
894
1207
|
|
895
|
-
|
1208
|
+
*Gannon McGibbon*, *Max Albrecht*
|
1209
|
+
|
1210
|
+
* Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
|
1211
|
+
|
1212
|
+
*Gannon McGibbon*
|
1213
|
+
|
1214
|
+
* Don't update counter cache unless the record is actually saved.
|
1215
|
+
|
1216
|
+
Fixes #31493, #33113, #33117.
|
896
1217
|
|
897
1218
|
*Ryuta Kamizono*
|
898
1219
|
|
899
|
-
*
|
1220
|
+
* Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
|
900
1221
|
|
901
|
-
|
902
|
-
inner transaction would still be marked as persisted.
|
1222
|
+
*Gannon McGibbon*, *Kevin Cheng*
|
903
1223
|
|
904
|
-
|
905
|
-
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
1224
|
+
* SQLite3 adapter supports expression indexes.
|
906
1225
|
|
907
|
-
|
1226
|
+
```
|
1227
|
+
create_table :users do |t|
|
1228
|
+
t.string :email
|
1229
|
+
end
|
908
1230
|
|
909
|
-
|
1231
|
+
add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
|
1232
|
+
```
|
910
1233
|
|
911
|
-
|
912
|
-
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
913
|
-
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
1234
|
+
*Gray Kemmey*
|
914
1235
|
|
915
|
-
|
1236
|
+
* Allow subclasses to redefine autosave callbacks for associated records.
|
1237
|
+
|
1238
|
+
Fixes #33305.
|
1239
|
+
|
1240
|
+
*Andrey Subbota*
|
1241
|
+
|
1242
|
+
* Bump minimum MySQL version to 5.5.8.
|
1243
|
+
|
1244
|
+
*Yasuo Honda*
|
1245
|
+
|
1246
|
+
* Use MySQL utf8mb4 character set by default.
|
1247
|
+
|
1248
|
+
`utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
|
1249
|
+
The previous default 3-Byte encoding character set `utf8` is not enough to support them.
|
1250
|
+
|
1251
|
+
*Yasuo Honda*
|
1252
|
+
|
1253
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
1254
|
+
|
1255
|
+
*Darwin Wu*
|
1256
|
+
|
1257
|
+
* Configuration item `config.filter_parameters` could also filter out
|
1258
|
+
sensitive values of database columns when calling `#inspect`.
|
1259
|
+
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
1260
|
+
specify sensitive attributes to specific model.
|
1261
|
+
|
1262
|
+
```
|
1263
|
+
Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
|
1264
|
+
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
|
1265
|
+
SecureAccount.filter_attributes += [:name]
|
1266
|
+
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
|
1267
|
+
```
|
1268
|
+
|
1269
|
+
*Zhang Kang*, *Yoshiyuki Kinjo*
|
916
1270
|
|
917
|
-
* Deprecate
|
1271
|
+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
|
1272
|
+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
1273
|
+
and `joins_per_query` methods in `DatabaseLimits`.
|
918
1274
|
|
919
1275
|
*Ryuta Kamizono*
|
920
1276
|
|
921
|
-
*
|
922
|
-
without being connected.
|
1277
|
+
* `ActiveRecord::Base.configurations` now returns an object.
|
923
1278
|
|
924
|
-
|
1279
|
+
`ActiveRecord::Base.configurations` used to return a hash, but this
|
1280
|
+
is an inflexible data model. In order to improve multiple-database
|
1281
|
+
handling in Rails, we've changed this to return an object. Some methods
|
1282
|
+
are provided to make the object behave hash-like in order to ease the
|
1283
|
+
transition process. Since most applications don't manipulate the hash
|
1284
|
+
we've decided to add backwards-compatible functionality that will throw
|
1285
|
+
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
1286
|
+
will use the new version internally and externally.
|
925
1287
|
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
1288
|
+
For example, the following `database.yml`:
|
1289
|
+
|
1290
|
+
```
|
1291
|
+
development:
|
1292
|
+
adapter: sqlite3
|
1293
|
+
database: db/development.sqlite3
|
1294
|
+
```
|
930
1295
|
|
931
|
-
|
1296
|
+
Used to become a hash:
|
932
1297
|
|
933
|
-
|
934
|
-
|
1298
|
+
```
|
1299
|
+
{ "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
|
1300
|
+
```
|
935
1301
|
|
936
|
-
|
1302
|
+
Is now converted into the following object:
|
937
1303
|
|
938
1304
|
```
|
939
|
-
|
940
|
-
|
941
|
-
|
1305
|
+
#<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
|
1306
|
+
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
|
1307
|
+
@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
|
1308
|
+
]
|
1309
|
+
```
|
1310
|
+
|
1311
|
+
Iterating over the database configurations has also changed. Instead of
|
1312
|
+
calling hash methods on the `configurations` hash directly, a new method `configs_for` has
|
1313
|
+
been provided that allows you to select the correct configuration. `env_name` and
|
1314
|
+
`spec_name` arguments are optional. For example, these return an array of
|
1315
|
+
database config objects for the requested environment and a single database config object
|
1316
|
+
will be returned for the requested environment and specification name respectively.
|
942
1317
|
|
943
|
-
|
944
|
-
|
1318
|
+
```
|
1319
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development")
|
1320
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
945
1321
|
```
|
946
1322
|
|
947
|
-
*
|
1323
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
948
1324
|
|
949
|
-
*
|
950
|
-
`locking_column`, without default value, is null in the database.
|
1325
|
+
* Add database configuration to disable advisory locks.
|
951
1326
|
|
952
|
-
|
1327
|
+
```
|
1328
|
+
production:
|
1329
|
+
adapter: postgresql
|
1330
|
+
advisory_locks: false
|
1331
|
+
```
|
953
1332
|
|
954
|
-
*
|
955
|
-
`locking_column` is null in the database.
|
1333
|
+
*Guo Xiang*
|
956
1334
|
|
957
|
-
|
1335
|
+
* SQLite3 adapter `alter_table` method restores foreign keys.
|
958
1336
|
|
959
|
-
*
|
1337
|
+
*Yasuo Honda*
|
960
1338
|
|
961
|
-
|
1339
|
+
* Allow `:to_table` option to `invert_remove_foreign_key`.
|
1340
|
+
|
1341
|
+
Example:
|
962
1342
|
|
963
|
-
|
1343
|
+
remove_foreign_key :accounts, to_table: :owners
|
964
1344
|
|
965
|
-
*
|
1345
|
+
*Nikolay Epifanov*, *Rich Chen*
|
1346
|
+
|
1347
|
+
* Add environment & load_config dependency to `bin/rake db:seed` to enable
|
1348
|
+
seed load in environments without Rails and custom DB configuration
|
1349
|
+
|
1350
|
+
*Tobias Bielohlawek*
|
1351
|
+
|
1352
|
+
* Fix default value for mysql time types with specified precision.
|
1353
|
+
|
1354
|
+
*Nikolay Kondratyev*
|
966
1355
|
|
967
|
-
*
|
1356
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
968
1357
|
|
969
1358
|
*Ryuta Kamizono*
|
970
1359
|
|
971
|
-
*
|
1360
|
+
* Migrations raise when duplicate column definition.
|
972
1361
|
|
973
|
-
Fixes #
|
1362
|
+
Fixes #33024.
|
974
1363
|
|
975
|
-
*
|
1364
|
+
*Federico Martinez*
|
976
1365
|
|
977
|
-
*
|
978
|
-
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
979
|
-
that does not include a timestamp any more.
|
1366
|
+
* Bump minimum SQLite version to 3.8
|
980
1367
|
|
981
|
-
|
982
|
-
until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
|
1368
|
+
*Yasuo Honda*
|
983
1369
|
|
984
|
-
|
1370
|
+
* Fix parent record should not get saved with duplicate children records.
|
985
1371
|
|
986
|
-
|
1372
|
+
Fixes #32940.
|
987
1373
|
|
988
|
-
*
|
1374
|
+
*Santosh Wadghule*
|
989
1375
|
|
990
|
-
*
|
1376
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
991
1377
|
|
992
|
-
|
1378
|
+
*Brian Durand*
|
993
1379
|
|
994
|
-
|
1380
|
+
* Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
|
1381
|
+
use loaded association ids if present.
|
995
1382
|
|
996
|
-
*
|
1383
|
+
*Graham Turner*
|
997
1384
|
|
998
|
-
|
1385
|
+
* Add support to preload associations of polymorphic associations when not all the records have the requested associations.
|
999
1386
|
|
1000
|
-
*
|
1001
|
-
when the current migration does not exist.
|
1387
|
+
*Dana Sherson*
|
1002
1388
|
|
1003
|
-
|
1389
|
+
* Add `touch_all` method to `ActiveRecord::Relation`.
|
1390
|
+
|
1391
|
+
Example:
|
1004
1392
|
|
1005
|
-
|
1393
|
+
Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
1006
1394
|
|
1007
|
-
*
|
1395
|
+
*fatkodima*, *duggiefresh*
|
1008
1396
|
|
1009
|
-
*
|
1397
|
+
* Add `ActiveRecord::Base.base_class?` predicate.
|
1010
1398
|
|
1011
|
-
|
1012
|
-
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
1399
|
+
*Bogdan Gusiev*
|
1013
1400
|
|
1014
|
-
|
1401
|
+
* Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
|
1015
1402
|
|
1016
|
-
*
|
1403
|
+
*Tan Huynh*, *Yukio Mizuta*
|
1017
1404
|
|
1018
|
-
|
1405
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
1019
1406
|
|
1020
|
-
*
|
1021
|
-
Previously this method always returned an empty array.
|
1407
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
1022
1408
|
|
1023
|
-
|
1409
|
+
* Deprecate `update_attributes`/`!` in favor of `update`/`!`.
|
1410
|
+
|
1411
|
+
*Eddie Lebow*
|
1412
|
+
|
1413
|
+
* Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
|
1414
|
+
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
1415
|
+
|
1416
|
+
*DHH*
|
1417
|
+
|
1418
|
+
* Add `Relation#pick` as short-hand for single-value plucks.
|
1419
|
+
|
1420
|
+
*DHH*
|
1024
1421
|
|
1025
1422
|
|
1026
|
-
Please check [5-
|
1423
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
|