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