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