activerecord 5.1.7 → 5.2.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 +583 -673
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -5
- data/examples/performance.rb +2 -0
- data/examples/simple.rb +2 -0
- data/lib/active_record/aggregations.rb +6 -5
- data/lib/active_record/association_relation.rb +7 -5
- data/lib/active_record/associations/alias_tracker.rb +19 -27
- data/lib/active_record/associations/association.rb +41 -37
- data/lib/active_record/associations/association_scope.rb +38 -50
- data/lib/active_record/associations/belongs_to_association.rb +27 -8
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -8
- data/lib/active_record/associations/builder/association.rb +4 -7
- data/lib/active_record/associations/builder/belongs_to.rb +12 -4
- data/lib/active_record/associations/builder/collection_association.rb +3 -3
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +3 -1
- data/lib/active_record/associations/builder/has_many.rb +2 -0
- data/lib/active_record/associations/builder/has_one.rb +2 -0
- data/lib/active_record/associations/builder/singular_association.rb +2 -0
- data/lib/active_record/associations/collection_association.rb +59 -47
- data/lib/active_record/associations/collection_proxy.rb +20 -49
- data/lib/active_record/associations/foreign_association.rb +2 -0
- data/lib/active_record/associations/has_many_association.rb +12 -1
- data/lib/active_record/associations/has_many_through_association.rb +36 -30
- data/lib/active_record/associations/has_one_association.rb +12 -1
- data/lib/active_record/associations/has_one_through_association.rb +13 -8
- data/lib/active_record/associations/join_dependency/join_association.rb +39 -63
- data/lib/active_record/associations/join_dependency/join_base.rb +9 -8
- data/lib/active_record/associations/join_dependency/join_part.rb +9 -9
- data/lib/active_record/associations/join_dependency.rb +48 -93
- data/lib/active_record/associations/preloader/association.rb +45 -61
- data/lib/active_record/associations/preloader/through_association.rb +71 -79
- data/lib/active_record/associations/preloader.rb +18 -38
- data/lib/active_record/associations/singular_association.rb +14 -16
- data/lib/active_record/associations/through_association.rb +26 -11
- data/lib/active_record/associations.rb +40 -63
- data/lib/active_record/attribute_assignment.rb +2 -5
- data/lib/active_record/attribute_decorators.rb +3 -2
- data/lib/active_record/attribute_methods/before_type_cast.rb +2 -0
- data/lib/active_record/attribute_methods/dirty.rb +30 -214
- data/lib/active_record/attribute_methods/primary_key.rb +7 -6
- data/lib/active_record/attribute_methods/query.rb +2 -0
- data/lib/active_record/attribute_methods/read.rb +9 -3
- data/lib/active_record/attribute_methods/serialization.rb +23 -0
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +6 -8
- data/lib/active_record/attribute_methods/write.rb +21 -9
- data/lib/active_record/attribute_methods.rb +65 -24
- data/lib/active_record/attributes.rb +6 -5
- data/lib/active_record/autosave_association.rb +35 -19
- data/lib/active_record/base.rb +2 -0
- data/lib/active_record/callbacks.rb +8 -6
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +2 -0
- data/lib/active_record/collection_cache_key.rb +12 -8
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +139 -41
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +7 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +174 -33
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +15 -5
- data/lib/active_record/connection_adapters/abstract/quoting.rb +13 -31
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +14 -5
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +64 -6
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +31 -53
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +152 -81
- data/lib/active_record/connection_adapters/abstract/transaction.rb +66 -21
- data/lib/active_record/connection_adapters/abstract_adapter.rb +84 -97
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +92 -165
- data/lib/active_record/connection_adapters/column.rb +3 -1
- data/lib/active_record/connection_adapters/connection_specification.rb +17 -3
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +13 -2
- data/lib/active_record/connection_adapters/mysql/column.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +47 -2
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +9 -10
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +5 -3
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +7 -10
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +30 -30
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +106 -1
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +8 -2
- data/lib/active_record/connection_adapters/postgresql/column.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -0
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +18 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +19 -25
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +50 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +24 -11
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +20 -13
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +233 -111
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +57 -73
- data/lib/active_record/connection_adapters/schema_cache.rb +4 -2
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +22 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -15
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +3 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +75 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +81 -94
- data/lib/active_record/connection_adapters/statement_pool.rb +2 -0
- data/lib/active_record/connection_handling.rb +4 -2
- data/lib/active_record/core.rb +41 -61
- data/lib/active_record/counter_cache.rb +10 -3
- data/lib/active_record/define_callbacks.rb +5 -3
- data/lib/active_record/dynamic_matchers.rb +9 -9
- data/lib/active_record/enum.rb +18 -13
- data/lib/active_record/errors.rb +42 -3
- data/lib/active_record/explain.rb +3 -1
- data/lib/active_record/explain_registry.rb +2 -0
- data/lib/active_record/explain_subscriber.rb +2 -0
- data/lib/active_record/fixture_set/file.rb +2 -0
- data/lib/active_record/fixtures.rb +67 -60
- data/lib/active_record/gem_version.rb +4 -2
- data/lib/active_record/inheritance.rb +49 -19
- data/lib/active_record/integration.rb +58 -19
- data/lib/active_record/internal_metadata.rb +2 -0
- data/lib/active_record/legacy_yaml_adapter.rb +3 -1
- data/lib/active_record/locking/optimistic.rb +14 -17
- data/lib/active_record/locking/pessimistic.rb +9 -6
- data/lib/active_record/log_subscriber.rb +43 -0
- data/lib/active_record/migration/command_recorder.rb +11 -9
- data/lib/active_record/migration/compatibility.rb +47 -9
- data/lib/active_record/migration/join_table.rb +2 -0
- data/lib/active_record/migration.rb +189 -139
- data/lib/active_record/model_schema.rb +16 -21
- data/lib/active_record/nested_attributes.rb +18 -6
- data/lib/active_record/no_touching.rb +3 -1
- data/lib/active_record/null_relation.rb +2 -0
- data/lib/active_record/persistence.rb +167 -16
- data/lib/active_record/query_cache.rb +6 -8
- data/lib/active_record/querying.rb +4 -2
- data/lib/active_record/railtie.rb +62 -6
- data/lib/active_record/railties/console_sandbox.rb +2 -0
- data/lib/active_record/railties/controller_runtime.rb +2 -0
- data/lib/active_record/railties/databases.rake +46 -36
- data/lib/active_record/readonly_attributes.rb +3 -2
- data/lib/active_record/reflection.rb +108 -194
- data/lib/active_record/relation/batches/batch_enumerator.rb +2 -0
- data/lib/active_record/relation/batches.rb +20 -5
- data/lib/active_record/relation/calculations.rb +45 -19
- data/lib/active_record/relation/delegation.rb +45 -27
- data/lib/active_record/relation/finder_methods.rb +75 -76
- data/lib/active_record/relation/from_clause.rb +2 -8
- data/lib/active_record/relation/merger.rb +53 -23
- data/lib/active_record/relation/predicate_builder/array_handler.rb +10 -7
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +46 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +2 -2
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +12 -1
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +56 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +26 -9
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/predicate_builder.rb +60 -79
- data/lib/active_record/relation/query_attribute.rb +28 -2
- data/lib/active_record/relation/query_methods.rb +128 -99
- data/lib/active_record/relation/record_fetch_warning.rb +2 -0
- data/lib/active_record/relation/spawn_methods.rb +4 -2
- data/lib/active_record/relation/where_clause.rb +65 -68
- data/lib/active_record/relation/where_clause_factory.rb +5 -48
- data/lib/active_record/relation.rb +120 -214
- data/lib/active_record/result.rb +2 -0
- data/lib/active_record/runtime_registry.rb +2 -0
- data/lib/active_record/sanitization.rb +129 -121
- data/lib/active_record/schema.rb +4 -2
- data/lib/active_record/schema_dumper.rb +36 -26
- data/lib/active_record/schema_migration.rb +2 -0
- data/lib/active_record/scoping/default.rb +8 -9
- data/lib/active_record/scoping/named.rb +23 -7
- data/lib/active_record/scoping.rb +9 -8
- data/lib/active_record/secure_token.rb +2 -0
- data/lib/active_record/serialization.rb +2 -0
- data/lib/active_record/statement_cache.rb +23 -13
- data/lib/active_record/store.rb +3 -1
- data/lib/active_record/suppressor.rb +2 -0
- data/lib/active_record/table_metadata.rb +12 -3
- data/lib/active_record/tasks/database_tasks.rb +25 -14
- data/lib/active_record/tasks/mysql_database_tasks.rb +9 -48
- data/lib/active_record/tasks/postgresql_database_tasks.rb +10 -2
- data/lib/active_record/tasks/sqlite_database_tasks.rb +25 -3
- data/lib/active_record/timestamp.rb +6 -6
- data/lib/active_record/touch_later.rb +2 -0
- data/lib/active_record/transactions.rb +33 -28
- data/lib/active_record/translation.rb +2 -0
- data/lib/active_record/type/adapter_specific_registry.rb +2 -0
- data/lib/active_record/type/date.rb +2 -0
- data/lib/active_record/type/date_time.rb +2 -0
- data/lib/active_record/type/decimal_without_scale.rb +2 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +2 -0
- data/lib/active_record/type/internal/timezone.rb +2 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +2 -0
- data/lib/active_record/type/text.rb +2 -0
- data/lib/active_record/type/time.rb +2 -0
- data/lib/active_record/type/type_map.rb +2 -0
- data/lib/active_record/type/unsigned_integer.rb +2 -0
- data/lib/active_record/type.rb +4 -1
- data/lib/active_record/type_caster/connection.rb +2 -0
- data/lib/active_record/type_caster/map.rb +3 -1
- data/lib/active_record/type_caster.rb +2 -0
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +2 -0
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +2 -0
- data/lib/active_record/validations/uniqueness.rb +35 -5
- data/lib/active_record/validations.rb +2 -0
- data/lib/active_record/version.rb +2 -0
- data/lib/active_record.rb +11 -4
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +3 -1
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration.rb +2 -0
- data/lib/rails/generators/active_record/model/model_generator.rb +2 -23
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +0 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- data/lib/rails/generators/active_record.rb +3 -1
- metadata +23 -36
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -15
- data/lib/active_record/associations/preloader/collection_association.rb +0 -17
- data/lib/active_record/associations/preloader/has_many.rb +0 -15
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
- data/lib/active_record/associations/preloader/has_one.rb +0 -15
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -18
- data/lib/active_record/attribute/user_provided_default.rb +0 -30
- data/lib/active_record/attribute.rb +0 -240
- data/lib/active_record/attribute_mutation_tracker.rb +0 -122
- data/lib/active_record/attribute_set/builder.rb +0 -126
- data/lib/active_record/attribute_set/yaml_encoder.rb +0 -41
- data/lib/active_record/attribute_set.rb +0 -113
- data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -10
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/relation/predicate_builder/association_query_handler.rb +0 -88
- data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -59
- data/lib/active_record/type/internal/abstract_json.rb +0 -37
data/CHANGELOG.md
CHANGED
@@ -1,1116 +1,1026 @@
|
|
1
|
-
## Rails 5.
|
1
|
+
## Rails 5.2.6 (May 05, 2021) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* No changes.
|
4
4
|
|
5
|
-
*Ryuta Kamizono*
|
6
5
|
|
7
|
-
|
6
|
+
## Rails 5.2.5 (March 26, 2021) ##
|
8
7
|
|
9
|
-
|
8
|
+
* No changes.
|
10
9
|
|
11
|
-
* `becomes` should clear the mutation tracker which is created in `after_initialize`.
|
12
10
|
|
13
|
-
|
11
|
+
## Rails 5.2.4.6 (May 05, 2021) ##
|
14
12
|
|
15
|
-
|
13
|
+
* No changes.
|
16
14
|
|
17
15
|
|
18
|
-
## Rails 5.
|
16
|
+
## Rails 5.2.4.5 (February 10, 2021) ##
|
19
17
|
|
20
|
-
*
|
18
|
+
* Fix possible DoS vector in PostgreSQL money type
|
19
|
+
|
20
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
21
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
22
|
+
fixes the regexp.
|
23
|
+
|
24
|
+
Thanks to @dee-see from Hackerone for this patch!
|
25
|
+
|
26
|
+
[CVE-2021-22880]
|
21
27
|
|
28
|
+
*Aaron Patterson*
|
22
29
|
|
23
|
-
|
30
|
+
|
31
|
+
## Rails 5.2.4.4 (September 09, 2020) ##
|
24
32
|
|
25
33
|
* No changes.
|
26
34
|
|
27
35
|
|
28
|
-
## Rails 5.
|
36
|
+
## Rails 5.2.4.3 (May 18, 2020) ##
|
29
37
|
|
30
|
-
*
|
38
|
+
* No changes.
|
31
39
|
|
32
|
-
|
40
|
+
## Rails 5.2.4.2 (March 19, 2020) ##
|
33
41
|
|
34
|
-
*
|
42
|
+
* No changes.
|
35
43
|
|
36
|
-
PR #20317 changed the behavior of datetime columns so that when they
|
37
|
-
have a specified precision then on assignment the value is rounded to
|
38
|
-
that precision. This behavior is now applied to time columns as well.
|
39
44
|
|
40
|
-
|
45
|
+
## Rails 5.2.4.1 (December 18, 2019) ##
|
41
46
|
|
42
|
-
|
47
|
+
* No changes.
|
43
48
|
|
44
|
-
* Normalize time column values for SQLite database.
|
45
49
|
|
46
|
-
|
47
|
-
because until #24542 the quoting for time columns didn't remove the date
|
48
|
-
component. To ensure that values are consistent we now normalize the
|
49
|
-
date component to 2001-01-01 on reading and writing.
|
50
|
+
## Rails 5.2.4 (November 27, 2019) ##
|
50
51
|
|
51
|
-
|
52
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
52
53
|
|
53
|
-
|
54
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
55
|
+
associations, the callback for a `has_many` association was run while
|
56
|
+
another instance of the same callback on the same association hadn't
|
57
|
+
finished running. When control returned to the first instance of the
|
58
|
+
callback, the instance variable had changed, and subsequent associated
|
59
|
+
records weren't saved correctly. Specifically, the ID field for the
|
60
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
54
61
|
|
55
|
-
|
56
|
-
was removed however it only removed it when it was 2001-01-01. Now the
|
57
|
-
date component is removed irrespective of what the date is.
|
62
|
+
Fixes #28080.
|
58
63
|
|
59
|
-
*
|
64
|
+
*Larry Reid*
|
60
65
|
|
61
|
-
* Fix
|
66
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
67
|
+
|
68
|
+
Fixes #36022.
|
62
69
|
|
63
70
|
*Ryuta Kamizono*
|
64
71
|
|
65
|
-
*
|
66
|
-
`locking_column`, without default value, is null in the database.
|
72
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
67
73
|
|
68
|
-
*
|
74
|
+
*Martin R. Schuster*
|
69
75
|
|
70
|
-
*
|
71
|
-
`locking column` is null in the database.
|
76
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
72
77
|
|
73
|
-
|
78
|
+
Fixes #36465.
|
74
79
|
|
80
|
+
*Jeff Doering*
|
75
81
|
|
76
|
-
|
82
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
83
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
77
84
|
|
78
|
-
|
85
|
+
Fixes #33249.
|
79
86
|
|
80
|
-
*
|
87
|
+
*Ryan H. Kerr*
|
81
88
|
|
82
|
-
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
83
89
|
|
84
|
-
|
90
|
+
## Rails 5.2.3 (March 27, 2019) ##
|
91
|
+
|
92
|
+
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
93
|
+
|
94
|
+
Fixes #35214.
|
95
|
+
|
96
|
+
*Juani Villarejo*
|
97
|
+
|
98
|
+
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
85
99
|
|
86
100
|
*Ryuta Kamizono*
|
87
101
|
|
88
|
-
*
|
89
|
-
SQL queries for association counting.
|
102
|
+
* Don't allow `where` with invalid value matches to nil values.
|
90
103
|
|
91
|
-
|
104
|
+
Fixes #33624.
|
92
105
|
|
93
|
-
*
|
106
|
+
*Ryuta Kamizono*
|
94
107
|
|
95
|
-
|
108
|
+
* Restore an ability that class level `update` without giving ids.
|
96
109
|
|
97
|
-
|
110
|
+
Fixes #34743.
|
98
111
|
|
99
112
|
*Ryuta Kamizono*
|
100
113
|
|
101
|
-
* Fix
|
114
|
+
* Fix join table column quoting with SQLite.
|
102
115
|
|
103
|
-
|
104
|
-
# create_table :posts do |t|
|
105
|
-
# t.integer :comments_count, default: 0
|
106
|
-
# t.integer :lock_version
|
107
|
-
# t.timestamps
|
108
|
-
# end
|
109
|
-
class Post < ApplicationRecord
|
110
|
-
end
|
116
|
+
*Gannon McGibbon*
|
111
117
|
|
112
|
-
|
113
|
-
# t.belongs_to :post
|
114
|
-
# end
|
115
|
-
class Comment < ApplicationRecord
|
116
|
-
belongs_to :post, touch: true, counter_cache: true
|
117
|
-
end
|
118
|
-
```
|
118
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
119
119
|
|
120
|
-
|
121
|
-
```
|
122
|
-
post = Post.create!
|
123
|
-
# => begin transaction
|
124
|
-
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
125
|
-
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
126
|
-
commit transaction
|
120
|
+
*Ryuta Kamizono*
|
127
121
|
|
128
|
-
|
129
|
-
# => begin transaction
|
130
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
122
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
131
123
|
|
132
|
-
|
133
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
124
|
+
*Gannon McGibbon*
|
134
125
|
|
135
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
136
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
137
|
-
rollback transaction
|
138
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
139
126
|
|
140
|
-
|
141
|
-
# => begin transaction
|
142
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
127
|
+
## Rails 5.2.2.1 (March 11, 2019) ##
|
143
128
|
|
144
|
-
|
145
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
129
|
+
* No changes.
|
146
130
|
|
147
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
148
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
149
|
-
rollback transaction
|
150
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
151
|
-
```
|
152
131
|
|
153
|
-
|
154
|
-
```
|
155
|
-
post = Post.create!
|
156
|
-
# => begin transaction
|
157
|
-
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
158
|
-
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
159
|
-
commit transaction
|
132
|
+
## Rails 5.2.2 (December 04, 2018) ##
|
160
133
|
|
161
|
-
|
162
|
-
# => begin transaction
|
163
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
134
|
+
* Do not ignore the scoping with query methods in the scope block.
|
164
135
|
|
165
|
-
|
166
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
167
|
-
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
168
|
-
commit transaction
|
136
|
+
*Ryuta Kamizono*
|
169
137
|
|
170
|
-
|
171
|
-
# => begin transaction
|
172
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
138
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
173
139
|
|
174
|
-
|
175
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
176
|
-
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
177
|
-
commit transaction
|
178
|
-
```
|
140
|
+
*Gannon McGibbon*
|
179
141
|
|
180
|
-
|
142
|
+
* Allow spaces in postgres table names.
|
181
143
|
|
182
|
-
|
144
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
|
145
|
+
adapter.
|
183
146
|
|
184
|
-
*
|
185
|
-
without being connected.
|
147
|
+
*Gannon McGibbon*
|
186
148
|
|
187
|
-
|
149
|
+
* Cached columns_hash fields should be excluded from ResultSet#column_types
|
188
150
|
|
189
|
-
|
190
|
-
|
151
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
152
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
191
153
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
```
|
154
|
+
```ruby
|
155
|
+
class DeveloperName < ActiveRecord::Type::String
|
156
|
+
def deserialize(value)
|
157
|
+
"Developer: #{value}"
|
158
|
+
end
|
159
|
+
end
|
199
160
|
|
200
|
-
|
201
|
-
|
202
|
-
$ RAILS_ENV=test rails dbconsole
|
203
|
-
> SELECT * FROM ar_internal_metadata;
|
204
|
-
key|value|created_at|updated_at
|
205
|
-
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
206
|
-
```
|
161
|
+
class AttributedDeveloper < ActiveRecord::Base
|
162
|
+
self.table_name = "developers"
|
207
163
|
|
208
|
-
|
164
|
+
attribute :name, DeveloperName.new
|
209
165
|
|
210
|
-
|
166
|
+
self.ignored_columns += ["name"]
|
167
|
+
end
|
211
168
|
|
212
|
-
|
169
|
+
developer = AttributedDeveloper.create
|
170
|
+
developer.update_column :name, "name"
|
213
171
|
|
214
|
-
|
172
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
173
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
174
|
+
```
|
215
175
|
|
216
|
-
*
|
176
|
+
*Dmitry Tsepelev*
|
217
177
|
|
218
|
-
*
|
178
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
219
179
|
|
220
|
-
|
180
|
+
*Emmanuel Byrd*
|
221
181
|
|
222
|
-
|
182
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
183
|
+
if the attribute does not exist.
|
223
184
|
|
224
|
-
*
|
185
|
+
*Sean Griffin*
|
225
186
|
|
226
|
-
|
187
|
+
* Do not use prepared statement in queries that have a large number of binds.
|
227
188
|
|
228
189
|
*Ryuta Kamizono*
|
229
190
|
|
191
|
+
* Fix query cache to load before first request.
|
230
192
|
|
231
|
-
|
193
|
+
*Eileen M. Uchitelle*
|
232
194
|
|
233
|
-
*
|
195
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
234
196
|
|
197
|
+
Fixes #33056.
|
235
198
|
|
236
|
-
|
199
|
+
*Federico Martinez*
|
237
200
|
|
238
|
-
*
|
201
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
239
202
|
|
240
|
-
|
203
|
+
*Darwin Wu*
|
241
204
|
|
242
|
-
|
205
|
+
* Fix regression setting children record in parent `before_save` callback.
|
243
206
|
|
244
|
-
*
|
207
|
+
*Guo Xiang Tan*
|
245
208
|
|
246
|
-
|
209
|
+
* Prevent leaking of user's DB credentials on `rails db:create` failure.
|
247
210
|
|
248
|
-
*
|
211
|
+
*bogdanvlviv*
|
249
212
|
|
250
|
-
|
251
|
-
bind values used by the `or` instead.
|
213
|
+
* Clear mutation tracker before continuing the around callbacks.
|
252
214
|
|
253
|
-
|
254
|
-
Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
|
255
|
-
# Currently:
|
256
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
257
|
-
# With fix:
|
258
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
259
|
-
```
|
215
|
+
*Yuya Tanaka*
|
260
216
|
|
261
|
-
|
217
|
+
* Prevent deadlocks when waiting for connection from pool.
|
262
218
|
|
263
|
-
*
|
264
|
-
`destroyed_by_association` will now be set to the reflection, matching the
|
265
|
-
behaviour of `has_many` associations.
|
219
|
+
*Brent Wheeldon*
|
266
220
|
|
267
|
-
|
221
|
+
* Avoid extra scoping when using `Relation#update` that was causing this method to change the current scope.
|
268
222
|
|
223
|
+
*Ryuta Kamizono*
|
269
224
|
|
270
|
-
|
225
|
+
* Fix numericality validator not to be affected by custom getter.
|
271
226
|
|
272
|
-
*
|
227
|
+
*Ryuta Kamizono*
|
273
228
|
|
229
|
+
* Fix bulk change table ignores comment option on PostgreSQL.
|
274
230
|
|
275
|
-
|
231
|
+
*Yoshiyuki Kinjo*
|
276
232
|
|
277
|
-
* No changes.
|
278
233
|
|
279
|
-
|
280
|
-
## Rails 5.1.3.rc2 (July 25, 2017) ##
|
234
|
+
## Rails 5.2.1.1 (November 27, 2018) ##
|
281
235
|
|
282
236
|
* No changes.
|
283
237
|
|
284
238
|
|
285
|
-
## Rails 5.1
|
239
|
+
## Rails 5.2.1 (August 07, 2018) ##
|
286
240
|
|
287
|
-
*
|
288
|
-
`current_scope`, with the exception of `unscoped`.
|
241
|
+
* PostgreSQL: Support new relkind for partitioned tables.
|
289
242
|
|
290
|
-
Fixes #
|
243
|
+
Fixes #33008.
|
291
244
|
|
292
|
-
*
|
245
|
+
*Yannick Schutz*
|
293
246
|
|
294
|
-
*
|
295
|
-
if the child records were deleted before the parent was saved, they would
|
296
|
-
still be persisted. Now, if child records are deleted before the parent is saved
|
297
|
-
on a `has_many :through` association, the child records will not be persisted.
|
247
|
+
* Rollback parent transaction when children fails to update.
|
298
248
|
|
299
|
-
*
|
249
|
+
*Guillaume Malette*
|
300
250
|
|
251
|
+
* Fix default value for MySQL time types with specified precision.
|
301
252
|
|
302
|
-
|
253
|
+
*Nikolay Kondratyev*
|
303
254
|
|
304
|
-
*
|
305
|
-
methods stubbed, and they respect extension modules applied by a default
|
306
|
-
scope.
|
255
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
307
256
|
|
308
257
|
*Ryuta Kamizono*
|
309
258
|
|
310
|
-
*
|
311
|
-
|
312
|
-
Fixes #28589.
|
259
|
+
* Fix `save` in `after_create_commit` won't invoke extra `after_create_commit`.
|
313
260
|
|
314
|
-
|
261
|
+
Fixes #32831.
|
315
262
|
|
263
|
+
*Ryuta Kamizono*
|
316
264
|
|
317
|
-
|
265
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
318
266
|
|
319
|
-
*
|
267
|
+
*Brian Durand*
|
320
268
|
|
321
|
-
|
269
|
+
* Fix parent record should not get saved with duplicate children records.
|
322
270
|
|
323
|
-
|
271
|
+
Fixes #32940.
|
324
272
|
|
273
|
+
*Santosh Wadghule*
|
325
274
|
|
326
|
-
|
275
|
+
* Fix that association's after_touch is not called with counter cache.
|
327
276
|
|
328
|
-
|
277
|
+
Fixes #31559.
|
329
278
|
|
330
|
-
*
|
279
|
+
*Ryuta Kamizono*
|
331
280
|
|
332
|
-
*
|
333
|
-
transactional fixtures, a nested transaction will temporarily lock the
|
334
|
-
connection to the current thread, forcing others to wait.
|
281
|
+
* `becomes` should clear the mutation tracker which is created in `after_initialize`.
|
335
282
|
|
336
|
-
Fixes #
|
283
|
+
Fixes #32867.
|
337
284
|
|
338
|
-
*
|
285
|
+
*Ryuta Kamizono*
|
339
286
|
|
340
|
-
*
|
287
|
+
* Allow a belonging to parent object to be created from a new record.
|
341
288
|
|
342
|
-
|
343
|
-
load the records as needed.
|
289
|
+
*Jolyon Pawlyn*
|
344
290
|
|
345
|
-
|
291
|
+
* Fix that building record with assigning multiple has_one associations
|
292
|
+
wrongly persists through record.
|
346
293
|
|
347
|
-
|
294
|
+
Fixes #32511.
|
348
295
|
|
349
|
-
*
|
350
|
-
version-specific parts of the file.
|
296
|
+
*Sam DeCesare*
|
351
297
|
|
352
|
-
|
298
|
+
* Fix relation merging when one of the relations is going to skip the
|
299
|
+
query cache.
|
353
300
|
|
354
|
-
*
|
301
|
+
*James Williams*
|
355
302
|
|
356
|
-
* Add `:default` option to `belongs_to`.
|
357
303
|
|
358
|
-
|
359
|
-
record before validation. For example:
|
304
|
+
## Rails 5.2.0 (April 09, 2018) ##
|
360
305
|
|
361
|
-
|
362
|
-
belongs_to :account
|
363
|
-
before_validation -> { self.account ||= Current.account }
|
306
|
+
* MySQL: Support mysql2 0.5.x.
|
364
307
|
|
365
|
-
|
366
|
-
belongs_to :account, default: -> { Current.account }
|
308
|
+
*Aaron Stone*
|
367
309
|
|
368
|
-
|
310
|
+
* Apply time column precision on assignment.
|
369
311
|
|
370
|
-
|
312
|
+
PR #20317 changed the behavior of datetime columns so that when they
|
313
|
+
have a specified precision then on assignment the value is rounded to
|
314
|
+
that precision. This behavior is now applied to time columns as well.
|
371
315
|
|
372
|
-
|
316
|
+
Fixes #30301.
|
373
317
|
|
374
|
-
*
|
318
|
+
*Andrew White*
|
375
319
|
|
376
|
-
|
320
|
+
* Normalize time column values for SQLite database.
|
377
321
|
|
378
|
-
|
322
|
+
For legacy reasons, time columns in SQLite are stored as full datetimes
|
323
|
+
because until #24542 the quoting for time columns didn't remove the date
|
324
|
+
component. To ensure that values are consistent we now normalize the
|
325
|
+
date component to 2001-01-01 on reading and writing.
|
379
326
|
|
380
|
-
*
|
327
|
+
*Andrew White*
|
381
328
|
|
382
|
-
|
383
|
-
path defined in `Rails.application.config.paths` however the code checked
|
384
|
-
for the presence of the `Rails` constant but not the `Rails.application`
|
385
|
-
method which caused problems when using Active Record and generators outside
|
386
|
-
of the context of a Rails application.
|
329
|
+
* Ensure that the date component is removed when quoting times.
|
387
330
|
|
388
|
-
|
331
|
+
PR #24542 altered the quoting for time columns so that the date component
|
332
|
+
was removed however it only removed it when it was 2001-01-01. Now the
|
333
|
+
date component is removed irrespective of what the date is.
|
389
334
|
|
390
335
|
*Andrew White*
|
391
336
|
|
392
|
-
* Fix `
|
337
|
+
* Fix `dependent: :destroy` issue for has_one/belongs_to relationship where
|
338
|
+
the parent class was getting deleted when the child was not.
|
393
339
|
|
394
|
-
Fixes #
|
340
|
+
Fixes #32022.
|
395
341
|
|
396
|
-
*
|
342
|
+
*Fernando Gorodscy*
|
397
343
|
|
398
|
-
*
|
344
|
+
* Whitelist `NULLS FIRST` and `NULLS LAST` in order clauses too.
|
399
345
|
|
400
|
-
*
|
346
|
+
*Xavier Noria*
|
401
347
|
|
402
|
-
* Fix
|
348
|
+
* Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
|
403
349
|
|
404
350
|
*Ryuta Kamizono*
|
405
351
|
|
406
|
-
*
|
352
|
+
* Fix `#columns_for_distinct` of MySQL and PostgreSQL to make
|
353
|
+
`ActiveRecord::FinderMethods#limited_ids_for` use correct primary key values
|
354
|
+
even if `ORDER BY` columns include other table's primary key.
|
407
355
|
|
408
|
-
|
409
|
-
between the two columns doesn't make sense since they are different types.
|
410
|
-
The `reference_id` column is usually an integer and the `reference_type`
|
411
|
-
column a string so options like `unsigned: true` will result in an invalid
|
412
|
-
table definition.
|
356
|
+
Fixes #28364.
|
413
357
|
|
414
|
-
*
|
415
|
-
|
416
|
-
* Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
|
358
|
+
*Takumi Kagiyama*
|
417
359
|
|
418
|
-
|
360
|
+
* Make `reflection.klass` raise if `polymorphic?` not to be misused.
|
419
361
|
|
420
|
-
|
362
|
+
Fixes #31876.
|
421
363
|
|
422
364
|
*Ryuta Kamizono*
|
423
365
|
|
424
|
-
*
|
366
|
+
* PostgreSQL: Allow pg-1.0 gem to be used with Active Record.
|
425
367
|
|
426
|
-
*
|
368
|
+
*Lars Kanis*
|
427
369
|
|
428
|
-
* Deprecate
|
370
|
+
* Deprecate `expand_hash_conditions_for_aggregates` without replacement.
|
371
|
+
Using a `Relation` for performing queries is the prefered API.
|
429
372
|
|
430
373
|
*Ryuta Kamizono*
|
431
374
|
|
432
|
-
* Fix
|
375
|
+
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
|
433
376
|
|
434
|
-
|
377
|
+
```
|
378
|
+
david_balance = customers(:david).balance
|
379
|
+
Customer.where(balance: [david_balance]).to_sql
|
435
380
|
|
436
|
-
|
381
|
+
# Before: WHERE `customers`.`balance` = NULL
|
382
|
+
# After : WHERE `customers`.`balance` = 50
|
383
|
+
```
|
437
384
|
|
438
|
-
|
385
|
+
Fixes #31723.
|
439
386
|
|
440
|
-
|
441
|
-
Internal representation of the timestamp type is UNIX time, This means
|
442
|
-
that timestamp columns are affected by time zone.
|
387
|
+
*Yutaro Kanagawa*
|
443
388
|
|
444
|
-
|
445
|
-
Query OK, 0 rows affected (0.00 sec)
|
389
|
+
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
446
390
|
|
447
|
-
|
448
|
-
Query OK, 1 row affected (0.02 sec)
|
391
|
+
Fixes #31783.
|
449
392
|
|
450
|
-
|
451
|
-
+---------------------+---------------------+
|
452
|
-
| ts | dt |
|
453
|
-
+---------------------+---------------------+
|
454
|
-
| 2016-02-07 22:11:44 | 2016-02-07 22:11:44 |
|
455
|
-
+---------------------+---------------------+
|
456
|
-
1 row in set (0.00 sec)
|
393
|
+
*Ryuta Kamizono*
|
457
394
|
|
458
|
-
|
459
|
-
Query OK, 0 rows affected (0.00 sec)
|
395
|
+
* Clear the transaction state when an Active Record object is duped.
|
460
396
|
|
461
|
-
|
462
|
-
+---------------------+---------------------+
|
463
|
-
| ts | dt |
|
464
|
-
+---------------------+---------------------+
|
465
|
-
| 2016-02-07 14:11:44 | 2016-02-07 22:11:44 |
|
466
|
-
+---------------------+---------------------+
|
467
|
-
1 row in set (0.00 sec)
|
397
|
+
Fixes #31670.
|
468
398
|
|
469
|
-
*
|
399
|
+
*Yuriy Ustushenko*
|
470
400
|
|
471
|
-
*
|
401
|
+
* Support for PostgreSQL foreign tables.
|
472
402
|
|
473
|
-
*
|
403
|
+
*fatkodima*
|
474
404
|
|
475
|
-
*
|
405
|
+
* Fix relation merger issue with `left_outer_joins`.
|
476
406
|
|
477
|
-
*
|
407
|
+
*Mehmet Emin İNAÇ*
|
478
408
|
|
479
|
-
*
|
409
|
+
* Don't allow destroyed object mutation after `save` or `save!` is called.
|
480
410
|
|
481
411
|
*Ryuta Kamizono*
|
482
412
|
|
483
|
-
*
|
413
|
+
* Take into account association conditions when deleting through records.
|
484
414
|
|
485
|
-
|
486
|
-
|
487
|
-
* Deprecate `supports_primary_key?` on connection adapters since it's
|
488
|
-
been long unused and unsupported.
|
415
|
+
Fixes #18424.
|
489
416
|
|
490
|
-
*
|
417
|
+
*Piotr Jakubowski*
|
491
418
|
|
492
|
-
*
|
493
|
-
so queries are not run against the previous table name.
|
419
|
+
* Fix nested `has_many :through` associations on unpersisted parent instances.
|
494
420
|
|
495
|
-
|
421
|
+
For example, if you have
|
496
422
|
|
497
|
-
|
423
|
+
class Post < ActiveRecord::Base
|
424
|
+
belongs_to :author
|
425
|
+
has_many :books, through: :author
|
426
|
+
has_many :subscriptions, through: :books
|
427
|
+
end
|
498
428
|
|
499
|
-
|
429
|
+
class Author < ActiveRecord::Base
|
430
|
+
has_one :post
|
431
|
+
has_many :books
|
432
|
+
has_many :subscriptions, through: :books
|
433
|
+
end
|
500
434
|
|
501
|
-
|
435
|
+
class Book < ActiveRecord::Base
|
436
|
+
belongs_to :author
|
437
|
+
has_many :subscriptions
|
438
|
+
end
|
502
439
|
|
503
|
-
|
440
|
+
class Subscription < ActiveRecord::Base
|
441
|
+
belongs_to :book
|
442
|
+
end
|
504
443
|
|
505
|
-
|
444
|
+
Before:
|
506
445
|
|
507
|
-
|
446
|
+
If `post` is not persisted, then `post.subscriptions` will be empty.
|
508
447
|
|
509
|
-
|
448
|
+
After:
|
510
449
|
|
511
|
-
|
450
|
+
If `post` is not persisted, then `post.subscriptions` can be set and used
|
451
|
+
just like it would if `post` were persisted.
|
512
452
|
|
513
|
-
|
453
|
+
Fixes #16313.
|
514
454
|
|
515
|
-
*
|
455
|
+
*Zoltan Kiss*
|
516
456
|
|
517
|
-
*
|
457
|
+
* Fixed inconsistency with `first(n)` when used with `limit()`.
|
458
|
+
The `first(n)` finder now respects the `limit()`, making it consistent
|
459
|
+
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
518
460
|
|
519
|
-
Fixes #
|
461
|
+
Fixes #23979.
|
520
462
|
|
521
|
-
*
|
463
|
+
*Brian Christian*
|
522
464
|
|
523
|
-
*
|
465
|
+
* Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
|
466
|
+
SQL queries for association counting.
|
524
467
|
|
525
|
-
|
526
|
-
MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
|
468
|
+
*Klas Eskilson*
|
527
469
|
|
528
|
-
|
529
|
-
Pass `stored: true` to persist the generated value (false by default).
|
470
|
+
* Fix to invoke callbacks when using `update_attribute`.
|
530
471
|
|
531
|
-
|
472
|
+
*Mike Busch*
|
532
473
|
|
533
|
-
|
534
|
-
t.string :name
|
535
|
-
t.virtual :upper_name, type: :string, as: "UPPER(name)"
|
536
|
-
t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
|
537
|
-
t.index :name_length # May be indexed, too!
|
538
|
-
end
|
474
|
+
* Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
|
539
475
|
|
540
476
|
*Ryuta Kamizono*
|
541
477
|
|
542
|
-
*
|
478
|
+
* Using subselect for `delete_all` with `limit` or `offset`.
|
543
479
|
|
544
480
|
*Ryuta Kamizono*
|
545
481
|
|
546
|
-
*
|
482
|
+
* Undefine attribute methods on descendants when resetting column
|
483
|
+
information.
|
547
484
|
|
548
|
-
*
|
485
|
+
*Chris Salzberg*
|
549
486
|
|
550
|
-
*
|
487
|
+
* Log database query callers.
|
551
488
|
|
552
|
-
|
489
|
+
Add `verbose_query_logs` configuration option to display the caller
|
490
|
+
of database queries in the log to facilitate N+1 query resolution
|
491
|
+
and other debugging.
|
553
492
|
|
554
|
-
|
493
|
+
Enabled in development only for new and upgraded applications. Not
|
494
|
+
recommended for use in the production environment since it relies
|
495
|
+
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
555
496
|
|
556
|
-
*
|
497
|
+
*Olivier Lacan*
|
557
498
|
|
558
|
-
*
|
499
|
+
* Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
|
559
500
|
|
560
|
-
|
501
|
+
```
|
502
|
+
# create_table :posts do |t|
|
503
|
+
# t.integer :comments_count, default: 0
|
504
|
+
# t.integer :lock_version
|
505
|
+
# t.timestamps
|
506
|
+
# end
|
507
|
+
class Post < ApplicationRecord
|
508
|
+
end
|
561
509
|
|
562
|
-
|
563
|
-
|
510
|
+
# create_table :comments do |t|
|
511
|
+
# t.belongs_to :post
|
512
|
+
# end
|
513
|
+
class Comment < ApplicationRecord
|
514
|
+
belongs_to :post, touch: true, counter_cache: true
|
515
|
+
end
|
516
|
+
```
|
564
517
|
|
565
|
-
|
518
|
+
Before:
|
519
|
+
```
|
520
|
+
post = Post.create!
|
521
|
+
# => begin transaction
|
522
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
523
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
524
|
+
commit transaction
|
566
525
|
|
567
|
-
|
526
|
+
comment = Comment.create!(post: post)
|
527
|
+
# => begin transaction
|
528
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
568
529
|
|
569
|
-
|
530
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
531
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
570
532
|
|
571
|
-
|
533
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
534
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
535
|
+
rollback transaction
|
536
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
572
537
|
|
573
|
-
|
538
|
+
Comment.take.destroy!
|
539
|
+
# => begin transaction
|
540
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
574
541
|
|
575
|
-
|
542
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
543
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
576
544
|
|
577
|
-
|
545
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
546
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
547
|
+
rollback transaction
|
548
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
549
|
+
```
|
578
550
|
|
579
|
-
|
551
|
+
After:
|
552
|
+
```
|
553
|
+
post = Post.create!
|
554
|
+
# => begin transaction
|
555
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
556
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
557
|
+
commit transaction
|
580
558
|
|
581
|
-
|
582
|
-
|
559
|
+
comment = Comment.create!(post: post)
|
560
|
+
# => begin transaction
|
561
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
583
562
|
|
584
|
-
|
563
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
564
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
565
|
+
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
566
|
+
commit transaction
|
585
567
|
|
586
|
-
|
568
|
+
comment.destroy!
|
569
|
+
# => begin transaction
|
570
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
587
571
|
|
588
|
-
|
589
|
-
|
572
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
573
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
574
|
+
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
575
|
+
commit transaction
|
576
|
+
```
|
590
577
|
|
591
|
-
|
578
|
+
Fixes #31199.
|
592
579
|
|
593
|
-
*
|
580
|
+
*bogdanvlviv*
|
594
581
|
|
595
|
-
|
582
|
+
* Add support for PostgreSQL operator classes to `add_index`.
|
596
583
|
|
597
|
-
|
584
|
+
Example:
|
598
585
|
|
599
|
-
|
586
|
+
add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
|
600
587
|
|
601
|
-
*
|
588
|
+
*Greg Navis*
|
602
589
|
|
603
|
-
*
|
590
|
+
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
604
591
|
|
605
|
-
|
592
|
+
Fixes #31120.
|
606
593
|
|
607
|
-
|
608
|
-
Topic.increment_counter(:messages_count, 1, touch: true)
|
609
|
-
Topic.decrement_counter(:messages_count, 1, touch: true)
|
594
|
+
*kinnrot*
|
610
595
|
|
611
|
-
|
612
|
-
|
596
|
+
* Add new error class `QueryCanceled` which will be raised
|
597
|
+
when canceling statement due to user request.
|
613
598
|
|
614
|
-
|
615
|
-
Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
|
599
|
+
*Ryuta Kamizono*
|
616
600
|
|
617
|
-
|
601
|
+
* Add `#up_only` to database migrations for code that is only relevant when
|
602
|
+
migrating up, e.g. populating a new column.
|
618
603
|
|
619
|
-
*
|
604
|
+
*Rich Daley*
|
620
605
|
|
621
|
-
*
|
606
|
+
* Require raw SQL fragments to be explicitly marked when used in
|
607
|
+
relation query methods.
|
622
608
|
|
623
|
-
|
609
|
+
Before:
|
610
|
+
```
|
611
|
+
Article.order("LENGTH(title)")
|
612
|
+
```
|
624
613
|
|
625
|
-
|
614
|
+
After:
|
615
|
+
```
|
616
|
+
Article.order(Arel.sql("LENGTH(title)"))
|
617
|
+
```
|
626
618
|
|
627
|
-
|
619
|
+
This prevents SQL injection if applications use the [strongly
|
620
|
+
discouraged] form `Article.order(params[:my_order])`, under the
|
621
|
+
mistaken belief that only column names will be accepted.
|
628
622
|
|
629
|
-
|
623
|
+
Raw SQL strings will now cause a deprecation warning, which will
|
624
|
+
become an UnknownAttributeReference error in Rails 6.0. Applications
|
625
|
+
can opt in to the future behavior by setting `allow_unsafe_raw_sql`
|
626
|
+
to `:disabled`.
|
630
627
|
|
631
|
-
|
628
|
+
Common and judged-safe string values (such as simple column
|
629
|
+
references) are unaffected:
|
630
|
+
```
|
631
|
+
Article.order("title DESC")
|
632
|
+
```
|
632
633
|
|
633
|
-
*
|
634
|
+
*Ben Toews*
|
634
635
|
|
635
|
-
|
636
|
+
* `update_all` will now pass its values to `Type#cast` before passing them to
|
637
|
+
`Type#serialize`. This means that `update_all(foo: 'true')` will properly
|
638
|
+
persist a boolean.
|
636
639
|
|
637
|
-
*
|
640
|
+
*Sean Griffin*
|
638
641
|
|
639
|
-
|
642
|
+
* Add new error class `StatementTimeout` which will be raised
|
643
|
+
when statement timeout exceeded.
|
640
644
|
|
641
|
-
*
|
645
|
+
*Ryuta Kamizono*
|
642
646
|
|
643
|
-
|
647
|
+
* Fix `bin/rails db:migrate` with specified `VERSION`.
|
648
|
+
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
649
|
+
Check a format of `VERSION`: Allow a migration version number
|
650
|
+
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
651
|
+
Raise error if target migration doesn't exist.
|
644
652
|
|
645
|
-
*
|
653
|
+
*bogdanvlviv*
|
646
654
|
|
647
|
-
|
655
|
+
* Fixed a bug where column orders for an index weren't written to
|
656
|
+
`db/schema.rb` when using the sqlite adapter.
|
648
657
|
|
649
|
-
|
658
|
+
Fixes #30902.
|
650
659
|
|
651
|
-
*
|
660
|
+
*Paul Kuruvilla*
|
652
661
|
|
653
|
-
* Remove deprecated
|
662
|
+
* Remove deprecated method `#sanitize_conditions`.
|
654
663
|
|
655
664
|
*Rafael Mendonça França*
|
656
665
|
|
657
|
-
*
|
658
|
-
order.
|
666
|
+
* Remove deprecated method `#scope_chain`.
|
659
667
|
|
660
668
|
*Rafael Mendonça França*
|
661
669
|
|
662
|
-
*
|
670
|
+
* Remove deprecated configuration `.error_on_ignored_order_or_limit`.
|
663
671
|
|
664
672
|
*Rafael Mendonça França*
|
665
673
|
|
666
|
-
*
|
674
|
+
* Remove deprecated arguments from `#verify!`.
|
667
675
|
|
668
676
|
*Rafael Mendonça França*
|
669
677
|
|
670
|
-
* Remove deprecated `
|
671
|
-
and `ActiveRecord::StatementInvalid#original_exception`.
|
678
|
+
* Remove deprecated argument `name` from `#indexes`.
|
672
679
|
|
673
680
|
*Rafael Mendonça França*
|
674
681
|
|
675
|
-
*
|
676
|
-
|
677
|
-
All the deprecations on those methods were removed.
|
682
|
+
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
|
678
683
|
|
679
684
|
*Rafael Mendonça França*
|
680
685
|
|
681
|
-
* Remove deprecated `
|
686
|
+
* Remove deprecated method `supports_primary_key?`.
|
682
687
|
|
683
688
|
*Rafael Mendonça França*
|
684
689
|
|
685
|
-
* Remove deprecated
|
690
|
+
* Remove deprecated method `supports_migrations?`.
|
686
691
|
|
687
692
|
*Rafael Mendonça França*
|
688
693
|
|
689
|
-
*
|
690
|
-
`config.active_record.time_zone_aware_types` is not explicitly set.
|
694
|
+
* Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
|
691
695
|
|
692
696
|
*Rafael Mendonça França*
|
693
697
|
|
694
|
-
*
|
698
|
+
* Raises when calling `lock!` in a dirty record.
|
695
699
|
|
696
700
|
*Rafael Mendonça França*
|
697
701
|
|
698
|
-
* Remove deprecated `
|
699
|
-
`activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes.
|
702
|
+
* Remove deprecated support to passing a class to `:class_name` on associations.
|
700
703
|
|
701
704
|
*Rafael Mendonça França*
|
702
705
|
|
703
|
-
*
|
704
|
-
|
705
|
-
Introduces `ActiveRecord::Tasks::DatabaseTasks.structure_(load|dump)_flags` to customize the
|
706
|
-
eventual commands run against the database, e.g. mysqldump/pg_dump.
|
706
|
+
* Remove deprecated argument `default` from `index_name_exists?`.
|
707
707
|
|
708
|
-
*
|
708
|
+
*Rafael Mendonça França*
|
709
709
|
|
710
|
-
*
|
710
|
+
* Remove deprecated support to `quoted_id` when typecasting an Active Record object.
|
711
711
|
|
712
|
-
|
712
|
+
*Rafael Mendonça França*
|
713
713
|
|
714
|
-
|
714
|
+
* Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
|
715
|
+
ar_internal_metadata's data for a test database.
|
715
716
|
|
716
|
-
|
717
|
+
Before:
|
718
|
+
```
|
719
|
+
$ RAILS_ENV=test rails dbconsole
|
720
|
+
> SELECT * FROM ar_internal_metadata;
|
721
|
+
key|value|created_at|updated_at
|
722
|
+
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
723
|
+
```
|
717
724
|
|
718
|
-
|
725
|
+
After:
|
726
|
+
```
|
727
|
+
$ RAILS_ENV=test rails dbconsole
|
728
|
+
> SELECT * FROM ar_internal_metadata;
|
729
|
+
key|value|created_at|updated_at
|
730
|
+
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
731
|
+
```
|
719
732
|
|
720
|
-
|
733
|
+
Fixes #26731.
|
721
734
|
|
722
|
-
*
|
735
|
+
*bogdanvlviv*
|
723
736
|
|
724
|
-
*
|
725
|
-
column names.
|
737
|
+
* Fix longer sequence name detection for serial columns.
|
726
738
|
|
727
|
-
Fixes #
|
739
|
+
Fixes #28332.
|
728
740
|
|
729
741
|
*Ryuta Kamizono*
|
730
742
|
|
731
|
-
*
|
732
|
-
|
733
|
-
*Ryuta Kamizono*
|
743
|
+
* MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
|
734
744
|
|
735
|
-
|
736
|
-
or updated because it would violate a not null constraint.
|
745
|
+
Fixes #30894.
|
737
746
|
|
738
747
|
*Ryuta Kamizono*
|
739
748
|
|
740
|
-
*
|
741
|
-
|
742
|
-
Race conditions can occur when an ActiveRecord is destroyed
|
743
|
-
twice or destroyed and updated. The callbacks should only be
|
744
|
-
triggered once, similar to a SQL database trigger.
|
745
|
-
|
746
|
-
*Stefan Budeanu*
|
747
|
-
|
748
|
-
* Moved `DecimalWithoutScale`, `Text`, and `UnsignedInteger` from Active Model to Active Record.
|
749
|
-
|
750
|
-
*Iain Beeston*
|
751
|
-
|
752
|
-
* Fix `write_attribute` method to check whether an attribute is aliased or not, and
|
753
|
-
use the aliased attribute name if needed.
|
754
|
-
|
755
|
-
*Prathamesh Sonpatki*
|
756
|
-
|
757
|
-
* Fix `read_attribute` method to check whether an attribute is aliased or not, and
|
758
|
-
use the aliased attribute name if needed.
|
759
|
-
|
760
|
-
Fixes #26417.
|
761
|
-
|
762
|
-
*Prathamesh Sonpatki*
|
763
|
-
|
764
|
-
* PostgreSQL & MySQL: Use big integer as primary key type for new tables.
|
765
|
-
|
766
|
-
*Jon McCartie*, *Pavel Pravosud*
|
767
|
-
|
768
|
-
* Change the type argument of `ActiveRecord::Base#attribute` to be optional.
|
769
|
-
The default is now `ActiveRecord::Type::Value.new`, which provides no type
|
770
|
-
casting behavior.
|
771
|
-
|
772
|
-
*Sean Griffin*
|
773
|
-
|
774
|
-
* Don't treat unsigned integers with zerofill as signed.
|
749
|
+
* Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
|
775
750
|
|
776
|
-
Fixes #
|
751
|
+
Fixes #30886.
|
777
752
|
|
778
753
|
*Ryuta Kamizono*
|
779
754
|
|
780
|
-
*
|
781
|
-
|
782
|
-
*Sergey Alekseev*
|
783
|
-
|
784
|
-
* Raise `ActiveRecord::RecordNotFound` from collection `*_ids` setters
|
785
|
-
for unknown IDs with a better error message.
|
755
|
+
* PostgreSQL `tsrange` now preserves subsecond precision.
|
786
756
|
|
787
|
-
|
788
|
-
|
789
|
-
|
757
|
+
PostgreSQL 9.1+ introduced range types, and Rails added support for using
|
758
|
+
this datatype in Active Record. However, the serialization of
|
759
|
+
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
760
|
+
cast the bounds that make up the range. This led to subseconds being
|
761
|
+
dropped in SQL commands:
|
790
762
|
|
791
|
-
|
792
|
-
|
793
|
-
* For PostgreSQL >= 9.4 use `pgcrypto`'s `gen_random_uuid()` instead of
|
794
|
-
`uuid-ossp`'s UUID generation function.
|
795
|
-
|
796
|
-
*Yuji Yaginuma*, *Yaw Boakye*
|
763
|
+
Before:
|
797
764
|
|
798
|
-
|
799
|
-
|
800
|
-
association.
|
765
|
+
connection.type_cast(tsrange.serialize(range_value))
|
766
|
+
# => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
|
801
767
|
|
802
|
-
|
803
|
-
in #20888. Unfortunately the suggested alternative of
|
804
|
-
`article.reload.category` does not expose the same behavior.
|
768
|
+
Now:
|
805
769
|
|
806
|
-
|
807
|
-
|
808
|
-
passing true to the association reader used to have.
|
770
|
+
connection.type_cast(tsrange.serialize(range_value))
|
771
|
+
# => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
|
809
772
|
|
810
|
-
*
|
773
|
+
*Thomas Cannon*
|
811
774
|
|
812
|
-
*
|
813
|
-
|
775
|
+
* Passing a `Set` to `Relation#where` now behaves the same as passing an
|
776
|
+
array.
|
814
777
|
|
815
|
-
*
|
778
|
+
*Sean Griffin*
|
816
779
|
|
817
|
-
*
|
818
|
-
values for Postgres HStore columns.
|
780
|
+
* Use given algorithm while removing index from database.
|
819
781
|
|
820
|
-
Fixes #
|
782
|
+
Fixes #24190.
|
821
783
|
|
822
|
-
*
|
784
|
+
*Mehmet Emin İNAÇ*
|
823
785
|
|
824
|
-
*
|
786
|
+
* Update payload names for `sql.active_record` instrumentation to be
|
787
|
+
more descriptive.
|
825
788
|
|
826
|
-
|
789
|
+
Fixes #30586.
|
827
790
|
|
828
|
-
|
829
|
-
{ size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
|
791
|
+
*Jeremy Green*
|
830
792
|
|
831
|
-
|
793
|
+
* Add new error class `LockWaitTimeout` which will be raised
|
794
|
+
when lock wait timeout exceeded.
|
832
795
|
|
833
|
-
*
|
834
|
-
and `exists?`.
|
796
|
+
*Gabriel Courtemanche*
|
835
797
|
|
836
|
-
|
837
|
-
for performance. We should not unscope the order in the case.
|
798
|
+
* Remove deprecated `#migration_keys`.
|
838
799
|
|
839
800
|
*Ryuta Kamizono*
|
840
801
|
|
841
|
-
*
|
842
|
-
datetime.
|
843
|
-
|
844
|
-
Fixes #24195.
|
845
|
-
|
846
|
-
*Sen Zhang*
|
847
|
-
|
848
|
-
* Allow `slice` to take an array of methods(without the need for splatting).
|
849
|
-
|
850
|
-
*Cohen Carlisle*
|
851
|
-
|
852
|
-
* Improved partial writes with HABTM and has many through associations
|
853
|
-
to fire database query only if relation has been changed.
|
854
|
-
|
855
|
-
Fixes #19663.
|
856
|
-
|
857
|
-
*Mehmet Emin İNAÇ*
|
858
|
-
|
859
|
-
* Deprecate passing arguments and block at the same time to
|
860
|
-
`ActiveRecord::QueryMethods#select`.
|
861
|
-
|
862
|
-
*Prathamesh Sonpatki*
|
802
|
+
* Automatically guess the inverse associations for STI.
|
863
803
|
|
864
|
-
*
|
804
|
+
*Yuichiro Kaneko*
|
865
805
|
|
866
|
-
|
806
|
+
* Ensure `sum` honors `distinct` on `has_many :through` associations.
|
867
807
|
|
868
|
-
|
808
|
+
Fixes #16791.
|
869
809
|
|
870
|
-
*
|
871
|
-
PostgreSQL.
|
810
|
+
*Aaron Wortham*
|
872
811
|
|
873
|
-
|
812
|
+
* Add `binary` fixture helper method.
|
874
813
|
|
875
|
-
*
|
814
|
+
*Atsushi Yoshida*
|
876
815
|
|
877
|
-
|
816
|
+
* When using `Relation#or`, extract the common conditions and put them before the OR condition.
|
878
817
|
|
879
|
-
*
|
880
|
-
to be updated is unchanged.
|
818
|
+
*Maxime Handfield Lapointe*
|
881
819
|
|
882
|
-
|
820
|
+
* `Relation#or` now accepts two relations who have different values for
|
821
|
+
`references` only, as `references` can be implicitly called by `where`.
|
883
822
|
|
884
|
-
|
823
|
+
Fixes #29411.
|
885
824
|
|
886
|
-
*
|
825
|
+
*Sean Griffin*
|
887
826
|
|
888
|
-
|
889
|
-
|
890
|
-
added using the `Errors#add` method. It was also inconsistent with the
|
891
|
-
`Errors#messages` storage.
|
827
|
+
* `ApplicationRecord` is no longer generated when generating models. If you
|
828
|
+
need to generate it, it can be created with `rails g application_record`.
|
892
829
|
|
893
|
-
|
894
|
-
cause a small breaking change because in those cases the details could
|
895
|
-
be accessed as strings keys but now it can not.
|
830
|
+
*Lisa Ugray*
|
896
831
|
|
897
|
-
|
832
|
+
* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
|
898
833
|
|
899
|
-
*
|
834
|
+
*Ryuta Kamizono*
|
900
835
|
|
901
|
-
*
|
902
|
-
|
836
|
+
* When a `has_one` association is destroyed by `dependent: destroy`,
|
837
|
+
`destroyed_by_association` will now be set to the reflection, matching the
|
838
|
+
behaviour of `has_many` associations.
|
903
839
|
|
904
|
-
|
840
|
+
*Lisa Ugray*
|
905
841
|
|
906
|
-
|
842
|
+
* Fix `unscoped(where: [columns])` removing the wrong bind values.
|
907
843
|
|
908
|
-
|
909
|
-
|
844
|
+
When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
|
845
|
+
bind values used by the `or` instead. (possibly other cases too)
|
910
846
|
|
911
|
-
|
847
|
+
```
|
848
|
+
Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
|
849
|
+
# Currently:
|
850
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
851
|
+
# With fix:
|
852
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
853
|
+
```
|
912
854
|
|
913
|
-
*
|
914
|
-
in the array.
|
855
|
+
*Maxime Handfield Lapointe*
|
915
856
|
|
916
|
-
|
857
|
+
* Values constructed using multi-parameter assignment will now use the
|
858
|
+
post-type-cast value for rendering in single-field form inputs.
|
917
859
|
|
918
860
|
*Sean Griffin*
|
919
861
|
|
920
|
-
*
|
921
|
-
`
|
862
|
+
* `Relation#joins` is no longer affected by the target model's
|
863
|
+
`current_scope`, with the exception of `unscoped`.
|
922
864
|
|
923
|
-
Fixes #
|
865
|
+
Fixes #29338.
|
924
866
|
|
925
867
|
*Sean Griffin*
|
926
868
|
|
927
|
-
*
|
928
|
-
loaded then the foreign key is changed directly and the record saved.
|
869
|
+
* Change sqlite3 boolean serialization to use 1 and 0.
|
929
870
|
|
930
|
-
|
871
|
+
SQLite natively recognizes 1 and 0 as true and false, but does not natively
|
872
|
+
recognize 't' and 'f' as was previously serialized.
|
931
873
|
|
932
|
-
|
874
|
+
This change in serialization requires a migration of stored boolean data
|
875
|
+
for SQLite databases, so it's implemented behind a configuration flag
|
876
|
+
whose default false value is deprecated.
|
933
877
|
|
934
|
-
*
|
935
|
-
|
936
|
-
* Avoid loading records from database when they are already loaded using
|
937
|
-
the `pluck` method on a collection.
|
938
|
-
|
939
|
-
Fixes #25921.
|
940
|
-
|
941
|
-
*Ryuta Kamizono*
|
878
|
+
*Lisa Ugray*
|
942
879
|
|
943
|
-
*
|
944
|
-
|
945
|
-
|
946
|
-
Strict mode controls how MySQL handles invalid or missing values in
|
947
|
-
data-change statements such as INSERT or UPDATE. If strict mode is not
|
948
|
-
in effect, MySQL inserts adjusted values for invalid or missing values
|
949
|
-
and produces warnings.
|
950
|
-
|
951
|
-
def test_mysql_not_null_defaults_non_strict
|
952
|
-
using_strict(false) do
|
953
|
-
with_mysql_not_null_table do |klass|
|
954
|
-
record = klass.new
|
955
|
-
assert_nil record.non_null_integer
|
956
|
-
assert_nil record.non_null_string
|
957
|
-
assert_nil record.non_null_text
|
958
|
-
assert_nil record.non_null_blob
|
959
|
-
|
960
|
-
record.save!
|
961
|
-
record.reload
|
962
|
-
|
963
|
-
assert_equal 0, record.non_null_integer
|
964
|
-
assert_equal "", record.non_null_string
|
965
|
-
assert_equal "", record.non_null_text
|
966
|
-
assert_equal "", record.non_null_blob
|
967
|
-
end
|
968
|
-
end
|
969
|
-
end
|
880
|
+
* Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
|
881
|
+
`in_batches`).
|
970
882
|
|
971
|
-
|
883
|
+
Previously, records would be fetched in batches, but all records would be retained in memory
|
884
|
+
until the end of the request or job.
|
972
885
|
|
973
|
-
*
|
886
|
+
*Eugene Kenny*
|
974
887
|
|
975
|
-
*
|
976
|
-
|
977
|
-
type.
|
888
|
+
* Prevent errors raised by `sql.active_record` notification subscribers from being converted into
|
889
|
+
`ActiveRecord::StatementInvalid` exceptions.
|
978
890
|
|
979
|
-
|
891
|
+
*Dennis Taylor*
|
980
892
|
|
981
|
-
|
893
|
+
* Fix eager loading/preloading association with scope including joins.
|
982
894
|
|
983
|
-
|
895
|
+
Fixes #28324.
|
984
896
|
|
985
897
|
*Ryuta Kamizono*
|
986
898
|
|
987
|
-
*
|
988
|
-
force a DISTINCT. This solves issues when using count after a left_joins.
|
899
|
+
* Fix transactions to apply state to child transactions.
|
989
900
|
|
990
|
-
|
991
|
-
|
992
|
-
* RecordNotFound raised by association.find exposes `id`, `primary_key` and
|
993
|
-
`model` methods to be consistent with RecordNotFound raised by Record.find.
|
901
|
+
Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
|
902
|
+
inner transaction would still be marked as persisted.
|
994
903
|
|
995
|
-
|
904
|
+
This change fixes that by applying the state of the parent transaction to the child transaction when the
|
905
|
+
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
996
906
|
|
997
|
-
*
|
998
|
-
mapping methods are methods implemented on `Hash`.
|
907
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
999
908
|
|
1000
|
-
|
909
|
+
* Deprecate `set_state` method in `TransactionState`.
|
1001
910
|
|
1002
|
-
|
911
|
+
Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
|
912
|
+
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
913
|
+
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
1003
914
|
|
1004
|
-
*
|
915
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1005
916
|
|
1006
|
-
|
917
|
+
* Deprecate delegating to `arel` in `Relation`.
|
1007
918
|
|
1008
|
-
*
|
1009
|
-
database.
|
919
|
+
*Ryuta Kamizono*
|
1010
920
|
|
1011
|
-
|
921
|
+
* Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
|
922
|
+
without being connected.
|
1012
923
|
|
1013
|
-
*
|
924
|
+
*Tsukasa Oishi*
|
1014
925
|
|
1015
|
-
|
926
|
+
* Previously, when building records using a `has_many :through` association,
|
927
|
+
if the child records were deleted before the parent was saved, they would
|
928
|
+
still be persisted. Now, if child records are deleted before the parent is saved
|
929
|
+
on a `has_many :through` association, the child records will not be persisted.
|
1016
930
|
|
1017
|
-
*
|
931
|
+
*Tobias Kraze*
|
1018
932
|
|
1019
|
-
|
933
|
+
* Merging two relations representing nested joins no longer transforms the joins of
|
934
|
+
the merged relation into LEFT OUTER JOIN.
|
1020
935
|
|
1021
|
-
|
936
|
+
Example:
|
1022
937
|
|
1023
|
-
|
1024
|
-
|
938
|
+
```
|
939
|
+
Author.joins(:posts).merge(Post.joins(:comments))
|
940
|
+
# Before the change:
|
941
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
|
1025
942
|
|
1026
|
-
|
943
|
+
# After the change:
|
944
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
|
945
|
+
```
|
1027
946
|
|
1028
|
-
*
|
947
|
+
*Maxime Handfield Lapointe*
|
1029
948
|
|
1030
|
-
*
|
1031
|
-
the
|
949
|
+
* `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
|
950
|
+
`locking_column`, without default value, is null in the database.
|
1032
951
|
|
1033
|
-
*
|
952
|
+
*bogdanvlviv*
|
1034
953
|
|
1035
|
-
*
|
954
|
+
* Fix destroying existing object does not work well when optimistic locking enabled and
|
955
|
+
`locking_column` is null in the database.
|
1036
956
|
|
1037
|
-
|
1038
|
-
# ...
|
1039
|
-
end
|
957
|
+
*bogdanvlviv*
|
1040
958
|
|
1041
|
-
|
959
|
+
* Use bulk INSERT to insert fixtures for better performance.
|
1042
960
|
|
1043
|
-
*
|
961
|
+
*Kir Shatrov*
|
1044
962
|
|
1045
|
-
*
|
1046
|
-
the hash keys after calling a calculation method like `count`.
|
963
|
+
* Prevent creation of bind param if casted value is nil.
|
1047
964
|
|
1048
|
-
|
965
|
+
*Ryuta Kamizono*
|
1049
966
|
|
1050
|
-
|
967
|
+
* Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.
|
1051
968
|
|
1052
|
-
*
|
1053
|
-
the resulting output is actually up to 20 characters, not
|
1054
|
-
effectively 17 to leave room for the default "...".
|
1055
|
-
Also call `#parameterize` before `#truncate` and make the
|
1056
|
-
`separator: /-/` to maximize the information included in the
|
1057
|
-
output.
|
969
|
+
*Ryuta Kamizono*
|
1058
970
|
|
1059
|
-
|
971
|
+
* Loading model schema from database is now thread-safe.
|
1060
972
|
|
1061
|
-
|
973
|
+
Fixes #28589.
|
1062
974
|
|
1063
|
-
*
|
1064
|
-
same connection to two threads.
|
975
|
+
*Vikrant Chaudhary*, *David Abdemoulaie*
|
1065
976
|
|
1066
|
-
|
977
|
+
* Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
|
978
|
+
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
979
|
+
that does not include a timestamp any more.
|
1067
980
|
|
1068
|
-
|
981
|
+
NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
|
982
|
+
until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
|
1069
983
|
|
1070
|
-
*
|
1071
|
-
truncates the array, preventing `inspect` from looping infinitely in some
|
1072
|
-
cases.
|
984
|
+
*DHH*
|
1073
985
|
|
1074
|
-
|
986
|
+
* Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump.
|
1075
987
|
|
1076
|
-
*
|
1077
|
-
`ActiveRecord::Base.connection_id=`.
|
988
|
+
*Rusty Geldmacher*, *Guillermo Iguaran*
|
1078
989
|
|
1079
|
-
|
990
|
+
* Add type caster to `RuntimeReflection#alias_name`.
|
1080
991
|
|
1081
|
-
|
992
|
+
Fixes #28959.
|
1082
993
|
|
1083
|
-
|
994
|
+
*Jon Moss*
|
1084
995
|
|
1085
|
-
|
996
|
+
* Deprecate `supports_statement_cache?`.
|
1086
997
|
|
1087
|
-
*
|
1088
|
-
was provided as a Hash.
|
998
|
+
*Ryuta Kamizono*
|
1089
999
|
|
1090
|
-
|
1000
|
+
* Raise error `UnknownMigrationVersionError` on the movement of migrations
|
1001
|
+
when the current migration does not exist.
|
1091
1002
|
|
1092
|
-
*
|
1093
|
-
adapter returns `''` instead of `nil`.
|
1003
|
+
*bogdanvlviv*
|
1094
1004
|
|
1095
|
-
|
1005
|
+
* Fix `bin/rails db:forward` first migration.
|
1096
1006
|
|
1097
|
-
*
|
1098
|
-
transaction serialization failures or deadlocks.
|
1007
|
+
*bogdanvlviv*
|
1099
1008
|
|
1100
|
-
|
1009
|
+
* Support Descending Indexes for MySQL.
|
1101
1010
|
|
1102
|
-
|
1011
|
+
MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
|
1012
|
+
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
1103
1013
|
|
1104
|
-
|
1105
|
-
when invoking `psql` to make sure errors are not suppressed.
|
1014
|
+
*Ryuta Kamizono*
|
1106
1015
|
|
1107
|
-
|
1016
|
+
* Fix inconsistency with changed attributes when overriding Active Record attribute reader.
|
1108
1017
|
|
1109
|
-
|
1018
|
+
*bogdanvlviv*
|
1110
1019
|
|
1111
|
-
|
1020
|
+
* When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
|
1021
|
+
Previously this method always returned an empty array.
|
1112
1022
|
|
1113
|
-
*
|
1023
|
+
*Kevin McPhillips*
|
1114
1024
|
|
1115
1025
|
|
1116
|
-
Please check [5-
|
1026
|
+
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
|