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