activerecord 3.2.22.5 → 5.2.8
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 +5 -5
- data/CHANGELOG.md +657 -621
- data/MIT-LICENSE +2 -2
- data/README.rdoc +41 -46
- data/examples/performance.rb +55 -42
- data/examples/simple.rb +6 -5
- data/lib/active_record/aggregations.rb +264 -236
- data/lib/active_record/association_relation.rb +40 -0
- data/lib/active_record/associations/alias_tracker.rb +47 -42
- data/lib/active_record/associations/association.rb +127 -75
- data/lib/active_record/associations/association_scope.rb +126 -92
- data/lib/active_record/associations/belongs_to_association.rb +78 -27
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +9 -4
- data/lib/active_record/associations/builder/association.rb +117 -32
- data/lib/active_record/associations/builder/belongs_to.rb +135 -60
- data/lib/active_record/associations/builder/collection_association.rb +61 -54
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +120 -42
- data/lib/active_record/associations/builder/has_many.rb +10 -64
- data/lib/active_record/associations/builder/has_one.rb +19 -51
- data/lib/active_record/associations/builder/singular_association.rb +28 -18
- data/lib/active_record/associations/collection_association.rb +226 -293
- data/lib/active_record/associations/collection_proxy.rb +1067 -69
- data/lib/active_record/associations/foreign_association.rb +13 -0
- data/lib/active_record/associations/has_many_association.rb +83 -47
- data/lib/active_record/associations/has_many_through_association.rb +98 -65
- data/lib/active_record/associations/has_one_association.rb +57 -20
- data/lib/active_record/associations/has_one_through_association.rb +18 -9
- data/lib/active_record/associations/join_dependency/join_association.rb +48 -126
- data/lib/active_record/associations/join_dependency/join_base.rb +11 -12
- data/lib/active_record/associations/join_dependency/join_part.rb +35 -42
- data/lib/active_record/associations/join_dependency.rb +212 -164
- data/lib/active_record/associations/preloader/association.rb +95 -89
- data/lib/active_record/associations/preloader/through_association.rb +84 -44
- data/lib/active_record/associations/preloader.rb +123 -111
- data/lib/active_record/associations/singular_association.rb +33 -24
- data/lib/active_record/associations/through_association.rb +60 -26
- data/lib/active_record/associations.rb +1759 -1506
- data/lib/active_record/attribute_assignment.rb +60 -193
- data/lib/active_record/attribute_decorators.rb +90 -0
- data/lib/active_record/attribute_methods/before_type_cast.rb +55 -8
- data/lib/active_record/attribute_methods/dirty.rb +113 -74
- data/lib/active_record/attribute_methods/primary_key.rb +106 -77
- data/lib/active_record/attribute_methods/query.rb +8 -5
- data/lib/active_record/attribute_methods/read.rb +63 -114
- data/lib/active_record/attribute_methods/serialization.rb +60 -90
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +69 -43
- data/lib/active_record/attribute_methods/write.rb +43 -45
- data/lib/active_record/attribute_methods.rb +366 -149
- data/lib/active_record/attributes.rb +266 -0
- data/lib/active_record/autosave_association.rb +312 -225
- data/lib/active_record/base.rb +114 -505
- data/lib/active_record/callbacks.rb +145 -67
- data/lib/active_record/coders/json.rb +15 -0
- data/lib/active_record/coders/yaml_column.rb +32 -23
- data/lib/active_record/collection_cache_key.rb +53 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +883 -284
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +16 -2
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +350 -200
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +82 -27
- data/lib/active_record/connection_adapters/abstract/quoting.rb +150 -65
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +23 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +146 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +477 -284
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +95 -0
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +1100 -310
- data/lib/active_record/connection_adapters/abstract/transaction.rb +283 -0
- data/lib/active_record/connection_adapters/abstract_adapter.rb +450 -118
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +657 -446
- data/lib/active_record/connection_adapters/column.rb +50 -255
- data/lib/active_record/connection_adapters/connection_specification.rb +287 -0
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +33 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +27 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +140 -0
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +72 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -0
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +73 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +87 -0
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +80 -0
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +148 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +35 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +59 -210
- data/lib/active_record/connection_adapters/postgresql/column.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +163 -0
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +92 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +56 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +17 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +50 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +21 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +71 -0
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +45 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +41 -0
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +65 -0
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +97 -0
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +18 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +111 -0
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +28 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +30 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +34 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +168 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +43 -0
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +65 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +206 -0
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +50 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +774 -0
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +39 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +81 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +620 -1080
- data/lib/active_record/connection_adapters/schema_cache.rb +85 -36
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +34 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +21 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +67 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +17 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +106 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +545 -27
- data/lib/active_record/connection_adapters/statement_pool.rb +34 -13
- data/lib/active_record/connection_handling.rb +145 -0
- data/lib/active_record/core.rb +559 -0
- data/lib/active_record/counter_cache.rb +200 -105
- data/lib/active_record/define_callbacks.rb +22 -0
- data/lib/active_record/dynamic_matchers.rb +107 -69
- data/lib/active_record/enum.rb +244 -0
- data/lib/active_record/errors.rb +245 -60
- data/lib/active_record/explain.rb +35 -71
- data/lib/active_record/explain_registry.rb +32 -0
- data/lib/active_record/explain_subscriber.rb +18 -9
- data/lib/active_record/fixture_set/file.rb +82 -0
- data/lib/active_record/fixtures.rb +418 -275
- data/lib/active_record/gem_version.rb +17 -0
- data/lib/active_record/inheritance.rb +209 -100
- data/lib/active_record/integration.rb +116 -21
- data/lib/active_record/internal_metadata.rb +45 -0
- data/lib/active_record/legacy_yaml_adapter.rb +48 -0
- data/lib/active_record/locale/en.yml +9 -1
- data/lib/active_record/locking/optimistic.rb +107 -94
- data/lib/active_record/locking/pessimistic.rb +20 -8
- data/lib/active_record/log_subscriber.rb +99 -34
- data/lib/active_record/migration/command_recorder.rb +199 -64
- data/lib/active_record/migration/compatibility.rb +217 -0
- data/lib/active_record/migration/join_table.rb +17 -0
- data/lib/active_record/migration.rb +893 -296
- data/lib/active_record/model_schema.rb +328 -175
- data/lib/active_record/nested_attributes.rb +338 -242
- data/lib/active_record/no_touching.rb +58 -0
- data/lib/active_record/null_relation.rb +68 -0
- data/lib/active_record/persistence.rb +557 -170
- data/lib/active_record/query_cache.rb +14 -43
- data/lib/active_record/querying.rb +36 -24
- data/lib/active_record/railtie.rb +147 -52
- data/lib/active_record/railties/console_sandbox.rb +5 -4
- data/lib/active_record/railties/controller_runtime.rb +13 -6
- data/lib/active_record/railties/databases.rake +206 -488
- data/lib/active_record/readonly_attributes.rb +4 -6
- data/lib/active_record/reflection.rb +734 -228
- data/lib/active_record/relation/batches/batch_enumerator.rb +69 -0
- data/lib/active_record/relation/batches.rb +249 -52
- data/lib/active_record/relation/calculations.rb +330 -284
- data/lib/active_record/relation/delegation.rb +135 -37
- data/lib/active_record/relation/finder_methods.rb +450 -287
- data/lib/active_record/relation/from_clause.rb +26 -0
- data/lib/active_record/relation/merger.rb +193 -0
- data/lib/active_record/relation/predicate_builder/array_handler.rb +48 -0
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +46 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +19 -0
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +20 -0
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +56 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +42 -0
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +19 -0
- data/lib/active_record/relation/predicate_builder.rb +132 -43
- data/lib/active_record/relation/query_attribute.rb +45 -0
- data/lib/active_record/relation/query_methods.rb +1037 -221
- data/lib/active_record/relation/record_fetch_warning.rb +51 -0
- data/lib/active_record/relation/spawn_methods.rb +48 -151
- data/lib/active_record/relation/where_clause.rb +186 -0
- data/lib/active_record/relation/where_clause_factory.rb +34 -0
- data/lib/active_record/relation.rb +451 -359
- data/lib/active_record/result.rb +129 -20
- data/lib/active_record/runtime_registry.rb +24 -0
- data/lib/active_record/sanitization.rb +164 -136
- data/lib/active_record/schema.rb +31 -19
- data/lib/active_record/schema_dumper.rb +154 -107
- data/lib/active_record/schema_migration.rb +56 -0
- data/lib/active_record/scoping/default.rb +108 -98
- data/lib/active_record/scoping/named.rb +125 -112
- data/lib/active_record/scoping.rb +77 -123
- data/lib/active_record/secure_token.rb +40 -0
- data/lib/active_record/serialization.rb +10 -6
- data/lib/active_record/statement_cache.rb +121 -0
- data/lib/active_record/store.rb +175 -16
- data/lib/active_record/suppressor.rb +61 -0
- data/lib/active_record/table_metadata.rb +82 -0
- data/lib/active_record/tasks/database_tasks.rb +337 -0
- data/lib/active_record/tasks/mysql_database_tasks.rb +115 -0
- data/lib/active_record/tasks/postgresql_database_tasks.rb +143 -0
- data/lib/active_record/tasks/sqlite_database_tasks.rb +83 -0
- data/lib/active_record/timestamp.rb +80 -41
- data/lib/active_record/touch_later.rb +64 -0
- data/lib/active_record/transactions.rb +240 -119
- data/lib/active_record/translation.rb +2 -0
- data/lib/active_record/type/adapter_specific_registry.rb +136 -0
- data/lib/active_record/type/date.rb +9 -0
- data/lib/active_record/type/date_time.rb +9 -0
- data/lib/active_record/type/decimal_without_scale.rb +15 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +25 -0
- data/lib/active_record/type/internal/timezone.rb +17 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +71 -0
- data/lib/active_record/type/text.rb +11 -0
- data/lib/active_record/type/time.rb +21 -0
- data/lib/active_record/type/type_map.rb +62 -0
- data/lib/active_record/type/unsigned_integer.rb +17 -0
- data/lib/active_record/type.rb +79 -0
- data/lib/active_record/type_caster/connection.rb +33 -0
- data/lib/active_record/type_caster/map.rb +23 -0
- data/lib/active_record/type_caster.rb +9 -0
- data/lib/active_record/validations/absence.rb +25 -0
- data/lib/active_record/validations/associated.rb +35 -18
- data/lib/active_record/validations/length.rb +26 -0
- data/lib/active_record/validations/presence.rb +68 -0
- data/lib/active_record/validations/uniqueness.rb +133 -75
- data/lib/active_record/validations.rb +53 -43
- data/lib/active_record/version.rb +7 -7
- data/lib/active_record.rb +89 -57
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +5 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +61 -8
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +24 -0
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +46 -0
- data/lib/rails/generators/active_record/migration.rb +28 -8
- data/lib/rails/generators/active_record/model/model_generator.rb +23 -22
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +13 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +1 -1
- data/lib/rails/generators/active_record.rb +10 -16
- metadata +141 -62
- data/examples/associations.png +0 -0
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +0 -63
- data/lib/active_record/associations/join_helper.rb +0 -55
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -24
- data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +0 -60
- data/lib/active_record/associations/preloader/has_many.rb +0 -17
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -15
- data/lib/active_record/associations/preloader/has_one.rb +0 -23
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -21
- data/lib/active_record/attribute_methods/deprecated_underscore_read.rb +0 -32
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +0 -191
- data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -441
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -583
- data/lib/active_record/dynamic_finder_match.rb +0 -68
- data/lib/active_record/dynamic_scope_match.rb +0 -23
- data/lib/active_record/fixtures/file.rb +0 -65
- data/lib/active_record/identity_map.rb +0 -162
- data/lib/active_record/observer.rb +0 -121
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/serializers/xml_serializer.rb +0 -203
- data/lib/active_record/session_store.rb +0 -360
- data/lib/active_record/test_case.rb +0 -73
- data/lib/rails/generators/active_record/migration/templates/migration.rb +0 -34
- data/lib/rails/generators/active_record/model/templates/migration.rb +0 -15
- data/lib/rails/generators/active_record/model/templates/model.rb +0 -12
- data/lib/rails/generators/active_record/observer/observer_generator.rb +0 -15
- data/lib/rails/generators/active_record/observer/templates/observer.rb +0 -4
- data/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +0 -25
- data/lib/rails/generators/active_record/session_migration/templates/migration.rb +0 -12
data/CHANGELOG.md
CHANGED
@@ -1,1020 +1,1056 @@
|
|
1
|
-
|
1
|
+
## Rails 5.2.8 (May 09, 2022) ##
|
2
2
|
|
3
|
-
|
3
|
+
* No changes.
|
4
4
|
|
5
|
-
*tlrdstd*
|
6
5
|
|
7
|
-
## Rails
|
6
|
+
## Rails 5.2.7.1 (April 26, 2022) ##
|
8
7
|
|
9
|
-
*
|
8
|
+
* No changes.
|
10
9
|
|
11
10
|
|
12
|
-
## Rails
|
11
|
+
## Rails 5.2.7 (March 10, 2022) ##
|
13
12
|
|
14
|
-
*
|
13
|
+
* No changes.
|
15
14
|
|
16
|
-
Fixes CVE-2014-3482.
|
17
15
|
|
18
|
-
|
16
|
+
## Rails 5.2.6.3 (March 08, 2022) ##
|
19
17
|
|
18
|
+
* No changes.
|
20
19
|
|
21
|
-
## Rails 3.2.18 (May 6, 2014) ##
|
22
20
|
|
23
|
-
|
21
|
+
## Rails 5.2.6.2 (February 11, 2022) ##
|
24
22
|
|
23
|
+
* No changes.
|
25
24
|
|
26
|
-
## Rails 3.2.17 (Feb 18, 2014) ##
|
27
25
|
|
28
|
-
|
26
|
+
## Rails 5.2.6.1 (February 11, 2022) ##
|
29
27
|
|
28
|
+
* No changes.
|
30
29
|
|
31
|
-
## Rails 3.2.16 (Dec 3, 2013) ##
|
32
30
|
|
33
|
-
|
31
|
+
## Rails 5.2.6 (May 05, 2021) ##
|
34
32
|
|
33
|
+
* No changes.
|
35
34
|
|
36
|
-
## Rails 3.2.15 (Oct 16, 2013) ##
|
37
35
|
|
38
|
-
|
39
|
-
it should set the inverse_of relation even when the entry was found on the db.
|
36
|
+
## Rails 5.2.5 (March 26, 2021) ##
|
40
37
|
|
41
|
-
|
38
|
+
* No changes.
|
42
39
|
|
43
|
-
* Callbacks on has_many should access the in memory parent if a inverse_of is set.
|
44
40
|
|
45
|
-
|
41
|
+
## Rails 5.2.4.6 (May 05, 2021) ##
|
46
42
|
|
47
|
-
*
|
43
|
+
* No changes.
|
48
44
|
|
49
|
-
Fixes #11917.
|
50
45
|
|
51
|
-
|
46
|
+
## Rails 5.2.4.5 (February 10, 2021) ##
|
52
47
|
|
53
|
-
*
|
48
|
+
* Fix possible DoS vector in PostgreSQL money type
|
54
49
|
|
55
|
-
|
50
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
51
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
52
|
+
fixes the regexp.
|
56
53
|
|
57
|
-
|
58
|
-
to allow the connection adapter to properly determine how to quote the value. This was
|
59
|
-
affecting certain databases that use specific colmn types.
|
54
|
+
Thanks to @dee-see from Hackerone for this patch!
|
60
55
|
|
61
|
-
|
56
|
+
[CVE-2021-22880]
|
62
57
|
|
63
|
-
*
|
58
|
+
*Aaron Patterson*
|
64
59
|
|
65
60
|
|
66
|
-
## Rails
|
61
|
+
## Rails 5.2.4.4 (September 09, 2020) ##
|
67
62
|
|
68
|
-
*
|
69
|
-
Backport of #7380.
|
63
|
+
* No changes.
|
70
64
|
|
71
|
-
*Karmes Alexander*
|
72
65
|
|
73
|
-
|
66
|
+
## Rails 5.2.4.3 (May 18, 2020) ##
|
74
67
|
|
75
|
-
|
68
|
+
* No changes.
|
76
69
|
|
77
|
-
|
70
|
+
## Rails 5.2.4.2 (March 19, 2020) ##
|
78
71
|
|
79
|
-
*
|
72
|
+
* No changes.
|
80
73
|
|
81
|
-
Fixes #11260.
|
82
74
|
|
83
|
-
|
75
|
+
## Rails 5.2.4.1 (December 18, 2019) ##
|
84
76
|
|
85
|
-
*
|
86
|
-
Fixes #10373.
|
77
|
+
* No changes.
|
87
78
|
|
88
|
-
*Janko Marohnić*
|
89
79
|
|
90
|
-
|
91
|
-
(ActiveRecord::Base.inheritance_column = 'some_column'.)
|
80
|
+
## Rails 5.2.4 (November 27, 2019) ##
|
92
81
|
|
93
|
-
|
82
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
94
83
|
|
95
|
-
|
96
|
-
|
84
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
85
|
+
associations, the callback for a `has_many` association was run while
|
86
|
+
another instance of the same callback on the same association hadn't
|
87
|
+
finished running. When control returned to the first instance of the
|
88
|
+
callback, the instance variable had changed, and subsequent associated
|
89
|
+
records weren't saved correctly. Specifically, the ID field for the
|
90
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
97
91
|
|
98
|
-
|
92
|
+
Fixes #28080.
|
99
93
|
|
100
|
-
*
|
101
|
-
all non-associated contracts.
|
94
|
+
*Larry Reid*
|
102
95
|
|
103
|
-
|
96
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
104
97
|
|
105
|
-
|
98
|
+
Fixes #36022.
|
106
99
|
|
107
|
-
|
108
|
-
company.contract_ids # => SELECT ... WHERE `contracts`.`company_id` IS NULL
|
100
|
+
*Ryuta Kamizono*
|
109
101
|
|
110
|
-
|
111
|
-
company.contract_ids # => []
|
102
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
112
103
|
|
113
|
-
*
|
104
|
+
*Martin R. Schuster*
|
114
105
|
|
115
|
-
*
|
116
|
-
Fixes #10693.
|
106
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
117
107
|
|
118
|
-
|
108
|
+
Fixes #36465.
|
119
109
|
|
120
|
-
*
|
121
|
-
deletions happen before inserts and saves. This prevents a 'duplicate
|
122
|
-
unique value' database error that would occur if a record being created had
|
123
|
-
the same value on a unique indexed field as that of a record being destroyed.
|
110
|
+
*Jeff Doering*
|
124
111
|
|
125
|
-
|
112
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
113
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
126
114
|
|
127
|
-
|
115
|
+
Fixes #33249.
|
128
116
|
|
129
|
-
*
|
130
|
-
"SELECT DISTINCT DISTINCT".
|
117
|
+
*Ryan H. Kerr*
|
131
118
|
|
132
|
-
Backport of #6792.
|
133
119
|
|
134
|
-
|
120
|
+
## Rails 5.2.3 (March 27, 2019) ##
|
135
121
|
|
136
|
-
*
|
137
|
-
avoid circular constant loading issues.
|
122
|
+
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
138
123
|
|
139
|
-
|
124
|
+
Fixes #35214.
|
140
125
|
|
141
|
-
|
126
|
+
*Juani Villarejo*
|
142
127
|
|
143
|
-
|
128
|
+
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
144
129
|
|
145
|
-
*
|
146
|
-
Backport #10164.
|
130
|
+
*Ryuta Kamizono*
|
147
131
|
|
148
|
-
|
132
|
+
* Don't allow `where` with invalid value matches to nil values.
|
149
133
|
|
150
|
-
|
134
|
+
Fixes #33624.
|
151
135
|
|
152
|
-
*
|
136
|
+
*Ryuta Kamizono*
|
153
137
|
|
154
|
-
*
|
155
|
-
has one. This caused a regression since it changed the behavior in a stable release.
|
138
|
+
* Restore an ability that class level `update` without giving ids.
|
156
139
|
|
157
|
-
Fixes #
|
140
|
+
Fixes #34743.
|
158
141
|
|
159
|
-
*
|
142
|
+
*Ryuta Kamizono*
|
160
143
|
|
161
|
-
*
|
144
|
+
* Fix join table column quoting with SQLite.
|
162
145
|
|
163
|
-
*
|
146
|
+
*Gannon McGibbon*
|
164
147
|
|
165
|
-
*
|
166
|
-
schema correctly.
|
167
|
-
Backport #10098.
|
148
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
168
149
|
|
169
|
-
*
|
150
|
+
*Ryuta Kamizono*
|
170
151
|
|
171
|
-
*
|
172
|
-
connection adapter doesn't support explain.
|
173
|
-
This is causing a regression since the Active Record Railtie is trying to
|
174
|
-
connect to the development database in the application boot.
|
152
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
175
153
|
|
176
|
-
*
|
154
|
+
*Gannon McGibbon*
|
177
155
|
|
178
|
-
* Do not reset `inheritance_column` when it's set explicitly.
|
179
|
-
Backport of #5327.
|
180
156
|
|
181
|
-
|
157
|
+
## Rails 5.2.2.1 (March 11, 2019) ##
|
182
158
|
|
183
|
-
*
|
184
|
-
when raising no translatable exception in PostgreSQL.
|
159
|
+
* No changes.
|
185
160
|
|
186
|
-
*kennyj*
|
187
161
|
|
188
|
-
|
189
|
-
is dumped in order to find schema_migrations table when multiples schemas
|
190
|
-
are used.
|
191
|
-
Fixes #9796.
|
162
|
+
## Rails 5.2.2 (December 04, 2018) ##
|
192
163
|
|
193
|
-
|
164
|
+
* Do not ignore the scoping with query methods in the scope block.
|
194
165
|
|
195
|
-
*
|
196
|
-
when a model isn't saved.
|
197
|
-
Fixes #7526.
|
166
|
+
*Ryuta Kamizono*
|
198
167
|
|
199
|
-
|
168
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
200
169
|
|
201
|
-
*
|
202
|
-
fixtures was removed some time ago but the task was still loading them, even
|
203
|
-
though later the code was looking for the related yaml file instead.
|
170
|
+
*Gannon McGibbon*
|
204
171
|
|
205
|
-
|
172
|
+
* Allow spaces in postgres table names.
|
206
173
|
|
174
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
|
175
|
+
adapter.
|
207
176
|
|
208
|
-
|
177
|
+
*Gannon McGibbon*
|
209
178
|
|
210
|
-
*
|
211
|
-
at the same time.
|
179
|
+
* Cached columns_hash fields should be excluded from ResultSet#column_types
|
212
180
|
|
213
|
-
|
181
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
182
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
214
183
|
|
215
|
-
|
216
|
-
|
184
|
+
```ruby
|
185
|
+
class DeveloperName < ActiveRecord::Type::String
|
186
|
+
def deserialize(value)
|
187
|
+
"Developer: #{value}"
|
188
|
+
end
|
189
|
+
end
|
217
190
|
|
218
|
-
|
191
|
+
class AttributedDeveloper < ActiveRecord::Base
|
192
|
+
self.table_name = "developers"
|
219
193
|
|
220
|
-
|
194
|
+
attribute :name, DeveloperName.new
|
221
195
|
|
222
|
-
|
196
|
+
self.ignored_columns += ["name"]
|
197
|
+
end
|
223
198
|
|
224
|
-
|
225
|
-
|
226
|
-
Backport #7072.
|
199
|
+
developer = AttributedDeveloper.create
|
200
|
+
developer.update_column :name, "name"
|
227
201
|
|
228
|
-
|
202
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
203
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
204
|
+
```
|
229
205
|
|
230
|
-
*
|
231
|
-
Fixes #9367.
|
232
|
-
Backport #2312.
|
206
|
+
*Dmitry Tsepelev*
|
233
207
|
|
234
|
-
|
208
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
235
209
|
|
236
|
-
*
|
237
|
-
cache the `:through` association. This will prevent invalid
|
238
|
-
subsets to be cached.
|
239
|
-
Fixes #8423.
|
240
|
-
Backport #9252.
|
210
|
+
*Emmanuel Byrd*
|
241
211
|
|
242
|
-
|
212
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
213
|
+
if the attribute does not exist.
|
243
214
|
|
244
|
-
|
245
|
-
has_many :posts
|
246
|
-
has_many :recent_comments, -> { where('created_at > ?', 1.week.ago) }, :through => :posts
|
247
|
-
end
|
215
|
+
*Sean Griffin*
|
248
216
|
|
249
|
-
|
217
|
+
* Do not use prepared statement in queries that have a large number of binds.
|
250
218
|
|
251
|
-
|
252
|
-
a_user.recent_comments
|
219
|
+
*Ryuta Kamizono*
|
253
220
|
|
254
|
-
|
255
|
-
a_user.posts
|
221
|
+
* Fix query cache to load before first request.
|
256
222
|
|
257
|
-
*
|
223
|
+
*Eileen M. Uchitelle*
|
258
224
|
|
259
|
-
* Fix
|
225
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
260
226
|
|
261
|
-
|
262
|
-
changing a datetime or timestamp attribute and then changing it back
|
263
|
-
to the original value, `changed_attributes` still tracked the
|
264
|
-
attribute as changed. This caused `[attribute]_changed?` and
|
265
|
-
`changed?` methods to return true incorrectly.
|
227
|
+
Fixes #33056.
|
266
228
|
|
267
|
-
|
229
|
+
*Federico Martinez*
|
268
230
|
|
269
|
-
|
270
|
-
order = Order.new
|
271
|
-
original_time = Time.local(2012, 10, 10)
|
272
|
-
order.shipped_at = original_time
|
273
|
-
order.save
|
274
|
-
order.changed? # => false
|
231
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
275
232
|
|
276
|
-
|
277
|
-
order.shipped_at = Time.local(2013, 1, 1)
|
278
|
-
order.changed? # => true
|
233
|
+
*Darwin Wu*
|
279
234
|
|
280
|
-
|
281
|
-
order.shipped_at = original_time
|
282
|
-
order.changed? # => false, used to return true
|
283
|
-
end
|
235
|
+
* Fix regression setting children record in parent `before_save` callback.
|
284
236
|
|
285
|
-
|
286
|
-
Fixes #8898
|
237
|
+
*Guo Xiang Tan*
|
287
238
|
|
288
|
-
|
239
|
+
* Prevent leaking of user's DB credentials on `rails db:create` failure.
|
289
240
|
|
290
|
-
*
|
291
|
-
associations.
|
292
|
-
Backport #8400.
|
293
|
-
Fix #7630.
|
241
|
+
*bogdanvlviv*
|
294
242
|
|
295
|
-
|
243
|
+
* Clear mutation tracker before continuing the around callbacks.
|
296
244
|
|
297
|
-
*
|
298
|
-
Backport c517602.
|
299
|
-
Fix #6115.
|
245
|
+
*Yuya Tanaka*
|
300
246
|
|
301
|
-
|
247
|
+
* Prevent deadlocks when waiting for connection from pool.
|
302
248
|
|
303
|
-
*
|
304
|
-
Fix #6865.
|
249
|
+
*Brent Wheeldon*
|
305
250
|
|
306
|
-
|
251
|
+
* Avoid extra scoping when using `Relation#update` that was causing this method to change the current scope.
|
307
252
|
|
308
|
-
|
253
|
+
*Ryuta Kamizono*
|
309
254
|
|
310
|
-
|
255
|
+
* Fix numericality validator not to be affected by custom getter.
|
311
256
|
|
312
|
-
*
|
313
|
-
Backport #7536.
|
314
|
-
Fix #8968.
|
257
|
+
*Ryuta Kamizono*
|
315
258
|
|
316
|
-
|
259
|
+
* Fix bulk change table ignores comment option on PostgreSQL.
|
317
260
|
|
318
|
-
*
|
319
|
-
Backport #6197.
|
261
|
+
*Yoshiyuki Kinjo*
|
320
262
|
|
321
|
-
*Blake Smith*
|
322
263
|
|
323
|
-
|
324
|
-
Fixes #8460.
|
264
|
+
## Rails 5.2.1.1 (November 27, 2018) ##
|
325
265
|
|
326
|
-
|
266
|
+
* No changes.
|
327
267
|
|
328
|
-
* Revert creation of through association models when using `collection=[]`
|
329
|
-
on a `has_many :through` association from an unsaved model.
|
330
|
-
Fix #7661, #8269.
|
331
268
|
|
332
|
-
|
269
|
+
## Rails 5.2.1 (August 07, 2018) ##
|
333
270
|
|
334
|
-
*
|
335
|
-
Array; Fix FloatDomainError when setting integer column to NaN.
|
336
|
-
Fixes #8718, #8734, #8757.
|
271
|
+
* PostgreSQL: Support new relkind for partitioned tables.
|
337
272
|
|
338
|
-
|
273
|
+
Fixes #33008.
|
339
274
|
|
340
|
-
*
|
341
|
-
Fix #8575.
|
275
|
+
*Yannick Schutz*
|
342
276
|
|
343
|
-
|
277
|
+
* Rollback parent transaction when children fails to update.
|
344
278
|
|
345
|
-
*
|
346
|
-
Fix #3489.
|
347
|
-
Backport #8522.
|
279
|
+
*Guillaume Malette*
|
348
280
|
|
349
|
-
|
281
|
+
* Fix default value for MySQL time types with specified precision.
|
350
282
|
|
351
|
-
*
|
352
|
-
Fix #8492.
|
353
|
-
Backport of #8500.
|
283
|
+
*Nikolay Kondratyev*
|
354
284
|
|
355
|
-
|
285
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
356
286
|
|
357
|
-
*
|
358
|
-
the format of the timestamp value in the cache key.
|
359
|
-
This allows users to improve the precision of the cache key.
|
360
|
-
Fixes #8195.
|
287
|
+
*Ryuta Kamizono*
|
361
288
|
|
362
|
-
|
289
|
+
* Fix `save` in `after_create_commit` won't invoke extra `after_create_commit`.
|
290
|
+
|
291
|
+
Fixes #32831.
|
363
292
|
|
364
|
-
*
|
365
|
-
Please note that this format only works with Ruby 1.9, Ruby 1.8 will ignore it completely.
|
293
|
+
*Ryuta Kamizono*
|
366
294
|
|
367
|
-
|
295
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
368
296
|
|
369
|
-
*
|
297
|
+
*Brian Durand*
|
370
298
|
|
371
|
-
|
372
|
-
`update_column(s)` could generate a query that would not properly update
|
373
|
-
the record due to the where clause from the `default_scope` being applied
|
374
|
-
to the update query.
|
299
|
+
* Fix parent record should not get saved with duplicate children records.
|
375
300
|
|
376
|
-
|
377
|
-
default_scope where(active: true)
|
378
|
-
end
|
301
|
+
Fixes #32940.
|
379
302
|
|
380
|
-
|
381
|
-
user.active = false
|
382
|
-
user.save!
|
303
|
+
*Santosh Wadghule*
|
383
304
|
|
384
|
-
|
305
|
+
* Fix that association's after_touch is not called with counter cache.
|
385
306
|
|
386
|
-
|
387
|
-
update the record based on the primary key. With this change:
|
307
|
+
Fixes #31559.
|
388
308
|
|
389
|
-
|
309
|
+
*Ryuta Kamizono*
|
390
310
|
|
391
|
-
|
311
|
+
* `becomes` should clear the mutation tracker which is created in `after_initialize`.
|
392
312
|
|
393
|
-
|
313
|
+
Fixes #32867.
|
394
314
|
|
395
|
-
*
|
396
|
-
Uses pg_constraint table instead of pg_depend table which has many records in general.
|
397
|
-
Fix #8414
|
315
|
+
*Ryuta Kamizono*
|
398
316
|
|
399
|
-
|
317
|
+
* Allow a belonging to parent object to be created from a new record.
|
400
318
|
|
401
|
-
*
|
402
|
-
These records caused `after_find` to run more than expected.
|
403
|
-
Fix #3313
|
404
|
-
Backport of #8403
|
319
|
+
*Jolyon Pawlyn*
|
405
320
|
|
406
|
-
|
321
|
+
* Fix that building record with assigning multiple has_one associations
|
322
|
+
wrongly persists through record.
|
407
323
|
|
408
|
-
|
324
|
+
Fixes #32511.
|
409
325
|
|
410
|
-
*
|
326
|
+
*Sam DeCesare*
|
411
327
|
|
412
|
-
* Fix
|
413
|
-
|
328
|
+
* Fix relation merging when one of the relations is going to skip the
|
329
|
+
query cache.
|
414
330
|
|
415
|
-
*
|
331
|
+
*James Williams*
|
416
332
|
|
417
|
-
* Fix dirty attribute checks for TimeZoneConversion with nil and blank
|
418
|
-
datetime attributes. Setting a nil datetime to a blank string should not
|
419
|
-
result in a change being flagged.
|
420
|
-
Fixes #8310.
|
421
|
-
Backport of #8311.
|
422
333
|
|
423
|
-
|
334
|
+
## Rails 5.2.0 (April 09, 2018) ##
|
424
335
|
|
425
|
-
*
|
426
|
-
Fixes #8265.
|
427
|
-
Backport of #8291.
|
336
|
+
* MySQL: Support mysql2 0.5.x.
|
428
337
|
|
429
|
-
*
|
338
|
+
*Aaron Stone*
|
430
339
|
|
431
|
-
*
|
432
|
-
silently dropped.
|
433
|
-
Previously, these migrations caused sql exceptions, because Postgresql doesn't support limits
|
434
|
-
on these types.
|
340
|
+
* Apply time column precision on assignment.
|
435
341
|
|
436
|
-
|
342
|
+
PR #20317 changed the behavior of datetime columns so that when they
|
343
|
+
have a specified precision then on assignment the value is rounded to
|
344
|
+
that precision. This behavior is now applied to time columns as well.
|
437
345
|
|
438
|
-
|
439
|
-
Fixes #7551.
|
440
|
-
Backport of #8176.
|
346
|
+
Fixes #30301.
|
441
347
|
|
442
|
-
|
348
|
+
*Andrew White*
|
443
349
|
|
444
|
-
|
350
|
+
* Normalize time column values for SQLite database.
|
445
351
|
|
446
|
-
|
352
|
+
For legacy reasons, time columns in SQLite are stored as full datetimes
|
353
|
+
because until #24542 the quoting for time columns didn't remove the date
|
354
|
+
component. To ensure that values are consistent we now normalize the
|
355
|
+
date component to 2001-01-01 on reading and writing.
|
447
356
|
|
448
|
-
*
|
449
|
-
should raise RecordNotFound.
|
450
|
-
Fixes #7238.
|
357
|
+
*Andrew White*
|
451
358
|
|
452
|
-
|
359
|
+
* Ensure that the date component is removed when quoting times.
|
453
360
|
|
454
|
-
|
455
|
-
|
456
|
-
|
361
|
+
PR #24542 altered the quoting for time columns so that the date component
|
362
|
+
was removed however it only removed it when it was 2001-01-01. Now the
|
363
|
+
date component is removed irrespective of what the date is.
|
457
364
|
|
458
|
-
*
|
365
|
+
*Andrew White*
|
459
366
|
|
460
|
-
*
|
461
|
-
|
462
|
-
Backport of #8074.
|
367
|
+
* Fix `dependent: :destroy` issue for has_one/belongs_to relationship where
|
368
|
+
the parent class was getting deleted when the child was not.
|
463
369
|
|
464
|
-
|
370
|
+
Fixes #32022.
|
465
371
|
|
466
|
-
*
|
372
|
+
*Fernando Gorodscy*
|
467
373
|
|
468
|
-
|
374
|
+
* Whitelist `NULLS FIRST` and `NULLS LAST` in order clauses too.
|
469
375
|
|
470
|
-
|
471
|
-
User.new.build_profile
|
376
|
+
*Xavier Noria*
|
472
377
|
|
473
|
-
|
378
|
+
* Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
|
474
379
|
|
475
|
-
*
|
380
|
+
*Ryuta Kamizono*
|
476
381
|
|
477
|
-
* `
|
382
|
+
* Fix `#columns_for_distinct` of MySQL and PostgreSQL to make
|
383
|
+
`ActiveRecord::FinderMethods#limited_ids_for` use correct primary key values
|
384
|
+
even if `ORDER BY` columns include other table's primary key.
|
478
385
|
|
479
|
-
|
386
|
+
Fixes #28364.
|
480
387
|
|
481
|
-
*
|
388
|
+
*Takumi Kagiyama*
|
482
389
|
|
483
|
-
|
390
|
+
* Make `reflection.klass` raise if `polymorphic?` not to be misused.
|
391
|
+
|
392
|
+
Fixes #31876.
|
393
|
+
|
394
|
+
*Ryuta Kamizono*
|
395
|
+
|
396
|
+
* PostgreSQL: Allow pg-1.0 gem to be used with Active Record.
|
397
|
+
|
398
|
+
*Lars Kanis*
|
399
|
+
|
400
|
+
* Deprecate `expand_hash_conditions_for_aggregates` without replacement.
|
401
|
+
Using a `Relation` for performing queries is the prefered API.
|
402
|
+
|
403
|
+
*Ryuta Kamizono*
|
404
|
+
|
405
|
+
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
|
406
|
+
|
407
|
+
```
|
408
|
+
david_balance = customers(:david).balance
|
409
|
+
Customer.where(balance: [david_balance]).to_sql
|
410
|
+
|
411
|
+
# Before: WHERE `customers`.`balance` = NULL
|
412
|
+
# After : WHERE `customers`.`balance` = 50
|
413
|
+
```
|
414
|
+
|
415
|
+
Fixes #31723.
|
416
|
+
|
417
|
+
*Yutaro Kanagawa*
|
418
|
+
|
419
|
+
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
420
|
+
|
421
|
+
Fixes #31783.
|
422
|
+
|
423
|
+
*Ryuta Kamizono*
|
424
|
+
|
425
|
+
* Clear the transaction state when an Active Record object is duped.
|
426
|
+
|
427
|
+
Fixes #31670.
|
428
|
+
|
429
|
+
*Yuriy Ustushenko*
|
430
|
+
|
431
|
+
* Support for PostgreSQL foreign tables.
|
432
|
+
|
433
|
+
*fatkodima*
|
434
|
+
|
435
|
+
* Fix relation merger issue with `left_outer_joins`.
|
484
436
|
|
485
|
-
|
486
|
-
has_one :address
|
437
|
+
*Mehmet Emin İNAÇ*
|
487
438
|
|
488
|
-
|
439
|
+
* Don't allow destroyed object mutation after `save` or `save!` is called.
|
440
|
+
|
441
|
+
*Ryuta Kamizono*
|
442
|
+
|
443
|
+
* Take into account association conditions when deleting through records.
|
444
|
+
|
445
|
+
Fixes #18424.
|
446
|
+
|
447
|
+
*Piotr Jakubowski*
|
448
|
+
|
449
|
+
* Fix nested `has_many :through` associations on unpersisted parent instances.
|
450
|
+
|
451
|
+
For example, if you have
|
452
|
+
|
453
|
+
class Post < ActiveRecord::Base
|
454
|
+
belongs_to :author
|
455
|
+
has_many :books, through: :author
|
456
|
+
has_many :subscriptions, through: :books
|
489
457
|
end
|
490
458
|
|
491
|
-
class
|
492
|
-
|
459
|
+
class Author < ActiveRecord::Base
|
460
|
+
has_one :post
|
461
|
+
has_many :books
|
462
|
+
has_many :subscriptions, through: :books
|
493
463
|
end
|
494
464
|
|
495
|
-
|
496
|
-
|
465
|
+
class Book < ActiveRecord::Base
|
466
|
+
belongs_to :author
|
467
|
+
has_many :subscriptions
|
468
|
+
end
|
469
|
+
|
470
|
+
class Subscription < ActiveRecord::Base
|
471
|
+
belongs_to :book
|
472
|
+
end
|
473
|
+
|
474
|
+
Before:
|
475
|
+
|
476
|
+
If `post` is not persisted, then `post.subscriptions` will be empty.
|
497
477
|
|
498
478
|
After:
|
499
479
|
|
500
|
-
|
501
|
-
|
480
|
+
If `post` is not persisted, then `post.subscriptions` can be set and used
|
481
|
+
just like it would if `post` were persisted.
|
502
482
|
|
503
|
-
Fixes #
|
483
|
+
Fixes #16313.
|
504
484
|
|
505
|
-
*
|
485
|
+
*Zoltan Kiss*
|
506
486
|
|
487
|
+
* Fixed inconsistency with `first(n)` when used with `limit()`.
|
488
|
+
The `first(n)` finder now respects the `limit()`, making it consistent
|
489
|
+
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
507
490
|
|
508
|
-
|
491
|
+
Fixes #23979.
|
509
492
|
|
510
|
-
*
|
511
|
-
in some database, the string column values will be coerced to a numeric
|
512
|
-
allowing 0, 0.0 or false to match any string starting with a non-digit.
|
493
|
+
*Brian Christian*
|
513
494
|
|
514
|
-
|
495
|
+
* Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
|
496
|
+
SQL queries for association counting.
|
515
497
|
|
516
|
-
|
498
|
+
*Klas Eskilson*
|
517
499
|
|
518
|
-
|
500
|
+
* Fix to invoke callbacks when using `update_attribute`.
|
519
501
|
|
502
|
+
*Mike Busch*
|
520
503
|
|
521
|
-
|
504
|
+
* Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
|
522
505
|
|
523
|
-
*
|
506
|
+
*Ryuta Kamizono*
|
524
507
|
|
508
|
+
* Using subselect for `delete_all` with `limit` or `offset`.
|
525
509
|
|
526
|
-
|
510
|
+
*Ryuta Kamizono*
|
527
511
|
|
528
|
-
*
|
529
|
-
|
512
|
+
* Undefine attribute methods on descendants when resetting column
|
513
|
+
information.
|
530
514
|
|
515
|
+
*Chris Salzberg*
|
531
516
|
|
532
|
-
|
517
|
+
* Log database query callers.
|
533
518
|
|
534
|
-
|
519
|
+
Add `verbose_query_logs` configuration option to display the caller
|
520
|
+
of database queries in the log to facilitate N+1 query resolution
|
521
|
+
and other debugging.
|
535
522
|
|
536
|
-
|
523
|
+
Enabled in development only for new and upgraded applications. Not
|
524
|
+
recommended for use in the production environment since it relies
|
525
|
+
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
537
526
|
|
538
|
-
*
|
539
|
-
to set the inverse association when `:inverse_of` was used. Fixes #8087.
|
527
|
+
*Olivier Lacan*
|
540
528
|
|
541
|
-
|
529
|
+
* Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
|
542
530
|
|
543
|
-
|
544
|
-
|
531
|
+
```
|
532
|
+
# create_table :posts do |t|
|
533
|
+
# t.integer :comments_count, default: 0
|
534
|
+
# t.integer :lock_version
|
535
|
+
# t.timestamps
|
536
|
+
# end
|
537
|
+
class Post < ApplicationRecord
|
538
|
+
end
|
545
539
|
|
546
|
-
|
540
|
+
# create_table :comments do |t|
|
541
|
+
# t.belongs_to :post
|
542
|
+
# end
|
543
|
+
class Comment < ApplicationRecord
|
544
|
+
belongs_to :post, touch: true, counter_cache: true
|
545
|
+
end
|
546
|
+
```
|
547
547
|
|
548
|
-
|
549
|
-
|
548
|
+
Before:
|
549
|
+
```
|
550
|
+
post = Post.create!
|
551
|
+
# => begin transaction
|
552
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
553
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
554
|
+
commit transaction
|
555
|
+
|
556
|
+
comment = Comment.create!(post: post)
|
557
|
+
# => begin transaction
|
558
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
559
|
+
|
560
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
561
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
562
|
+
|
563
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
564
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
565
|
+
rollback transaction
|
566
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
567
|
+
|
568
|
+
Comment.take.destroy!
|
569
|
+
# => begin transaction
|
570
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
571
|
+
|
572
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
573
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
574
|
+
|
575
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
576
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
577
|
+
rollback transaction
|
578
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
579
|
+
```
|
550
580
|
|
551
|
-
|
581
|
+
After:
|
582
|
+
```
|
583
|
+
post = Post.create!
|
584
|
+
# => begin transaction
|
585
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
586
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
587
|
+
commit transaction
|
552
588
|
|
553
|
-
|
589
|
+
comment = Comment.create!(post: post)
|
590
|
+
# => begin transaction
|
591
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
554
592
|
|
555
|
-
|
593
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
594
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
595
|
+
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
596
|
+
commit transaction
|
556
597
|
|
557
|
-
|
598
|
+
comment.destroy!
|
599
|
+
# => begin transaction
|
600
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
558
601
|
|
559
|
-
|
602
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
603
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
604
|
+
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
605
|
+
commit transaction
|
606
|
+
```
|
560
607
|
|
561
|
-
|
608
|
+
Fixes #31199.
|
562
609
|
|
563
|
-
*
|
564
|
-
and the dup'ed object shared the same errors.
|
610
|
+
*bogdanvlviv*
|
565
611
|
|
566
|
-
|
612
|
+
* Add support for PostgreSQL operator classes to `add_index`.
|
567
613
|
|
568
|
-
|
569
|
-
Fixes #7955
|
614
|
+
Example:
|
570
615
|
|
571
|
-
|
572
|
-
multiple schemas and domains in a db. Fixes #7914
|
616
|
+
add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
|
573
617
|
|
574
|
-
*
|
618
|
+
*Greg Navis*
|
575
619
|
|
576
|
-
*
|
577
|
-
selects columns from other tables, if a new record was previously
|
578
|
-
built using that association.
|
620
|
+
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
579
621
|
|
580
|
-
|
622
|
+
Fixes #31120.
|
581
623
|
|
582
|
-
*
|
583
|
-
Fix #5920
|
624
|
+
*kinnrot*
|
584
625
|
|
585
|
-
|
626
|
+
* Add new error class `QueryCanceled` which will be raised
|
627
|
+
when canceling statement due to user request.
|
586
628
|
|
587
|
-
*
|
588
|
-
parent record is not persisted.
|
629
|
+
*Ryuta Kamizono*
|
589
630
|
|
590
|
-
|
631
|
+
* Add `#up_only` to database migrations for code that is only relevant when
|
632
|
+
migrating up, e.g. populating a new column.
|
591
633
|
|
592
|
-
|
593
|
-
|
594
|
-
|
634
|
+
*Rich Daley*
|
635
|
+
|
636
|
+
* Require raw SQL fragments to be explicitly marked when used in
|
637
|
+
relation query methods.
|
638
|
+
|
639
|
+
Before:
|
640
|
+
```
|
641
|
+
Article.order("LENGTH(title)")
|
642
|
+
```
|
595
643
|
|
596
644
|
After:
|
645
|
+
```
|
646
|
+
Article.order(Arel.sql("LENGTH(title)"))
|
647
|
+
```
|
597
648
|
|
598
|
-
|
599
|
-
|
600
|
-
|
649
|
+
This prevents SQL injection if applications use the [strongly
|
650
|
+
discouraged] form `Article.order(params[:my_order])`, under the
|
651
|
+
mistaken belief that only column names will be accepted.
|
601
652
|
|
602
|
-
|
653
|
+
Raw SQL strings will now cause a deprecation warning, which will
|
654
|
+
become an UnknownAttributeReference error in Rails 6.0. Applications
|
655
|
+
can opt in to the future behavior by setting `allow_unsafe_raw_sql`
|
656
|
+
to `:disabled`.
|
603
657
|
|
604
|
-
|
605
|
-
|
658
|
+
Common and judged-safe string values (such as simple column
|
659
|
+
references) are unaffected:
|
660
|
+
```
|
661
|
+
Article.order("title DESC")
|
662
|
+
```
|
606
663
|
|
607
|
-
*
|
664
|
+
*Ben Toews*
|
608
665
|
|
609
|
-
*
|
610
|
-
|
611
|
-
|
666
|
+
* `update_all` will now pass its values to `Type#cast` before passing them to
|
667
|
+
`Type#serialize`. This means that `update_all(foo: 'true')` will properly
|
668
|
+
persist a boolean.
|
612
669
|
|
613
|
-
*
|
670
|
+
*Sean Griffin*
|
614
671
|
|
615
|
-
*
|
672
|
+
* Add new error class `StatementTimeout` which will be raised
|
673
|
+
when statement timeout exceeded.
|
616
674
|
|
617
|
-
*
|
675
|
+
*Ryuta Kamizono*
|
618
676
|
|
619
|
-
* Fix
|
620
|
-
|
621
|
-
|
677
|
+
* Fix `bin/rails db:migrate` with specified `VERSION`.
|
678
|
+
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
679
|
+
Check a format of `VERSION`: Allow a migration version number
|
680
|
+
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
681
|
+
Raise error if target migration doesn't exist.
|
622
682
|
|
623
|
-
*
|
683
|
+
*bogdanvlviv*
|
624
684
|
|
625
|
-
*
|
626
|
-
|
685
|
+
* Fixed a bug where column orders for an index weren't written to
|
686
|
+
`db/schema.rb` when using the sqlite adapter.
|
627
687
|
|
628
|
-
|
688
|
+
Fixes #30902.
|
629
689
|
|
630
|
-
*
|
631
|
-
remains healthy.
|
690
|
+
*Paul Kuruvilla*
|
632
691
|
|
633
|
-
|
692
|
+
* Remove deprecated method `#sanitize_conditions`.
|
634
693
|
|
635
|
-
*
|
636
|
-
databases.rake in the mysql/mysql2. A correct option for a database.yml
|
637
|
-
is 'encoding'.
|
694
|
+
*Rafael Mendonça França*
|
638
695
|
|
639
|
-
|
696
|
+
* Remove deprecated method `#scope_chain`.
|
640
697
|
|
641
|
-
*
|
642
|
-
to always convert values to integer calling #to_i. Fixes #7509.
|
698
|
+
*Rafael Mendonça França*
|
643
699
|
|
644
|
-
|
700
|
+
* Remove deprecated configuration `.error_on_ignored_order_or_limit`.
|
645
701
|
|
646
|
-
*
|
702
|
+
*Rafael Mendonça França*
|
647
703
|
|
648
|
-
|
704
|
+
* Remove deprecated arguments from `#verify!`.
|
649
705
|
|
650
|
-
*
|
706
|
+
*Rafael Mendonça França*
|
651
707
|
|
652
|
-
|
708
|
+
* Remove deprecated argument `name` from `#indexes`.
|
653
709
|
|
654
|
-
*
|
655
|
-
same foreign key and one of them have a counter cache.
|
656
|
-
Fixes #5200.
|
710
|
+
*Rafael Mendonça França*
|
657
711
|
|
658
|
-
|
712
|
+
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
|
659
713
|
|
660
|
-
*
|
661
|
-
Fixes #6975.
|
714
|
+
*Rafael Mendonça França*
|
662
715
|
|
663
|
-
|
716
|
+
* Remove deprecated method `supports_primary_key?`.
|
664
717
|
|
665
|
-
*
|
718
|
+
*Rafael Mendonça França*
|
666
719
|
|
667
|
-
|
720
|
+
* Remove deprecated method `supports_migrations?`.
|
668
721
|
|
669
|
-
*
|
670
|
-
|
671
|
-
|
722
|
+
*Rafael Mendonça França*
|
723
|
+
|
724
|
+
* Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
|
672
725
|
|
673
|
-
*
|
726
|
+
*Rafael Mendonça França*
|
674
727
|
|
675
|
-
*
|
676
|
-
Fixes #7306.
|
728
|
+
* Raises when calling `lock!` in a dirty record.
|
677
729
|
|
678
730
|
*Rafael Mendonça França*
|
679
731
|
|
680
|
-
*
|
681
|
-
raised. Fixes #3217.
|
732
|
+
* Remove deprecated support to passing a class to `:class_name` on associations.
|
682
733
|
|
683
|
-
*
|
734
|
+
*Rafael Mendonça França*
|
684
735
|
|
685
|
-
* Remove
|
686
|
-
Fix #7191.
|
736
|
+
* Remove deprecated argument `default` from `index_name_exists?`.
|
687
737
|
|
688
|
-
*
|
738
|
+
*Rafael Mendonça França*
|
689
739
|
|
690
|
-
*
|
691
|
-
Fix #4840.
|
740
|
+
* Remove deprecated support to `quoted_id` when typecasting an Active Record object.
|
692
741
|
|
693
|
-
*
|
742
|
+
*Rafael Mendonça França*
|
694
743
|
|
695
|
-
*
|
696
|
-
|
744
|
+
* Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
|
745
|
+
ar_internal_metadata's data for a test database.
|
697
746
|
|
698
|
-
|
747
|
+
Before:
|
748
|
+
```
|
749
|
+
$ RAILS_ENV=test rails dbconsole
|
750
|
+
> SELECT * FROM ar_internal_metadata;
|
751
|
+
key|value|created_at|updated_at
|
752
|
+
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
753
|
+
```
|
699
754
|
|
700
|
-
|
701
|
-
|
755
|
+
After:
|
756
|
+
```
|
757
|
+
$ RAILS_ENV=test rails dbconsole
|
758
|
+
> SELECT * FROM ar_internal_metadata;
|
759
|
+
key|value|created_at|updated_at
|
760
|
+
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
761
|
+
```
|
702
762
|
|
703
|
-
|
763
|
+
Fixes #26731.
|
704
764
|
|
765
|
+
*bogdanvlviv*
|
705
766
|
|
706
|
-
|
767
|
+
* Fix longer sequence name detection for serial columns.
|
707
768
|
|
708
|
-
|
709
|
-
is not a string.
|
710
|
-
Fixes #7237.
|
769
|
+
Fixes #28332.
|
711
770
|
|
712
|
-
*
|
771
|
+
*Ryuta Kamizono*
|
713
772
|
|
714
|
-
*
|
773
|
+
* MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
|
715
774
|
|
716
|
-
|
775
|
+
Fixes #30894.
|
717
776
|
|
718
|
-
*
|
719
|
-
be deprecated in 4.0 instead. *Jon Leighton*
|
777
|
+
*Ryuta Kamizono*
|
720
778
|
|
721
|
-
*
|
722
|
-
in Action Pack. Eager loading this class would break client code that eager loads Active Record
|
723
|
-
standalone.
|
724
|
-
Fixes #7160
|
779
|
+
* Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
|
725
780
|
|
726
|
-
|
781
|
+
Fixes #30886.
|
727
782
|
|
728
|
-
*
|
729
|
-
This was causing the truncation of the development database data when using RSpec.
|
730
|
-
Fixes #7175.
|
783
|
+
*Ryuta Kamizono*
|
731
784
|
|
732
|
-
|
785
|
+
* PostgreSQL `tsrange` now preserves subsecond precision.
|
733
786
|
|
734
|
-
|
787
|
+
PostgreSQL 9.1+ introduced range types, and Rails added support for using
|
788
|
+
this datatype in Active Record. However, the serialization of
|
789
|
+
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
790
|
+
cast the bounds that make up the range. This led to subseconds being
|
791
|
+
dropped in SQL commands:
|
735
792
|
|
736
|
-
|
737
|
-
are deprecated. Please transition to using scopes.
|
793
|
+
Before:
|
738
794
|
|
739
|
-
|
795
|
+
connection.type_cast(tsrange.serialize(range_value))
|
796
|
+
# => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
|
740
797
|
|
741
|
-
|
742
|
-
associations are deprecated. Please transition to using `has_many
|
743
|
-
:through`
|
798
|
+
Now:
|
744
799
|
|
745
|
-
|
800
|
+
connection.type_cast(tsrange.serialize(range_value))
|
801
|
+
# => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
|
746
802
|
|
747
|
-
*
|
748
|
-
and mutator methods if you'd like to use value objects to represent some
|
749
|
-
portion of your models.
|
803
|
+
*Thomas Cannon*
|
750
804
|
|
751
|
-
|
805
|
+
* Passing a `Set` to `Relation#where` now behaves the same as passing an
|
806
|
+
array.
|
752
807
|
|
753
|
-
*
|
754
|
-
you want to bypass mass-assignment protection, validations, callbacks,
|
755
|
-
and touching of updated_at. Otherwise please use `update_attributes`.
|
808
|
+
*Sean Griffin*
|
756
809
|
|
757
|
-
|
810
|
+
* Use given algorithm while removing index from database.
|
758
811
|
|
759
|
-
|
812
|
+
Fixes #24190.
|
760
813
|
|
761
|
-
*
|
762
|
-
table context in the next call to build_from_hash. This fix
|
763
|
-
covers this case as well.
|
814
|
+
*Mehmet Emin İNAÇ*
|
764
815
|
|
765
|
-
|
816
|
+
* Update payload names for `sql.active_record` instrumentation to be
|
817
|
+
more descriptive.
|
766
818
|
|
767
|
-
|
768
|
-
change introduced a regression (GH #6609). assoc.clear and
|
769
|
-
assoc.delete_all have loaded the association before doing the delete
|
770
|
-
since at least Rails 2.3. Doing the delete without loading the
|
771
|
-
records means that the `before_remove` and `after_remove` callbacks do
|
772
|
-
not get invoked. Therefore, this change was less a fix a more an
|
773
|
-
optimisation, which should only have gone into master.
|
819
|
+
Fixes #30586.
|
774
820
|
|
775
|
-
*
|
821
|
+
*Jeremy Green*
|
776
822
|
|
777
|
-
|
823
|
+
* Add new error class `LockWaitTimeout` which will be raised
|
824
|
+
when lock wait timeout exceeded.
|
778
825
|
|
779
|
-
*
|
780
|
-
A series of commits relating to preloading and scopes caused a regression.
|
826
|
+
*Gabriel Courtemanche*
|
781
827
|
|
782
|
-
|
828
|
+
* Remove deprecated `#migration_keys`.
|
783
829
|
|
830
|
+
*Ryuta Kamizono*
|
784
831
|
|
785
|
-
|
832
|
+
* Automatically guess the inverse associations for STI.
|
786
833
|
|
787
|
-
*
|
788
|
-
GH #6289. *Jon Leighton*
|
834
|
+
*Yuichiro Kaneko*
|
789
835
|
|
790
|
-
*
|
791
|
-
This could cause infinite recursion and potentially other problems.
|
792
|
-
See GH #5667. *Jon Leighton*
|
836
|
+
* Ensure `sum` honors `distinct` on `has_many :through` associations.
|
793
837
|
|
794
|
-
|
838
|
+
Fixes #16791.
|
795
839
|
|
796
|
-
*
|
840
|
+
*Aaron Wortham*
|
797
841
|
|
798
|
-
*
|
842
|
+
* Add `binary` fixture helper method.
|
799
843
|
|
800
|
-
*
|
801
|
-
Thanks to Ben Murphy for reporting this! CVE-2012-2661
|
844
|
+
*Atsushi Yoshida*
|
802
845
|
|
846
|
+
* When using `Relation#or`, extract the common conditions and put them before the OR condition.
|
803
847
|
|
804
|
-
|
848
|
+
*Maxime Handfield Lapointe*
|
805
849
|
|
806
|
-
*
|
850
|
+
* `Relation#or` now accepts two relations who have different values for
|
851
|
+
`references` only, as `references` can be implicitly called by `where`.
|
807
852
|
|
808
|
-
|
853
|
+
Fixes #29411.
|
809
854
|
|
810
|
-
*
|
855
|
+
*Sean Griffin*
|
811
856
|
|
812
|
-
*
|
857
|
+
* `ApplicationRecord` is no longer generated when generating models. If you
|
858
|
+
need to generate it, it can be created with `rails g application_record`.
|
813
859
|
|
814
|
-
*
|
860
|
+
*Lisa Ugray*
|
815
861
|
|
816
|
-
* Fix
|
862
|
+
* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
|
817
863
|
|
818
|
-
*
|
864
|
+
*Ryuta Kamizono*
|
819
865
|
|
866
|
+
* When a `has_one` association is destroyed by `dependent: destroy`,
|
867
|
+
`destroyed_by_association` will now be set to the reflection, matching the
|
868
|
+
behaviour of `has_many` associations.
|
820
869
|
|
821
|
-
|
870
|
+
*Lisa Ugray*
|
822
871
|
|
823
|
-
*
|
872
|
+
* Fix `unscoped(where: [columns])` removing the wrong bind values.
|
824
873
|
|
874
|
+
When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
|
875
|
+
bind values used by the `or` instead. (possibly other cases too)
|
825
876
|
|
826
|
-
|
877
|
+
```
|
878
|
+
Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
|
879
|
+
# Currently:
|
880
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
881
|
+
# With fix:
|
882
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
883
|
+
```
|
827
884
|
|
828
|
-
*
|
885
|
+
*Maxime Handfield Lapointe*
|
829
886
|
|
830
|
-
*
|
831
|
-
|
887
|
+
* Values constructed using multi-parameter assignment will now use the
|
888
|
+
post-type-cast value for rendering in single-field form inputs.
|
832
889
|
|
833
|
-
*
|
834
|
-
methods for the same class. *Jon Leighton*
|
890
|
+
*Sean Griffin*
|
835
891
|
|
892
|
+
* `Relation#joins` is no longer affected by the target model's
|
893
|
+
`current_scope`, with the exception of `unscoped`.
|
836
894
|
|
837
|
-
|
895
|
+
Fixes #29338.
|
838
896
|
|
839
|
-
*
|
840
|
-
a transaction, locks the object (pessimistically) and yields to the block.
|
841
|
-
The method takes one (optional) parameter and passes it to `lock!`.
|
897
|
+
*Sean Griffin*
|
842
898
|
|
843
|
-
|
899
|
+
* Change sqlite3 boolean serialization to use 1 and 0.
|
844
900
|
|
845
|
-
|
846
|
-
|
847
|
-
transaction do
|
848
|
-
lock!
|
849
|
-
# ... cancelling logic
|
850
|
-
end
|
851
|
-
end
|
852
|
-
end
|
901
|
+
SQLite natively recognizes 1 and 0 as true and false, but does not natively
|
902
|
+
recognize 't' and 'f' as was previously serialized.
|
853
903
|
|
854
|
-
|
904
|
+
This change in serialization requires a migration of stored boolean data
|
905
|
+
for SQLite databases, so it's implemented behind a configuration flag
|
906
|
+
whose default false value is deprecated.
|
855
907
|
|
856
|
-
|
857
|
-
def cancel!
|
858
|
-
with_lock do
|
859
|
-
# ... cancelling logic
|
860
|
-
end
|
861
|
-
end
|
862
|
-
end
|
908
|
+
*Lisa Ugray*
|
863
909
|
|
864
|
-
|
910
|
+
* Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
|
911
|
+
`in_batches`).
|
865
912
|
|
866
|
-
|
867
|
-
|
913
|
+
Previously, records would be fetched in batches, but all records would be retained in memory
|
914
|
+
until the end of the request or job.
|
868
915
|
|
869
|
-
*
|
870
|
-
to run migrations only from one engine (for example to revert changes
|
871
|
-
from engine that you want to remove).
|
916
|
+
*Eugene Kenny*
|
872
917
|
|
873
|
-
|
874
|
-
|
918
|
+
* Prevent errors raised by `sql.active_record` notification subscribers from being converted into
|
919
|
+
`ActiveRecord::StatementInvalid` exceptions.
|
875
920
|
|
876
|
-
*
|
921
|
+
*Dennis Taylor*
|
877
922
|
|
878
|
-
*
|
879
|
-
for example 01_create_posts.blog.rb. *Piotr Sarnacki*
|
923
|
+
* Fix eager loading/preloading association with scope including joins.
|
880
924
|
|
881
|
-
|
882
|
-
selectively disable automatic EXPLAINs within a block. *fxn*
|
925
|
+
Fixes #28324.
|
883
926
|
|
884
|
-
*
|
927
|
+
*Ryuta Kamizono*
|
885
928
|
|
886
|
-
|
887
|
-
determines what's to be considered a slow query. Setting that to `nil` disables
|
888
|
-
this feature. Defaults are 0.5 in development mode, and `nil` in test and production
|
889
|
-
modes.
|
929
|
+
* Fix transactions to apply state to child transactions.
|
890
930
|
|
891
|
-
|
892
|
-
|
931
|
+
Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
|
932
|
+
inner transaction would still be marked as persisted.
|
893
933
|
|
894
|
-
|
934
|
+
This change fixes that by applying the state of the parent transaction to the child transaction when the
|
935
|
+
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
895
936
|
|
896
|
-
*
|
937
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
897
938
|
|
898
|
-
|
939
|
+
* Deprecate `set_state` method in `TransactionState`.
|
899
940
|
|
900
|
-
|
941
|
+
Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
|
942
|
+
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
943
|
+
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
901
944
|
|
902
|
-
*
|
945
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
903
946
|
|
904
|
-
*
|
905
|
-
the following code is deprecated:
|
947
|
+
* Deprecate delegating to `arel` in `Relation`.
|
906
948
|
|
907
|
-
|
949
|
+
*Ryuta Kamizono*
|
908
950
|
|
909
|
-
|
910
|
-
|
951
|
+
* Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
|
952
|
+
without being connected.
|
911
953
|
|
912
|
-
|
913
|
-
Post.find(1)
|
914
|
-
Post.connection.close
|
915
|
-
}.join
|
954
|
+
*Tsukasa Oishi*
|
916
955
|
|
917
|
-
|
918
|
-
|
956
|
+
* Previously, when building records using a `has_many :through` association,
|
957
|
+
if the child records were deleted before the parent was saved, they would
|
958
|
+
still be persisted. Now, if child records are deleted before the parent is saved
|
959
|
+
on a `has_many :through` association, the child records will not be persisted.
|
919
960
|
|
920
|
-
*
|
961
|
+
*Tobias Kraze*
|
921
962
|
|
922
|
-
|
923
|
-
|
924
|
-
* `set_sequence_name`
|
925
|
-
* `set_primary_key`
|
926
|
-
* `set_locking_column`
|
963
|
+
* Merging two relations representing nested joins no longer transforms the joins of
|
964
|
+
the merged relation into LEFT OUTER JOIN.
|
927
965
|
|
928
|
-
|
966
|
+
Example:
|
929
967
|
|
930
|
-
|
931
|
-
|
932
|
-
|
968
|
+
```
|
969
|
+
Author.joins(:posts).merge(Post.joins(:comments))
|
970
|
+
# Before the change:
|
971
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
|
933
972
|
|
934
|
-
|
973
|
+
# After the change:
|
974
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
|
975
|
+
```
|
935
976
|
|
936
|
-
|
937
|
-
def self.table_name
|
938
|
-
"special_" + super
|
939
|
-
end
|
940
|
-
end
|
941
|
-
Post.table_name # => "special_posts"
|
977
|
+
*Maxime Handfield Lapointe*
|
942
978
|
|
943
|
-
|
979
|
+
* `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
|
980
|
+
`locking_column`, without default value, is null in the database.
|
944
981
|
|
945
|
-
*
|
946
|
-
composition using `super`. For a class named `MyModel`, the module is named
|
947
|
-
`MyModel::GeneratedFeatureMethods`. It is included into the model class immediately after
|
948
|
-
the `generated_attributes_methods` module defined in ActiveModel, so association methods
|
949
|
-
override attribute methods of the same name. *Josh Susser*
|
982
|
+
*bogdanvlviv*
|
950
983
|
|
951
|
-
*
|
984
|
+
* Fix destroying existing object does not work well when optimistic locking enabled and
|
985
|
+
`locking_column` is null in the database.
|
952
986
|
|
953
|
-
*
|
987
|
+
*bogdanvlviv*
|
954
988
|
|
955
|
-
|
989
|
+
* Use bulk INSERT to insert fixtures for better performance.
|
956
990
|
|
957
|
-
|
991
|
+
*Kir Shatrov*
|
958
992
|
|
959
|
-
|
993
|
+
* Prevent creation of bind param if casted value is nil.
|
960
994
|
|
961
|
-
|
995
|
+
*Ryuta Kamizono*
|
962
996
|
|
963
|
-
|
997
|
+
* Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.
|
964
998
|
|
965
|
-
|
999
|
+
*Ryuta Kamizono*
|
966
1000
|
|
967
|
-
|
1001
|
+
* Loading model schema from database is now thread-safe.
|
968
1002
|
|
969
|
-
|
1003
|
+
Fixes #28589.
|
970
1004
|
|
971
|
-
*
|
972
|
-
a string ('Client').
|
1005
|
+
*Vikrant Chaudhary*, *David Abdemoulaie*
|
973
1006
|
|
974
|
-
|
975
|
-
|
1007
|
+
* Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
|
1008
|
+
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
1009
|
+
that does not include a timestamp any more.
|
976
1010
|
|
977
|
-
|
1011
|
+
NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
|
1012
|
+
until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
|
978
1013
|
|
979
|
-
*
|
980
|
-
the db:create task. *Dmitriy Kiriyenko*
|
1014
|
+
*DHH*
|
981
1015
|
|
982
|
-
*
|
1016
|
+
* Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump.
|
983
1017
|
|
984
|
-
|
985
|
-
store :settings, accessors: [ :color, :homepage ]
|
986
|
-
end
|
1018
|
+
*Rusty Geldmacher*, *Guillermo Iguaran*
|
987
1019
|
|
988
|
-
|
989
|
-
u.color # Accessor stored attribute
|
990
|
-
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
|
1020
|
+
* Add type caster to `RuntimeReflection#alias_name`.
|
991
1021
|
|
1022
|
+
Fixes #28959.
|
992
1023
|
|
993
|
-
*
|
994
|
-
the column already uses a case-insensitive collation. Fixes #561.
|
1024
|
+
*Jon Moss*
|
995
1025
|
|
996
|
-
|
1026
|
+
* Deprecate `supports_statement_cache?`.
|
997
1027
|
|
998
|
-
*
|
999
|
-
models on different connections without disabling transactional fixtures.
|
1028
|
+
*Ryuta Kamizono*
|
1000
1029
|
|
1001
|
-
|
1030
|
+
* Raise error `UnknownMigrationVersionError` on the movement of migrations
|
1031
|
+
when the current migration does not exist.
|
1002
1032
|
|
1003
|
-
*
|
1004
|
-
better approach over the old find_or_create_by dynamic methods because it's clearer which
|
1005
|
-
arguments are used to find the record and which are used to create it:
|
1033
|
+
*bogdanvlviv*
|
1006
1034
|
|
1007
|
-
|
1035
|
+
* Fix `bin/rails db:forward` first migration.
|
1008
1036
|
|
1009
|
-
*
|
1037
|
+
*bogdanvlviv*
|
1010
1038
|
|
1011
|
-
*
|
1012
|
-
during :reject_if => :all_blank (fixes #2937)
|
1039
|
+
* Support Descending Indexes for MySQL.
|
1013
1040
|
|
1014
|
-
|
1041
|
+
MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
|
1042
|
+
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
1015
1043
|
|
1016
|
-
*
|
1044
|
+
*Ryuta Kamizono*
|
1045
|
+
|
1046
|
+
* Fix inconsistency with changed attributes when overriding Active Record attribute reader.
|
1047
|
+
|
1048
|
+
*bogdanvlviv*
|
1049
|
+
|
1050
|
+
* When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
|
1051
|
+
Previously this method always returned an empty array.
|
1052
|
+
|
1053
|
+
*Kevin McPhillips*
|
1017
1054
|
|
1018
|
-
*Brian Durand*
|
1019
1055
|
|
1020
|
-
Please check [
|
1056
|
+
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
|