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