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