activerecord 5.2.6.2 → 6.0.0.beta1
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 +299 -768
- data/MIT-LICENSE +3 -1
- data/README.rdoc +1 -1
- data/examples/performance.rb +1 -1
- data/lib/active_record/aggregations.rb +4 -2
- data/lib/active_record/associations/association.rb +35 -19
- data/lib/active_record/associations/association_scope.rb +4 -6
- 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/belongs_to.rb +14 -50
- data/lib/active_record/associations/builder/collection_association.rb +3 -3
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +17 -38
- data/lib/active_record/associations/collection_association.rb +11 -25
- data/lib/active_record/associations/collection_proxy.rb +32 -6
- data/lib/active_record/associations/foreign_association.rb +7 -0
- data/lib/active_record/associations/has_many_association.rb +1 -1
- data/lib/active_record/associations/has_many_through_association.rb +25 -18
- 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 +11 -26
- data/lib/active_record/associations/join_dependency/join_part.rb +2 -2
- data/lib/active_record/associations/join_dependency.rb +15 -20
- data/lib/active_record/associations/preloader/association.rb +1 -2
- data/lib/active_record/associations/preloader.rb +32 -29
- data/lib/active_record/associations/singular_association.rb +2 -16
- data/lib/active_record/associations.rb +16 -12
- data/lib/active_record/attribute_assignment.rb +7 -10
- data/lib/active_record/attribute_methods/dirty.rb +64 -26
- data/lib/active_record/attribute_methods/primary_key.rb +8 -7
- data/lib/active_record/attribute_methods/read.rb +16 -48
- data/lib/active_record/attribute_methods/serialization.rb +1 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +1 -1
- data/lib/active_record/attribute_methods/write.rb +15 -16
- data/lib/active_record/attribute_methods.rb +34 -56
- data/lib/active_record/autosave_association.rb +7 -21
- data/lib/active_record/base.rb +2 -2
- data/lib/active_record/callbacks.rb +3 -17
- data/lib/active_record/collection_cache_key.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +13 -36
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +25 -84
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +17 -14
- data/lib/active_record/connection_adapters/abstract/quoting.rb +5 -11
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +15 -11
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +30 -13
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +0 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +41 -27
- data/lib/active_record/connection_adapters/abstract/transaction.rb +81 -52
- data/lib/active_record/connection_adapters/abstract_adapter.rb +95 -31
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +65 -90
- data/lib/active_record/connection_adapters/connection_specification.rb +52 -42
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +5 -9
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +29 -7
- data/lib/active_record/connection_adapters/mysql/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +3 -4
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +65 -10
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +8 -4
- data/lib/active_record/connection_adapters/postgresql/column.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +16 -1
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +1 -4
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +9 -7
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +4 -4
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +11 -36
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +9 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +38 -20
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +75 -56
- data/lib/active_record/connection_adapters/schema_cache.rb +5 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +5 -5
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +14 -9
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +95 -62
- data/lib/active_record/connection_handling.rb +132 -26
- data/lib/active_record/core.rb +76 -43
- data/lib/active_record/counter_cache.rb +4 -29
- 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 +74 -0
- data/lib/active_record/database_configurations.rb +184 -0
- data/lib/active_record/enum.rb +22 -7
- data/lib/active_record/errors.rb +24 -21
- data/lib/active_record/explain.rb +1 -1
- 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 +153 -0
- data/lib/active_record/fixture_set/table_rows.rb +47 -0
- data/lib/active_record/fixtures.rb +140 -472
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +12 -2
- data/lib/active_record/integration.rb +56 -16
- data/lib/active_record/internal_metadata.rb +5 -1
- data/lib/active_record/locking/optimistic.rb +2 -2
- data/lib/active_record/locking/pessimistic.rb +3 -3
- data/lib/active_record/log_subscriber.rb +7 -26
- data/lib/active_record/migration/command_recorder.rb +35 -5
- data/lib/active_record/migration/compatibility.rb +34 -16
- data/lib/active_record/migration.rb +38 -37
- data/lib/active_record/model_schema.rb +30 -9
- data/lib/active_record/nested_attributes.rb +2 -2
- data/lib/active_record/no_touching.rb +7 -0
- data/lib/active_record/persistence.rb +18 -7
- data/lib/active_record/query_cache.rb +11 -4
- data/lib/active_record/querying.rb +19 -11
- data/lib/active_record/railtie.rb +71 -42
- 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 +94 -43
- data/lib/active_record/reflection.rb +60 -44
- data/lib/active_record/relation/batches.rb +13 -10
- data/lib/active_record/relation/calculations.rb +38 -28
- data/lib/active_record/relation/delegation.rb +4 -13
- data/lib/active_record/relation/finder_methods.rb +12 -25
- data/lib/active_record/relation/merger.rb +2 -6
- 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 +4 -6
- data/lib/active_record/relation/query_attribute.rb +15 -12
- data/lib/active_record/relation/query_methods.rb +29 -52
- data/lib/active_record/relation/where_clause.rb +4 -0
- data/lib/active_record/relation/where_clause_factory.rb +1 -2
- data/lib/active_record/relation.rb +150 -69
- data/lib/active_record/result.rb +30 -11
- data/lib/active_record/sanitization.rb +2 -39
- data/lib/active_record/schema.rb +1 -10
- data/lib/active_record/schema_dumper.rb +12 -6
- data/lib/active_record/schema_migration.rb +4 -0
- data/lib/active_record/scoping/default.rb +10 -3
- data/lib/active_record/scoping/named.rb +10 -14
- data/lib/active_record/scoping.rb +9 -8
- data/lib/active_record/statement_cache.rb +32 -5
- data/lib/active_record/store.rb +39 -8
- data/lib/active_record/table_metadata.rb +1 -4
- data/lib/active_record/tasks/database_tasks.rb +89 -23
- data/lib/active_record/tasks/mysql_database_tasks.rb +2 -4
- data/lib/active_record/tasks/postgresql_database_tasks.rb +5 -7
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -8
- data/lib/active_record/test_databases.rb +38 -0
- data/lib/active_record/test_fixtures.rb +224 -0
- data/lib/active_record/timestamp.rb +4 -6
- data/lib/active_record/transactions.rb +3 -22
- data/lib/active_record/translation.rb +1 -1
- data/lib/active_record/type/adapter_specific_registry.rb +1 -8
- data/lib/active_record/type.rb +3 -4
- data/lib/active_record/type_caster/connection.rb +1 -6
- data/lib/active_record/type_caster/map.rb +1 -4
- data/lib/active_record/validations/uniqueness.rb +13 -25
- data/lib/active_record.rb +2 -1
- 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/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 +63 -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 +44 -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.rb +16 -0
- data/lib/arel/nodes/values_list.rb +24 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/nodes.rb +67 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +257 -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 +199 -0
- data/lib/arel/visitors/dot.rb +292 -0
- data/lib/arel/visitors/ibm_db.rb +21 -0
- data/lib/arel/visitors/informix.rb +56 -0
- data/lib/arel/visitors/mssql.rb +143 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +159 -0
- data/lib/arel/visitors/oracle12.rb +67 -0
- data/lib/arel/visitors/postgresql.rb +116 -0
- data/lib/arel/visitors/sqlite.rb +39 -0
- data/lib/arel/visitors/to_sql.rb +913 -0
- data/lib/arel/visitors/visitor.rb +42 -0
- data/lib/arel/visitors/where_sql.rb +23 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/arel.rb +44 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +2 -5
- data/lib/rails/generators/active_record/migration.rb +14 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +1 -0
- metadata +107 -29
data/CHANGELOG.md
CHANGED
@@ -1,123 +1,80 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Remove deprecated `#set_state` from the transaction object.
|
4
4
|
|
5
|
+
*Rafael Mendonça França*
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
* No changes.
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 5.2.6 (May 05, 2021) ##
|
12
|
-
|
13
|
-
* No changes.
|
14
|
-
|
15
|
-
|
16
|
-
## Rails 5.2.5 (March 26, 2021) ##
|
17
|
-
|
18
|
-
* No changes.
|
19
|
-
|
20
|
-
|
21
|
-
## Rails 5.2.4.6 (May 05, 2021) ##
|
22
|
-
|
23
|
-
* No changes.
|
24
|
-
|
25
|
-
|
26
|
-
## Rails 5.2.4.5 (February 10, 2021) ##
|
27
|
-
|
28
|
-
* Fix possible DoS vector in PostgreSQL money type
|
29
|
-
|
30
|
-
Carefully crafted input can cause a DoS via the regular expressions used
|
31
|
-
for validating the money format in the PostgreSQL adapter. This patch
|
32
|
-
fixes the regexp.
|
33
|
-
|
34
|
-
Thanks to @dee-see from Hackerone for this patch!
|
35
|
-
|
36
|
-
[CVE-2021-22880]
|
37
|
-
|
38
|
-
*Aaron Patterson*
|
39
|
-
|
40
|
-
|
41
|
-
## Rails 5.2.4.4 (September 09, 2020) ##
|
42
|
-
|
43
|
-
* No changes.
|
44
|
-
|
45
|
-
|
46
|
-
## Rails 5.2.4.3 (May 18, 2020) ##
|
47
|
-
|
48
|
-
* No changes.
|
7
|
+
* Remove deprecated `#supports_statement_cache?` from the database adapters.
|
49
8
|
|
50
|
-
|
9
|
+
*Rafael Mendonça França*
|
51
10
|
|
52
|
-
*
|
11
|
+
* Remove deprecated `#insert_fixtures` from the database adapters.
|
53
12
|
|
13
|
+
*Rafael Mendonça França*
|
54
14
|
|
55
|
-
|
15
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
|
56
16
|
|
57
|
-
*
|
17
|
+
*Rafael Mendonça França*
|
58
18
|
|
19
|
+
* Do not allow passing the column name to `sum` when a block is passed.
|
59
20
|
|
60
|
-
|
21
|
+
*Rafael Mendonça França*
|
61
22
|
|
62
|
-
*
|
23
|
+
* Do not allow passing the column name to `count` when a block is passed.
|
63
24
|
|
64
|
-
|
65
|
-
associations, the callback for a `has_many` association was run while
|
66
|
-
another instance of the same callback on the same association hadn't
|
67
|
-
finished running. When control returned to the first instance of the
|
68
|
-
callback, the instance variable had changed, and subsequent associated
|
69
|
-
records weren't saved correctly. Specifically, the ID field for the
|
70
|
-
`belongs_to` corresponding to the `has_many` was `nil`.
|
25
|
+
*Rafael Mendonça França*
|
71
26
|
|
72
|
-
|
27
|
+
* Remove delegation of missing methods in a relation to arel.
|
73
28
|
|
74
|
-
*
|
29
|
+
*Rafael Mendonça França*
|
75
30
|
|
76
|
-
*
|
31
|
+
* Remove delegation of missing methods in a relation to private methods of the class.
|
77
32
|
|
78
|
-
|
33
|
+
*Rafael Mendonça França*
|
79
34
|
|
80
|
-
|
35
|
+
* Deprecate `config.activerecord.sqlite3.represent_boolean_as_integer`.
|
81
36
|
|
82
|
-
*
|
37
|
+
*Rafael Mendonça França*
|
83
38
|
|
84
|
-
|
39
|
+
* Change `SQLite3Adapter` to always represent boolean values as integers.
|
85
40
|
|
86
|
-
*
|
41
|
+
*Rafael Mendonça França*
|
87
42
|
|
88
|
-
|
43
|
+
* Remove ability to specify a timestamp name for `#cache_key`.
|
89
44
|
|
90
|
-
*
|
45
|
+
*Rafael Mendonça França*
|
91
46
|
|
92
|
-
*
|
93
|
-
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
47
|
+
* Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
|
94
48
|
|
95
|
-
|
49
|
+
*Rafael Mendonça França*
|
96
50
|
|
97
|
-
|
51
|
+
* Remove deprecated `expand_hash_conditions_for_aggregates`.
|
98
52
|
|
53
|
+
*Rafael Mendonça França*
|
99
54
|
|
100
|
-
|
55
|
+
* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
|
101
56
|
|
102
|
-
|
57
|
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
|
103
58
|
|
104
|
-
|
59
|
+
*Laerti Papa*
|
105
60
|
|
106
|
-
|
61
|
+
* Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
|
107
62
|
|
108
|
-
*
|
63
|
+
*Gannon McGibbon*
|
109
64
|
|
110
|
-
|
65
|
+
* Add support for endless ranges introduces in Ruby 2.6.
|
111
66
|
|
112
|
-
*
|
67
|
+
*Greg Navis*
|
113
68
|
|
114
|
-
|
69
|
+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
|
115
70
|
|
116
71
|
*Ryuta Kamizono*
|
117
72
|
|
118
|
-
*
|
73
|
+
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
|
119
74
|
|
120
|
-
|
75
|
+
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
|
76
|
+
format for InnoDB tables. The default setting is `DYNAMIC`.
|
77
|
+
The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
|
121
78
|
|
122
79
|
*Ryuta Kamizono*
|
123
80
|
|
@@ -125,6 +82,10 @@
|
|
125
82
|
|
126
83
|
*Gannon McGibbon*
|
127
84
|
|
85
|
+
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
86
|
+
|
87
|
+
*Alfred Dominic*
|
88
|
+
|
128
89
|
* Ensure that `delete_all` on collection proxy returns affected count.
|
129
90
|
|
130
91
|
*Ryuta Kamizono*
|
@@ -133,17 +94,21 @@
|
|
133
94
|
|
134
95
|
*Gannon McGibbon*
|
135
96
|
|
97
|
+
* Add the ability to prevent writes to a database for the duration of a block.
|
136
98
|
|
137
|
-
|
138
|
-
|
139
|
-
|
99
|
+
Allows the application to prevent writes to a database. This can be useful when
|
100
|
+
you're building out multiple databases and want to make sure you're not sending
|
101
|
+
writes when you want a read.
|
140
102
|
|
103
|
+
If `while_preventing_writes` is called and the query is considered a write
|
104
|
+
query the database will raise an exception regardless of whether the database
|
105
|
+
user is able to write.
|
141
106
|
|
142
|
-
|
107
|
+
This is not meant to be a catch-all for write queries but rather a way to enforce
|
108
|
+
read-only queries without opening a second connection. One purpose of this is to
|
109
|
+
catch accidental writes, not all writes.
|
143
110
|
|
144
|
-
*
|
145
|
-
|
146
|
-
*Ryuta Kamizono*
|
111
|
+
*Eileen M. Uchitelle*
|
147
112
|
|
148
113
|
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
149
114
|
|
@@ -151,8 +116,7 @@
|
|
151
116
|
|
152
117
|
* Allow spaces in postgres table names.
|
153
118
|
|
154
|
-
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
|
155
|
-
adapter.
|
119
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
|
156
120
|
|
157
121
|
*Gannon McGibbon*
|
158
122
|
|
@@ -185,852 +149,419 @@
|
|
185
149
|
|
186
150
|
*Dmitry Tsepelev*
|
187
151
|
|
188
|
-
*
|
189
|
-
|
190
|
-
*Emmanuel Byrd*
|
191
|
-
|
192
|
-
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
193
|
-
if the attribute does not exist.
|
194
|
-
|
195
|
-
*Sean Griffin*
|
196
|
-
|
197
|
-
* Do not use prepared statement in queries that have a large number of binds.
|
198
|
-
|
199
|
-
*Ryuta Kamizono*
|
200
|
-
|
201
|
-
* Fix query cache to load before first request.
|
202
|
-
|
203
|
-
*Eileen M. Uchitelle*
|
204
|
-
|
205
|
-
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
206
|
-
|
207
|
-
Fixes #33056.
|
208
|
-
|
209
|
-
*Federico Martinez*
|
210
|
-
|
211
|
-
* Fix duplicated record creation when using nested attributes with `create_with`.
|
212
|
-
|
213
|
-
*Darwin Wu*
|
214
|
-
|
215
|
-
* Fix regression setting children record in parent `before_save` callback.
|
216
|
-
|
217
|
-
*Guo Xiang Tan*
|
218
|
-
|
219
|
-
* Prevent leaking of user's DB credentials on `rails db:create` failure.
|
220
|
-
|
221
|
-
*bogdanvlviv*
|
222
|
-
|
223
|
-
* Clear mutation tracker before continuing the around callbacks.
|
224
|
-
|
225
|
-
*Yuya Tanaka*
|
226
|
-
|
227
|
-
* Prevent deadlocks when waiting for connection from pool.
|
228
|
-
|
229
|
-
*Brent Wheeldon*
|
230
|
-
|
231
|
-
* Avoid extra scoping when using `Relation#update` that was causing this method to change the current scope.
|
232
|
-
|
233
|
-
*Ryuta Kamizono*
|
234
|
-
|
235
|
-
* Fix numericality validator not to be affected by custom getter.
|
236
|
-
|
237
|
-
*Ryuta Kamizono*
|
238
|
-
|
239
|
-
* Fix bulk change table ignores comment option on PostgreSQL.
|
240
|
-
|
241
|
-
*Yoshiyuki Kinjo*
|
242
|
-
|
243
|
-
|
244
|
-
## Rails 5.2.1.1 (November 27, 2018) ##
|
245
|
-
|
246
|
-
* No changes.
|
152
|
+
* Make the implicit order column configurable.
|
247
153
|
|
154
|
+
When calling ordered finder methods such as +first+ or +last+ without an
|
155
|
+
explicit order clause, ActiveRecord sorts records by primary key. This can
|
156
|
+
result in unpredictable and surprising behaviour when the primary key is
|
157
|
+
not an auto-incrementing integer, for example when it's a UUID. This change
|
158
|
+
makes it possible to override the column used for implicit ordering such
|
159
|
+
that +first+ and +last+ will return more predictable results.
|
248
160
|
|
249
|
-
|
250
|
-
|
251
|
-
* PostgreSQL: Support new relkind for partitioned tables.
|
252
|
-
|
253
|
-
Fixes #33008.
|
254
|
-
|
255
|
-
*Yannick Schutz*
|
256
|
-
|
257
|
-
* Rollback parent transaction when children fails to update.
|
258
|
-
|
259
|
-
*Guillaume Malette*
|
260
|
-
|
261
|
-
* Fix default value for MySQL time types with specified precision.
|
262
|
-
|
263
|
-
*Nikolay Kondratyev*
|
264
|
-
|
265
|
-
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
266
|
-
|
267
|
-
*Ryuta Kamizono*
|
268
|
-
|
269
|
-
* Fix `save` in `after_create_commit` won't invoke extra `after_create_commit`.
|
270
|
-
|
271
|
-
Fixes #32831.
|
272
|
-
|
273
|
-
*Ryuta Kamizono*
|
274
|
-
|
275
|
-
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
276
|
-
|
277
|
-
*Brian Durand*
|
278
|
-
|
279
|
-
* Fix parent record should not get saved with duplicate children records.
|
280
|
-
|
281
|
-
Fixes #32940.
|
282
|
-
|
283
|
-
*Santosh Wadghule*
|
284
|
-
|
285
|
-
* Fix that association's after_touch is not called with counter cache.
|
286
|
-
|
287
|
-
Fixes #31559.
|
288
|
-
|
289
|
-
*Ryuta Kamizono*
|
290
|
-
|
291
|
-
* `becomes` should clear the mutation tracker which is created in `after_initialize`.
|
292
|
-
|
293
|
-
Fixes #32867.
|
294
|
-
|
295
|
-
*Ryuta Kamizono*
|
296
|
-
|
297
|
-
* Allow a belonging to parent object to be created from a new record.
|
298
|
-
|
299
|
-
*Jolyon Pawlyn*
|
300
|
-
|
301
|
-
* Fix that building record with assigning multiple has_one associations
|
302
|
-
wrongly persists through record.
|
303
|
-
|
304
|
-
Fixes #32511.
|
305
|
-
|
306
|
-
*Sam DeCesare*
|
307
|
-
|
308
|
-
* Fix relation merging when one of the relations is going to skip the
|
309
|
-
query cache.
|
310
|
-
|
311
|
-
*James Williams*
|
312
|
-
|
313
|
-
|
314
|
-
## Rails 5.2.0 (April 09, 2018) ##
|
315
|
-
|
316
|
-
* MySQL: Support mysql2 0.5.x.
|
317
|
-
|
318
|
-
*Aaron Stone*
|
319
|
-
|
320
|
-
* Apply time column precision on assignment.
|
321
|
-
|
322
|
-
PR #20317 changed the behavior of datetime columns so that when they
|
323
|
-
have a specified precision then on assignment the value is rounded to
|
324
|
-
that precision. This behavior is now applied to time columns as well.
|
325
|
-
|
326
|
-
Fixes #30301.
|
327
|
-
|
328
|
-
*Andrew White*
|
329
|
-
|
330
|
-
* Normalize time column values for SQLite database.
|
331
|
-
|
332
|
-
For legacy reasons, time columns in SQLite are stored as full datetimes
|
333
|
-
because until #24542 the quoting for time columns didn't remove the date
|
334
|
-
component. To ensure that values are consistent we now normalize the
|
335
|
-
date component to 2001-01-01 on reading and writing.
|
336
|
-
|
337
|
-
*Andrew White*
|
338
|
-
|
339
|
-
* Ensure that the date component is removed when quoting times.
|
340
|
-
|
341
|
-
PR #24542 altered the quoting for time columns so that the date component
|
342
|
-
was removed however it only removed it when it was 2001-01-01. Now the
|
343
|
-
date component is removed irrespective of what the date is.
|
344
|
-
|
345
|
-
*Andrew White*
|
346
|
-
|
347
|
-
* Fix `dependent: :destroy` issue for has_one/belongs_to relationship where
|
348
|
-
the parent class was getting deleted when the child was not.
|
349
|
-
|
350
|
-
Fixes #32022.
|
351
|
-
|
352
|
-
*Fernando Gorodscy*
|
353
|
-
|
354
|
-
* Whitelist `NULLS FIRST` and `NULLS LAST` in order clauses too.
|
355
|
-
|
356
|
-
*Xavier Noria*
|
357
|
-
|
358
|
-
* Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
|
359
|
-
|
360
|
-
*Ryuta Kamizono*
|
161
|
+
Example:
|
361
162
|
|
362
|
-
|
363
|
-
|
364
|
-
|
163
|
+
class Project < ActiveRecord::Base
|
164
|
+
self.implicit_order_column = "created_at"
|
165
|
+
end
|
365
166
|
|
366
|
-
|
167
|
+
*Tekin Suleyman*
|
367
168
|
|
368
|
-
|
169
|
+
* Bump minimum PostgreSQL version to 9.3.
|
369
170
|
|
370
|
-
*
|
171
|
+
*Yasuo Honda*
|
371
172
|
|
372
|
-
|
173
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
373
174
|
|
374
|
-
*
|
175
|
+
*Emmanuel Byrd*
|
375
176
|
|
376
|
-
*
|
177
|
+
* Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
|
377
178
|
|
378
|
-
|
179
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
|
379
180
|
|
380
|
-
|
381
|
-
Using a `Relation` for performing queries is the prefered API.
|
181
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
|
382
182
|
|
383
|
-
|
183
|
+
Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
|
384
184
|
|
385
|
-
|
185
|
+
Example:
|
386
186
|
|
387
187
|
```
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
188
|
+
class MySubclassedError < ActiveRecord::StatementInvalid
|
189
|
+
def initialize(message, sql:, binds:)
|
190
|
+
super(message, sql: sql, binds: binds)
|
191
|
+
end
|
192
|
+
end
|
393
193
|
```
|
394
194
|
|
395
|
-
|
396
|
-
|
397
|
-
*Yutaro Kanagawa*
|
398
|
-
|
399
|
-
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
400
|
-
|
401
|
-
Fixes #31783.
|
402
|
-
|
403
|
-
*Ryuta Kamizono*
|
404
|
-
|
405
|
-
* Clear the transaction state when an Active Record object is duped.
|
406
|
-
|
407
|
-
Fixes #31670.
|
408
|
-
|
409
|
-
*Yuriy Ustushenko*
|
410
|
-
|
411
|
-
* Support for PostgreSQL foreign tables.
|
412
|
-
|
413
|
-
*fatkodima*
|
414
|
-
|
415
|
-
* Fix relation merger issue with `left_outer_joins`.
|
416
|
-
|
417
|
-
*Mehmet Emin İNAÇ*
|
418
|
-
|
419
|
-
* Don't allow destroyed object mutation after `save` or `save!` is called.
|
420
|
-
|
421
|
-
*Ryuta Kamizono*
|
422
|
-
|
423
|
-
* Take into account association conditions when deleting through records.
|
424
|
-
|
425
|
-
Fixes #18424.
|
426
|
-
|
427
|
-
*Piotr Jakubowski*
|
195
|
+
*Gannon McGibbon*
|
428
196
|
|
429
|
-
*
|
197
|
+
* Add an `:if_not_exists` option to `create_table`.
|
430
198
|
|
431
|
-
|
199
|
+
Example:
|
432
200
|
|
433
|
-
|
434
|
-
|
435
|
-
has_many :books, through: :author
|
436
|
-
has_many :subscriptions, through: :books
|
201
|
+
create_table :posts, if_not_exists: true do |t|
|
202
|
+
t.string :title
|
437
203
|
end
|
438
204
|
|
439
|
-
|
440
|
-
has_one :post
|
441
|
-
has_many :books
|
442
|
-
has_many :subscriptions, through: :books
|
443
|
-
end
|
205
|
+
That would execute:
|
444
206
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
end
|
207
|
+
CREATE TABLE IF NOT EXISTS posts (
|
208
|
+
...
|
209
|
+
)
|
449
210
|
|
450
|
-
|
451
|
-
|
452
|
-
end
|
211
|
+
If the table already exists, `if_not_exists: false` (the default) raises an
|
212
|
+
exception whereas `if_not_exists: true` does nothing.
|
453
213
|
|
454
|
-
|
214
|
+
*fatkodima*, *Stefan Kanev*
|
455
215
|
|
456
|
-
|
216
|
+
* Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
|
457
217
|
|
458
|
-
|
218
|
+
*Christophe Maximin*
|
459
219
|
|
460
|
-
|
461
|
-
just like it would if `post` were persisted.
|
220
|
+
* Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
|
462
221
|
|
463
|
-
|
222
|
+
*Gannon McGibbon*
|
464
223
|
|
465
|
-
|
224
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
225
|
+
if the attribute does not exist.
|
466
226
|
|
467
|
-
*
|
468
|
-
The `first(n)` finder now respects the `limit()`, making it consistent
|
469
|
-
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
227
|
+
*Sean Griffin*
|
470
228
|
|
471
|
-
|
229
|
+
* Add support for hash and url configs in database hash of `ActiveRecord::Base.connected_to`.
|
472
230
|
|
473
|
-
|
231
|
+
````
|
232
|
+
User.connected_to(database: { writing: "postgres://foo" }) do
|
233
|
+
User.create!(name: "Gannon")
|
234
|
+
end
|
474
235
|
|
475
|
-
|
476
|
-
|
236
|
+
config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
|
237
|
+
User.connected_to(database: { reading: config }) do
|
238
|
+
User.count
|
239
|
+
end
|
240
|
+
````
|
477
241
|
|
478
|
-
*
|
242
|
+
*Gannon McGibbon*
|
479
243
|
|
480
|
-
*
|
244
|
+
* Support default expression for MySQL.
|
481
245
|
|
482
|
-
|
246
|
+
MySQL 8.0.13 and higher supports default value to be a function or expression.
|
483
247
|
|
484
|
-
|
248
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-table.html
|
485
249
|
|
486
250
|
*Ryuta Kamizono*
|
487
251
|
|
488
|
-
*
|
252
|
+
* Support expression indexes for MySQL.
|
489
253
|
|
490
|
-
|
254
|
+
MySQL 8.0.13 and higher supports functional key parts that index
|
255
|
+
expression values rather than column or column prefix values.
|
491
256
|
|
492
|
-
|
493
|
-
information.
|
257
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-index.html
|
494
258
|
|
495
|
-
*
|
259
|
+
*Ryuta Kamizono*
|
496
260
|
|
497
|
-
*
|
261
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
498
262
|
|
499
|
-
|
500
|
-
of database queries in the log to facilitate N+1 query resolution
|
501
|
-
and other debugging.
|
263
|
+
Fixes #33056.
|
502
264
|
|
503
|
-
|
504
|
-
recommended for use in the production environment since it relies
|
505
|
-
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
265
|
+
*Federico Martinez*
|
506
266
|
|
507
|
-
|
267
|
+
* Add basic API for connection switching to support multiple databases.
|
508
268
|
|
509
|
-
|
269
|
+
1) Adds a `connects_to` method for models to connect to multiple databases. Example:
|
510
270
|
|
511
271
|
```
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
# end
|
517
|
-
class Post < ApplicationRecord
|
272
|
+
class AnimalsModel < ApplicationRecord
|
273
|
+
self.abstract_class = true
|
274
|
+
|
275
|
+
connects_to database: { writing: :animals_primary, reading: :animals_replica }
|
518
276
|
end
|
519
277
|
|
520
|
-
|
521
|
-
|
522
|
-
# end
|
523
|
-
class Comment < ApplicationRecord
|
524
|
-
belongs_to :post, touch: true, counter_cache: true
|
278
|
+
class Dog < AnimalsModel
|
279
|
+
# connected to both the animals_primary db for writing and the animals_replica for reading
|
525
280
|
end
|
526
281
|
```
|
527
282
|
|
528
|
-
|
283
|
+
2) Adds a `connected_to` block method for switching connection roles or connecting to
|
284
|
+
a database that the model didn't connect to. Connecting to the database in this block is
|
285
|
+
useful when you have another defined connection, for example `slow_replica` that you don't
|
286
|
+
want to connect to by default but need in the console, or a specific code block.
|
287
|
+
|
529
288
|
```
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
commit transaction
|
535
|
-
|
536
|
-
comment = Comment.create!(post: post)
|
537
|
-
# => begin transaction
|
538
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
539
|
-
|
540
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
541
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
542
|
-
|
543
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
544
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
545
|
-
rollback transaction
|
546
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
547
|
-
|
548
|
-
Comment.take.destroy!
|
549
|
-
# => begin transaction
|
550
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
551
|
-
|
552
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
553
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
554
|
-
|
555
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
556
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
557
|
-
rollback transaction
|
558
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
289
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
290
|
+
Dog.first # finds dog from replica connected to AnimalsBase
|
291
|
+
Book.first # doesn't have a reading connection, will raise an error
|
292
|
+
end
|
559
293
|
```
|
560
294
|
|
561
|
-
After:
|
562
295
|
```
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
567
|
-
commit transaction
|
568
|
-
|
569
|
-
comment = Comment.create!(post: post)
|
570
|
-
# => begin transaction
|
571
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
572
|
-
|
573
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
574
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
575
|
-
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
576
|
-
commit transaction
|
577
|
-
|
578
|
-
comment.destroy!
|
579
|
-
# => begin transaction
|
580
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
581
|
-
|
582
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
583
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
584
|
-
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
585
|
-
commit transaction
|
296
|
+
ActiveRecord::Base.connected_to(database: :slow_replica) do
|
297
|
+
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
|
298
|
+
end
|
586
299
|
```
|
587
300
|
|
588
|
-
|
589
|
-
|
590
|
-
*bogdanvlviv*
|
591
|
-
|
592
|
-
* Add support for PostgreSQL operator classes to `add_index`.
|
593
|
-
|
594
|
-
Example:
|
595
|
-
|
596
|
-
add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
|
597
|
-
|
598
|
-
*Greg Navis*
|
599
|
-
|
600
|
-
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
601
|
-
|
602
|
-
Fixes #31120.
|
603
|
-
|
604
|
-
*kinnrot*
|
605
|
-
|
606
|
-
* Add new error class `QueryCanceled` which will be raised
|
607
|
-
when canceling statement due to user request.
|
301
|
+
*Eileen M. Uchitelle*
|
608
302
|
|
609
|
-
|
303
|
+
* Enum raises on invalid definition values
|
610
304
|
|
611
|
-
|
612
|
-
|
305
|
+
When defining a Hash enum it can be easy to use [] instead of {}. This
|
306
|
+
commit checks that only valid definition values are provided, those can
|
307
|
+
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
308
|
+
raises an ArgumentError.
|
613
309
|
|
614
|
-
|
310
|
+
Fixes #33961
|
615
311
|
|
616
|
-
*
|
617
|
-
relation query methods.
|
312
|
+
*Alberto Almagro*
|
618
313
|
|
619
|
-
|
620
|
-
```
|
621
|
-
Article.order("LENGTH(title)")
|
622
|
-
```
|
314
|
+
* Reloading associations now clears the Query Cache like `Persistence#reload` does.
|
623
315
|
|
624
|
-
After:
|
625
|
-
```
|
626
|
-
Article.order(Arel.sql("LENGTH(title)"))
|
627
316
|
```
|
317
|
+
class Post < ActiveRecord::Base
|
318
|
+
has_one :category
|
319
|
+
belongs_to :author
|
320
|
+
has_many :comments
|
321
|
+
end
|
628
322
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
Raw SQL strings will now cause a deprecation warning, which will
|
634
|
-
become an UnknownAttributeReference error in Rails 6.0. Applications
|
635
|
-
can opt in to the future behavior by setting `allow_unsafe_raw_sql`
|
636
|
-
to `:disabled`.
|
637
|
-
|
638
|
-
Common and judged-safe string values (such as simple column
|
639
|
-
references) are unaffected:
|
640
|
-
```
|
641
|
-
Article.order("title DESC")
|
323
|
+
# Each of the following will now clear the query cache.
|
324
|
+
post.reload_category
|
325
|
+
post.reload_author
|
326
|
+
post.comments.reload
|
642
327
|
```
|
643
328
|
|
644
|
-
*
|
329
|
+
*Christophe Maximin*
|
645
330
|
|
646
|
-
* `
|
647
|
-
|
648
|
-
|
331
|
+
* Added `index` option for `change_table` migration helpers.
|
332
|
+
With this change you can create indexes while adding new
|
333
|
+
columns into the existing tables.
|
649
334
|
|
650
|
-
|
651
|
-
|
652
|
-
* Add new error class `StatementTimeout` which will be raised
|
653
|
-
when statement timeout exceeded.
|
654
|
-
|
655
|
-
*Ryuta Kamizono*
|
656
|
-
|
657
|
-
* Fix `bin/rails db:migrate` with specified `VERSION`.
|
658
|
-
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
659
|
-
Check a format of `VERSION`: Allow a migration version number
|
660
|
-
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
661
|
-
Raise error if target migration doesn't exist.
|
662
|
-
|
663
|
-
*bogdanvlviv*
|
664
|
-
|
665
|
-
* Fixed a bug where column orders for an index weren't written to
|
666
|
-
`db/schema.rb` when using the sqlite adapter.
|
667
|
-
|
668
|
-
Fixes #30902.
|
669
|
-
|
670
|
-
*Paul Kuruvilla*
|
671
|
-
|
672
|
-
* Remove deprecated method `#sanitize_conditions`.
|
673
|
-
|
674
|
-
*Rafael Mendonça França*
|
675
|
-
|
676
|
-
* Remove deprecated method `#scope_chain`.
|
677
|
-
|
678
|
-
*Rafael Mendonça França*
|
679
|
-
|
680
|
-
* Remove deprecated configuration `.error_on_ignored_order_or_limit`.
|
681
|
-
|
682
|
-
*Rafael Mendonça França*
|
683
|
-
|
684
|
-
* Remove deprecated arguments from `#verify!`.
|
685
|
-
|
686
|
-
*Rafael Mendonça França*
|
687
|
-
|
688
|
-
* Remove deprecated argument `name` from `#indexes`.
|
689
|
-
|
690
|
-
*Rafael Mendonça França*
|
691
|
-
|
692
|
-
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
|
693
|
-
|
694
|
-
*Rafael Mendonça França*
|
335
|
+
Example:
|
695
336
|
|
696
|
-
|
337
|
+
change_table(:languages) do |t|
|
338
|
+
t.string :country_code, index: true
|
339
|
+
end
|
697
340
|
|
698
|
-
*
|
341
|
+
*Mehmet Emin İNAÇ*
|
699
342
|
|
700
|
-
*
|
343
|
+
* Fix `transaction` reverting for migrations.
|
701
344
|
|
702
|
-
|
345
|
+
Before: Commands inside a `transaction` in a reverted migration ran uninverted.
|
346
|
+
Now: This change fixes that by reverting commands inside `transaction` block.
|
703
347
|
|
704
|
-
*
|
348
|
+
*fatkodima*, *David Verhasselt*
|
705
349
|
|
706
|
-
|
350
|
+
* Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
|
707
351
|
|
708
|
-
*
|
352
|
+
*Gannon McGibbon*, *Max Albrecht*
|
709
353
|
|
710
|
-
|
354
|
+
* Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
|
711
355
|
|
712
|
-
*
|
356
|
+
*Gannon McGibbon*
|
713
357
|
|
714
|
-
|
358
|
+
* Don't update counter cache unless the record is actually saved.
|
715
359
|
|
716
|
-
|
360
|
+
Fixes #31493, #33113, #33117.
|
717
361
|
|
718
|
-
*
|
362
|
+
*Ryuta Kamizono*
|
719
363
|
|
720
|
-
*
|
364
|
+
* Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
|
721
365
|
|
722
|
-
*
|
366
|
+
*Gannon McGibbon*, *Kevin Cheng*
|
723
367
|
|
724
|
-
*
|
725
|
-
ar_internal_metadata's data for a test database.
|
368
|
+
* SQLite3 adapter supports expression indexes.
|
726
369
|
|
727
|
-
Before:
|
728
|
-
```
|
729
|
-
$ RAILS_ENV=test rails dbconsole
|
730
|
-
> SELECT * FROM ar_internal_metadata;
|
731
|
-
key|value|created_at|updated_at
|
732
|
-
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
733
370
|
```
|
371
|
+
create_table :users do |t|
|
372
|
+
t.string :email
|
373
|
+
end
|
734
374
|
|
735
|
-
|
736
|
-
```
|
737
|
-
$ RAILS_ENV=test rails dbconsole
|
738
|
-
> SELECT * FROM ar_internal_metadata;
|
739
|
-
key|value|created_at|updated_at
|
740
|
-
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
375
|
+
add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
|
741
376
|
```
|
742
377
|
|
743
|
-
|
744
|
-
|
745
|
-
*bogdanvlviv*
|
746
|
-
|
747
|
-
* Fix longer sequence name detection for serial columns.
|
748
|
-
|
749
|
-
Fixes #28332.
|
378
|
+
*Gray Kemmey*
|
750
379
|
|
751
|
-
|
752
|
-
|
753
|
-
* MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
|
754
|
-
|
755
|
-
Fixes #30894.
|
756
|
-
|
757
|
-
*Ryuta Kamizono*
|
758
|
-
|
759
|
-
* Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
|
380
|
+
* Allow subclasses to redefine autosave callbacks for associated records.
|
760
381
|
|
761
|
-
Fixes #
|
382
|
+
Fixes #33305.
|
762
383
|
|
763
|
-
*
|
764
|
-
|
765
|
-
* PostgreSQL `tsrange` now preserves subsecond precision.
|
766
|
-
|
767
|
-
PostgreSQL 9.1+ introduced range types, and Rails added support for using
|
768
|
-
this datatype in Active Record. However, the serialization of
|
769
|
-
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
770
|
-
cast the bounds that make up the range. This led to subseconds being
|
771
|
-
dropped in SQL commands:
|
384
|
+
*Andrey Subbota*
|
772
385
|
|
773
|
-
|
386
|
+
* Bump minimum MySQL version to 5.5.8.
|
774
387
|
|
775
|
-
|
776
|
-
# => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
|
388
|
+
*Yasuo Honda*
|
777
389
|
|
778
|
-
|
390
|
+
* Use MySQL utf8mb4 character set by default.
|
779
391
|
|
780
|
-
|
781
|
-
|
392
|
+
`utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
|
393
|
+
The previous default 3-Byte encoding character set `utf8` is not enough to support them.
|
782
394
|
|
783
|
-
*
|
784
|
-
|
785
|
-
* Passing a `Set` to `Relation#where` now behaves the same as passing an
|
786
|
-
array.
|
787
|
-
|
788
|
-
*Sean Griffin*
|
395
|
+
*Yasuo Honda*
|
789
396
|
|
790
|
-
*
|
791
|
-
|
792
|
-
Fixes #24190.
|
793
|
-
|
794
|
-
*Mehmet Emin İNAÇ*
|
795
|
-
|
796
|
-
* Update payload names for `sql.active_record` instrumentation to be
|
797
|
-
more descriptive.
|
397
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
798
398
|
|
799
|
-
|
399
|
+
*Darwin Wu*
|
800
400
|
|
801
|
-
|
401
|
+
* Configuration item `config.filter_parameters` could also filter out
|
402
|
+
sensitive values of database columns when call `#inspect`.
|
403
|
+
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
404
|
+
specify sensitive attributes to specific model.
|
802
405
|
|
803
|
-
|
804
|
-
|
406
|
+
```
|
407
|
+
Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
|
408
|
+
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
|
409
|
+
SecureAccount.filter_attributes += [:name]
|
410
|
+
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
|
411
|
+
```
|
805
412
|
|
806
|
-
*
|
413
|
+
*Zhang Kang*, *Yoshiyuki Kinjo*
|
807
414
|
|
808
|
-
*
|
415
|
+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
|
416
|
+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
417
|
+
and `joins_per_query` methods in `DatabaseLimits`.
|
809
418
|
|
810
419
|
*Ryuta Kamizono*
|
811
420
|
|
812
|
-
*
|
813
|
-
|
814
|
-
*Yuichiro Kaneko*
|
815
|
-
|
816
|
-
* Ensure `sum` honors `distinct` on `has_many :through` associations.
|
817
|
-
|
818
|
-
Fixes #16791.
|
421
|
+
* `ActiveRecord::Base.configurations` now returns an object.
|
819
422
|
|
820
|
-
|
423
|
+
`ActiveRecord::Base.configurations` used to return a hash, but this
|
424
|
+
is an inflexible data model. In order to improve multiple-database
|
425
|
+
handling in Rails, we've changed this to return an object. Some methods
|
426
|
+
are provided to make the object behave hash-like in order to ease the
|
427
|
+
transition process. Since most applications don't manipulate the hash
|
428
|
+
we've decided to add backwards-compatible functionality that will throw
|
429
|
+
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
430
|
+
will use the new version internally and externally.
|
821
431
|
|
822
|
-
|
432
|
+
For example, the following `database.yml`:
|
823
433
|
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
* `Relation#or` now accepts two relations who have different values for
|
831
|
-
`references` only, as `references` can be implicitly called by `where`.
|
832
|
-
|
833
|
-
Fixes #29411.
|
834
|
-
|
835
|
-
*Sean Griffin*
|
836
|
-
|
837
|
-
* `ApplicationRecord` is no longer generated when generating models. If you
|
838
|
-
need to generate it, it can be created with `rails g application_record`.
|
839
|
-
|
840
|
-
*Lisa Ugray*
|
841
|
-
|
842
|
-
* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
|
434
|
+
```
|
435
|
+
development:
|
436
|
+
adapter: sqlite3
|
437
|
+
database: db/development.sqlite3
|
438
|
+
```
|
843
439
|
|
844
|
-
|
440
|
+
Used to become a hash:
|
845
441
|
|
846
|
-
|
847
|
-
|
848
|
-
|
442
|
+
```
|
443
|
+
{ "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
|
444
|
+
```
|
849
445
|
|
850
|
-
|
446
|
+
Is now converted into the following object:
|
851
447
|
|
852
|
-
|
448
|
+
```
|
449
|
+
#<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
|
450
|
+
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
|
451
|
+
@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
|
452
|
+
]
|
453
|
+
```
|
853
454
|
|
854
|
-
|
855
|
-
|
455
|
+
Iterating over the database configurations has also changed. Instead of
|
456
|
+
calling hash methods on the `configurations` hash directly, a new method `configs_for` has
|
457
|
+
been provided that allows you to select the correct configuration. `env_name`, and
|
458
|
+
`spec_name` arguments are optional. For example these return an array of
|
459
|
+
database config objects for the requested environment and a single database config object
|
460
|
+
will be returned for the requested environment and specification name respectively.
|
856
461
|
|
857
462
|
```
|
858
|
-
|
859
|
-
|
860
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
861
|
-
# With fix:
|
862
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
463
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development")
|
464
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
863
465
|
```
|
864
466
|
|
865
|
-
*
|
866
|
-
|
867
|
-
* Values constructed using multi-parameter assignment will now use the
|
868
|
-
post-type-cast value for rendering in single-field form inputs.
|
467
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
869
468
|
|
870
|
-
|
469
|
+
* Add database configuration to disable advisory locks.
|
871
470
|
|
872
|
-
|
873
|
-
|
471
|
+
```
|
472
|
+
production:
|
473
|
+
adapter: postgresql
|
474
|
+
advisory_locks: false
|
475
|
+
```
|
874
476
|
|
875
|
-
|
477
|
+
*Guo Xiang*
|
876
478
|
|
877
|
-
|
479
|
+
* SQLite3 adapter `alter_table` method restores foreign keys.
|
878
480
|
|
879
|
-
*
|
481
|
+
*Yasuo Honda*
|
880
482
|
|
881
|
-
|
882
|
-
recognize 't' and 'f' as was previously serialized.
|
483
|
+
* Allow `:to_table` option to `invert_remove_foreign_key`.
|
883
484
|
|
884
|
-
|
885
|
-
for SQLite databases, so it's implemented behind a configuration flag
|
886
|
-
whose default false value is deprecated.
|
887
|
-
|
888
|
-
*Lisa Ugray*
|
485
|
+
Example:
|
889
486
|
|
890
|
-
|
891
|
-
`in_batches`).
|
487
|
+
remove_foreign_key :accounts, to_table: :owners
|
892
488
|
|
893
|
-
|
894
|
-
until the end of the request or job.
|
489
|
+
*Nikolay Epifanov*, *Rich Chen*
|
895
490
|
|
896
|
-
|
491
|
+
* Add environment & load_config dependency to `bin/rake db:seed` to enable
|
492
|
+
seed load in environments without Rails and custom DB configuration
|
897
493
|
|
898
|
-
*
|
899
|
-
`ActiveRecord::StatementInvalid` exceptions.
|
494
|
+
*Tobias Bielohlawek*
|
900
495
|
|
901
|
-
|
496
|
+
* Fix default value for mysql time types with specified precision.
|
902
497
|
|
903
|
-
*
|
498
|
+
*Nikolay Kondratyev*
|
904
499
|
|
905
|
-
|
500
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
906
501
|
|
907
502
|
*Ryuta Kamizono*
|
908
503
|
|
909
|
-
*
|
910
|
-
|
911
|
-
Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
|
912
|
-
inner transaction would still be marked as persisted.
|
913
|
-
|
914
|
-
This change fixes that by applying the state of the parent transaction to the child transaction when the
|
915
|
-
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
916
|
-
|
917
|
-
*Eileen M. Uchitelle*, *Aaron Patterson*
|
918
|
-
|
919
|
-
* Deprecate `set_state` method in `TransactionState`.
|
920
|
-
|
921
|
-
Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
|
922
|
-
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
923
|
-
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
924
|
-
|
925
|
-
*Eileen M. Uchitelle*, *Aaron Patterson*
|
504
|
+
* Migrations raise when duplicate column definition.
|
926
505
|
|
927
|
-
|
506
|
+
Fixes #33024.
|
928
507
|
|
929
|
-
*
|
508
|
+
*Federico Martinez*
|
930
509
|
|
931
|
-
*
|
932
|
-
without being connected.
|
510
|
+
* Bump minimum SQLite version to 3.8
|
933
511
|
|
934
|
-
*
|
512
|
+
*Yasuo Honda*
|
935
513
|
|
936
|
-
*
|
937
|
-
if the child records were deleted before the parent was saved, they would
|
938
|
-
still be persisted. Now, if child records are deleted before the parent is saved
|
939
|
-
on a `has_many :through` association, the child records will not be persisted.
|
514
|
+
* Fix parent record should not get saved with duplicate children records.
|
940
515
|
|
941
|
-
|
516
|
+
Fixes #32940.
|
942
517
|
|
943
|
-
*
|
944
|
-
the merged relation into LEFT OUTER JOIN.
|
518
|
+
*Santosh Wadghule*
|
945
519
|
|
946
|
-
|
520
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
947
521
|
|
948
|
-
|
949
|
-
Author.joins(:posts).merge(Post.joins(:comments))
|
950
|
-
# Before the change:
|
951
|
-
#=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
|
522
|
+
*Brian Durand*
|
952
523
|
|
953
|
-
|
954
|
-
|
955
|
-
```
|
524
|
+
* Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
|
525
|
+
use loaded association ids if present.
|
956
526
|
|
957
|
-
*
|
527
|
+
*Graham Turner*
|
958
528
|
|
959
|
-
*
|
960
|
-
`locking_column`, without default value, is null in the database.
|
529
|
+
* Add support to preload associations of polymorphic associations when not all the records have the requested associations.
|
961
530
|
|
962
|
-
*
|
531
|
+
*Dana Sherson*
|
963
532
|
|
964
|
-
*
|
965
|
-
`locking_column` is null in the database.
|
533
|
+
* Add `touch_all` method to `ActiveRecord::Relation`.
|
966
534
|
|
967
|
-
|
535
|
+
Example:
|
968
536
|
|
969
|
-
|
537
|
+
Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
970
538
|
|
971
|
-
*
|
539
|
+
*fatkodima*, *duggiefresh*
|
972
540
|
|
973
|
-
*
|
541
|
+
* Add `ActiveRecord::Base.base_class?` predicate.
|
974
542
|
|
975
|
-
*
|
543
|
+
*Bogdan Gusiev*
|
976
544
|
|
977
|
-
*
|
545
|
+
* Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
|
978
546
|
|
979
|
-
*
|
547
|
+
*Tan Huynh*, *Yukio Mizuta*
|
980
548
|
|
981
|
-
*
|
549
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
982
550
|
|
983
|
-
|
551
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
984
552
|
|
985
|
-
|
553
|
+
* Deprecate `update_attributes`/`!` in favor of `update`/`!`.
|
986
554
|
|
987
|
-
*
|
988
|
-
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
989
|
-
that does not include a timestamp any more.
|
555
|
+
*Eddie Lebow*
|
990
556
|
|
991
|
-
|
992
|
-
|
557
|
+
* Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
|
558
|
+
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
993
559
|
|
994
560
|
*DHH*
|
995
561
|
|
996
|
-
*
|
997
|
-
|
998
|
-
*Rusty Geldmacher*, *Guillermo Iguaran*
|
999
|
-
|
1000
|
-
* Add type caster to `RuntimeReflection#alias_name`.
|
1001
|
-
|
1002
|
-
Fixes #28959.
|
1003
|
-
|
1004
|
-
*Jon Moss*
|
1005
|
-
|
1006
|
-
* Deprecate `supports_statement_cache?`.
|
1007
|
-
|
1008
|
-
*Ryuta Kamizono*
|
1009
|
-
|
1010
|
-
* Raise error `UnknownMigrationVersionError` on the movement of migrations
|
1011
|
-
when the current migration does not exist.
|
562
|
+
* Add `Relation#pick` as short-hand for single-value plucks.
|
1012
563
|
|
1013
|
-
*
|
1014
|
-
|
1015
|
-
* Fix `bin/rails db:forward` first migration.
|
1016
|
-
|
1017
|
-
*bogdanvlviv*
|
1018
|
-
|
1019
|
-
* Support Descending Indexes for MySQL.
|
1020
|
-
|
1021
|
-
MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
|
1022
|
-
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
1023
|
-
|
1024
|
-
*Ryuta Kamizono*
|
1025
|
-
|
1026
|
-
* Fix inconsistency with changed attributes when overriding Active Record attribute reader.
|
1027
|
-
|
1028
|
-
*bogdanvlviv*
|
1029
|
-
|
1030
|
-
* When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
|
1031
|
-
Previously this method always returned an empty array.
|
1032
|
-
|
1033
|
-
*Kevin McPhillips*
|
564
|
+
*DHH*
|
1034
565
|
|
1035
566
|
|
1036
|
-
Please check [5-
|
567
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
|