activerecord 5.1.0 → 5.2.0.rc1
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 +410 -530
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- 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 +23 -32
- data/lib/active_record/associations/association.rb +20 -21
- data/lib/active_record/associations/association_scope.rb +49 -49
- data/lib/active_record/associations/belongs_to_association.rb +12 -10
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +4 -7
- data/lib/active_record/associations/builder/association.rb +4 -7
- data/lib/active_record/associations/builder/belongs_to.rb +10 -6
- 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 +50 -41
- data/lib/active_record/associations/collection_proxy.rb +22 -39
- data/lib/active_record/associations/foreign_association.rb +2 -0
- data/lib/active_record/associations/has_many_association.rb +4 -2
- data/lib/active_record/associations/has_many_through_association.rb +12 -18
- data/lib/active_record/associations/has_one_association.rb +5 -1
- data/lib/active_record/associations/has_one_through_association.rb +8 -7
- data/lib/active_record/associations/join_dependency/join_association.rb +17 -64
- data/lib/active_record/associations/join_dependency/join_base.rb +9 -8
- data/lib/active_record/associations/join_dependency/join_part.rb +2 -9
- data/lib/active_record/associations/join_dependency.rb +27 -44
- data/lib/active_record/associations/preloader/association.rb +53 -92
- data/lib/active_record/associations/preloader/through_association.rb +72 -73
- data/lib/active_record/associations/preloader.rb +17 -37
- data/lib/active_record/associations/singular_association.rb +14 -10
- data/lib/active_record/associations/through_association.rb +26 -11
- data/lib/active_record/associations.rb +68 -76
- data/lib/active_record/attribute_assignment.rb +2 -0
- 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 +24 -214
- data/lib/active_record/attribute_methods/primary_key.rb +10 -13
- data/lib/active_record/attribute_methods/query.rb +2 -0
- data/lib/active_record/attribute_methods/read.rb +8 -2
- 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 +22 -19
- data/lib/active_record/attribute_methods.rb +48 -12
- data/lib/active_record/attributes.rb +7 -6
- data/lib/active_record/autosave_association.rb +8 -11
- data/lib/active_record/base.rb +2 -0
- data/lib/active_record/callbacks.rb +8 -6
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +2 -0
- data/lib/active_record/collection_cache_key.rb +14 -10
- 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 +175 -33
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +8 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +13 -24
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +15 -6
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +58 -3
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +31 -53
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +165 -85
- data/lib/active_record/connection_adapters/abstract/transaction.rb +45 -9
- data/lib/active_record/connection_adapters/abstract_adapter.rb +83 -97
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +118 -180
- data/lib/active_record/connection_adapters/column.rb +4 -2
- 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 +11 -17
- 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 -23
- 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 +30 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -32
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_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 -11
- 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 +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +22 -1
- 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 +269 -126
- 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 +64 -85
- 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 +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -15
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +3 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +71 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +92 -95
- 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 +3 -2
- 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 +9 -9
- 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 +8 -6
- data/lib/active_record/locking/pessimistic.rb +9 -6
- data/lib/active_record/log_subscriber.rb +46 -4
- data/lib/active_record/migration/command_recorder.rb +11 -9
- data/lib/active_record/migration/compatibility.rb +74 -22
- data/lib/active_record/migration/join_table.rb +2 -0
- data/lib/active_record/migration.rb +181 -137
- data/lib/active_record/model_schema.rb +73 -58
- 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 +153 -18
- data/lib/active_record/query_cache.rb +17 -12
- data/lib/active_record/querying.rb +4 -2
- 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 +47 -37
- data/lib/active_record/readonly_attributes.rb +3 -2
- data/lib/active_record/reflection.rb +131 -204
- data/lib/active_record/relation/batches/batch_enumerator.rb +2 -0
- data/lib/active_record/relation/batches.rb +32 -17
- data/lib/active_record/relation/calculations.rb +58 -20
- data/lib/active_record/relation/delegation.rb +10 -29
- data/lib/active_record/relation/finder_methods.rb +74 -85
- data/lib/active_record/relation/from_clause.rb +2 -8
- data/lib/active_record/relation/merger.rb +51 -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 +54 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +22 -6
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/predicate_builder.rb +53 -78
- data/lib/active_record/relation/query_attribute.rb +9 -2
- data/lib/active_record/relation/query_methods.rb +101 -95
- 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 -67
- data/lib/active_record/relation/where_clause_factory.rb +5 -48
- data/lib/active_record/relation.rb +99 -202
- 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 +10 -7
- data/lib/active_record/scoping/named.rb +38 -12
- data/lib/active_record/scoping.rb +12 -10
- 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 +37 -25
- data/lib/active_record/tasks/mysql_database_tasks.rb +11 -50
- data/lib/active_record/tasks/postgresql_database_tasks.rb +11 -3
- data/lib/active_record/tasks/sqlite_database_tasks.rb +25 -3
- data/lib/active_record/timestamp.rb +5 -5
- data/lib/active_record/touch_later.rb +2 -0
- data/lib/active_record/transactions.rb +9 -7
- data/lib/active_record/translation.rb +2 -0
- data/lib/active_record/type/adapter_specific_registry.rb +2 -0
- data/lib/active_record/type/date.rb +2 -0
- data/lib/active_record/type/date_time.rb +2 -0
- data/lib/active_record/type/decimal_without_scale.rb +2 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +2 -0
- data/lib/active_record/type/internal/timezone.rb +2 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +2 -0
- data/lib/active_record/type/text.rb +2 -0
- data/lib/active_record/type/time.rb +2 -0
- data/lib/active_record/type/type_map.rb +2 -0
- data/lib/active_record/type/unsigned_integer.rb +2 -0
- data/lib/active_record/type.rb +4 -1
- data/lib/active_record/type_caster/connection.rb +2 -0
- data/lib/active_record/type_caster/map.rb +3 -1
- data/lib/active_record/type_caster.rb +2 -0
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +2 -0
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +2 -0
- data/lib/active_record/validations/uniqueness.rb +35 -5
- data/lib/active_record/validations.rb +2 -0
- data/lib/active_record/version.rb +2 -0
- data/lib/active_record.rb +11 -4
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +3 -1
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration.rb +2 -0
- data/lib/rails/generators/active_record/model/model_generator.rb +2 -23
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +0 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- data/lib/rails/generators/active_record.rb +3 -1
- metadata +25 -37
- 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 -113
- 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 -33
data/CHANGELOG.md
CHANGED
@@ -1,791 +1,671 @@
|
|
1
|
-
## Rails 5.
|
1
|
+
## Rails 5.2.0.rc1 (January 30, 2018) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
*Rune Philosof*
|
6
|
-
|
7
|
-
* When multiple threads are sharing a database connection inside a test using
|
8
|
-
transactional fixtures, a nested transaction will temporarily lock the
|
9
|
-
connection to the current thread, forcing others to wait.
|
10
|
-
|
11
|
-
Fixes #28197.
|
12
|
-
|
13
|
-
*Matthew Draper*
|
14
|
-
|
15
|
-
* Load only needed records on `ActiveRecord::Relation#inspect`.
|
16
|
-
|
17
|
-
Instead of loading all records and returning only a subset of those, just
|
18
|
-
load the records as needed.
|
19
|
-
|
20
|
-
Fixes #25537.
|
21
|
-
|
22
|
-
*Hendy Tanata*
|
23
|
-
|
24
|
-
* Remove comments from structure.sql when using postgresql adapter to avoid
|
25
|
-
version-specific parts of the file.
|
26
|
-
|
27
|
-
Fixes #28153.
|
28
|
-
|
29
|
-
*Ari Pollak*
|
30
|
-
|
31
|
-
* Add `:default` option to `belongs_to`.
|
32
|
-
|
33
|
-
Use it to specify that an association should be initialized with a particular
|
34
|
-
record before validation. For example:
|
35
|
-
|
36
|
-
# Before
|
37
|
-
belongs_to :account
|
38
|
-
before_validation -> { self.account ||= Current.account }
|
39
|
-
|
40
|
-
# After
|
41
|
-
belongs_to :account, default: -> { Current.account }
|
42
|
-
|
43
|
-
*George Claghorn*
|
44
|
-
|
45
|
-
* Deprecate `Migrator.schema_migrations_table_name`.
|
3
|
+
* Deprecate `expand_hash_conditions_for_aggregates` without replacement.
|
4
|
+
Using a `Relation` for performing queries is the prefered API.
|
46
5
|
|
47
6
|
*Ryuta Kamizono*
|
48
7
|
|
49
|
-
* Fix
|
8
|
+
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
|
50
9
|
|
51
|
-
|
10
|
+
```
|
11
|
+
david_balance = customers(:david).balance
|
12
|
+
Customer.where(balance: [david_balance]).to_sql
|
52
13
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
In #27674 we changed the migration generator to generate migrations at the
|
58
|
-
path defined in `Rails.application.config.paths` however the code checked
|
59
|
-
for the presence of the `Rails` constant but not the `Rails.application`
|
60
|
-
method which caused problems when using Active Record and generators outside
|
61
|
-
of the context of a Rails application.
|
14
|
+
# Before: WHERE `customers`.`balance` = NULL
|
15
|
+
# After : WHERE `customers`.`balance` = 50
|
16
|
+
```
|
62
17
|
|
63
|
-
Fixes #
|
18
|
+
Fixes #31723.
|
64
19
|
|
65
|
-
*
|
20
|
+
*Yutaro Kanagawa*
|
66
21
|
|
67
|
-
* Fix `
|
22
|
+
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
68
23
|
|
69
|
-
Fixes #
|
24
|
+
Fixes #31783.
|
70
25
|
|
71
26
|
*Ryuta Kamizono*
|
72
27
|
|
73
|
-
*
|
28
|
+
* Clear the transaction state when an Active Record object is duped.
|
74
29
|
|
75
|
-
|
30
|
+
Fixes #31670.
|
76
31
|
|
77
|
-
*
|
32
|
+
*Yuriy Ustushenko*
|
78
33
|
|
79
|
-
|
34
|
+
* Support for PostgreSQL foreign tables.
|
80
35
|
|
81
|
-
*
|
36
|
+
*fatkodima*
|
82
37
|
|
83
|
-
|
84
|
-
between the two columns doesn't make sense since they are different types.
|
85
|
-
The `reference_id` column is usually an integer and the `reference_type`
|
86
|
-
column a string so options like `unsigned: true` will result in an invalid
|
87
|
-
table definition.
|
38
|
+
* Fix relation merger issue with `left_outer_joins`.
|
88
39
|
|
89
|
-
*
|
40
|
+
*Mehmet Emin İNAÇ*
|
90
41
|
|
91
|
-
*
|
42
|
+
* Don't allow destroyed object mutation after `save` or `save!` is called.
|
92
43
|
|
93
44
|
*Ryuta Kamizono*
|
94
45
|
|
95
|
-
*
|
46
|
+
* Take into account association conditions when deleting through records.
|
96
47
|
|
97
|
-
|
48
|
+
Fixes #18424.
|
98
49
|
|
99
|
-
*
|
50
|
+
*Piotr Jakubowski*
|
100
51
|
|
101
|
-
|
52
|
+
* Fix nested `has_many :through` associations on unpersisted parent instances.
|
102
53
|
|
103
|
-
|
54
|
+
For example, if you have
|
104
55
|
|
105
|
-
|
56
|
+
class Post < ActiveRecord::Base
|
57
|
+
belongs_to :author
|
58
|
+
has_many :books, through: :author
|
59
|
+
has_many :subscriptions, through: :books
|
60
|
+
end
|
106
61
|
|
107
|
-
|
62
|
+
class Author < ActiveRecord::Base
|
63
|
+
has_one :post
|
64
|
+
has_many :books
|
65
|
+
has_many :subscriptions, through: :books
|
66
|
+
end
|
108
67
|
|
109
|
-
|
68
|
+
class Book < ActiveRecord::Base
|
69
|
+
belongs_to :author
|
70
|
+
has_many :subscriptions
|
71
|
+
end
|
110
72
|
|
111
|
-
|
73
|
+
class Subscription < ActiveRecord::Base
|
74
|
+
belongs_to :book
|
75
|
+
end
|
112
76
|
|
113
|
-
|
77
|
+
Before:
|
114
78
|
|
115
|
-
|
116
|
-
Internal representation of the timestamp type is UNIX time, This means
|
117
|
-
that timestamp columns are affected by time zone.
|
79
|
+
If `post` is not persisted, then `post.subscriptions` will be empty.
|
118
80
|
|
119
|
-
|
120
|
-
Query OK, 0 rows affected (0.00 sec)
|
81
|
+
After:
|
121
82
|
|
122
|
-
|
123
|
-
|
83
|
+
If `post` is not persisted, then `post.subscriptions` can be set and used
|
84
|
+
just like it would if `post` were persisted.
|
124
85
|
|
125
|
-
|
126
|
-
+---------------------+---------------------+
|
127
|
-
| ts | dt |
|
128
|
-
+---------------------+---------------------+
|
129
|
-
| 2016-02-07 22:11:44 | 2016-02-07 22:11:44 |
|
130
|
-
+---------------------+---------------------+
|
131
|
-
1 row in set (0.00 sec)
|
86
|
+
Fixes #16313.
|
132
87
|
|
133
|
-
|
134
|
-
Query OK, 0 rows affected (0.00 sec)
|
88
|
+
*Zoltan Kiss*
|
135
89
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
+---------------------+---------------------+
|
140
|
-
| 2016-02-07 14:11:44 | 2016-02-07 22:11:44 |
|
141
|
-
+---------------------+---------------------+
|
142
|
-
1 row in set (0.00 sec)
|
90
|
+
* Fixed inconsistency with `first(n)` when used with `limit()`.
|
91
|
+
The `first(n)` finder now respects the `limit()`, making it consistent
|
92
|
+
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
143
93
|
|
144
|
-
|
94
|
+
Fixes #23979.
|
145
95
|
|
146
|
-
*
|
96
|
+
*Brian Christian*
|
147
97
|
|
148
|
-
|
98
|
+
* Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
|
99
|
+
SQL queries for association counting.
|
149
100
|
|
150
|
-
*
|
101
|
+
*Klas Eskilson*
|
151
102
|
|
152
|
-
|
153
|
-
|
154
|
-
* Deprecate passing `default` to `index_name_exists?`.
|
103
|
+
* Fix to invoke callbacks when using `update_attribute`.
|
155
104
|
|
156
|
-
*
|
105
|
+
*Mike Busch*
|
157
106
|
|
158
|
-
*
|
107
|
+
* Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
|
159
108
|
|
160
109
|
*Ryuta Kamizono*
|
161
110
|
|
162
|
-
*
|
163
|
-
been long unused and unsupported.
|
111
|
+
* Using subselect for `delete_all` with `limit` or `offset`.
|
164
112
|
|
165
113
|
*Ryuta Kamizono*
|
166
114
|
|
167
|
-
*
|
168
|
-
|
169
|
-
|
170
|
-
*
|
171
|
-
|
172
|
-
*
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
*
|
115
|
+
* Undefine attribute methods on descendants when resetting column
|
116
|
+
information.
|
117
|
+
|
118
|
+
*Chris Salzberg*
|
119
|
+
|
120
|
+
* Log database query callers
|
121
|
+
|
122
|
+
Add `verbose_query_logs` configuration option to display the caller
|
123
|
+
of database queries in the log to facilitate N+1 query resolution
|
124
|
+
and other debugging.
|
125
|
+
|
126
|
+
Enabled in development only for new and upgraded applications. Not
|
127
|
+
recommended for use in the production environment since it relies
|
128
|
+
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
129
|
+
|
130
|
+
*Olivier Lacan*
|
131
|
+
|
132
|
+
* Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
|
133
|
+
|
134
|
+
```
|
135
|
+
# create_table :posts do |t|
|
136
|
+
# t.integer :comments_count, default: 0
|
137
|
+
# t.integer :lock_version
|
138
|
+
# t.timestamps
|
139
|
+
# end
|
140
|
+
class Post < ApplicationRecord
|
141
|
+
end
|
142
|
+
|
143
|
+
# create_table :comments do |t|
|
144
|
+
# t.belongs_to :post
|
145
|
+
# end
|
146
|
+
class Comment < ApplicationRecord
|
147
|
+
belongs_to :post, touch: true, counter_cache: true
|
148
|
+
end
|
149
|
+
```
|
150
|
+
|
151
|
+
Before:
|
152
|
+
```
|
153
|
+
post = Post.create!
|
154
|
+
# => begin transaction
|
155
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
156
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
157
|
+
commit transaction
|
158
|
+
|
159
|
+
comment = Comment.create!(post: post)
|
160
|
+
# => begin transaction
|
161
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
162
|
+
|
163
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
164
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
165
|
+
|
166
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
167
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
168
|
+
rollback transaction
|
169
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
170
|
+
|
171
|
+
Comment.take.destroy!
|
172
|
+
# => begin transaction
|
173
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
174
|
+
|
175
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
176
|
+
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
177
|
+
|
178
|
+
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
179
|
+
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
180
|
+
rollback transaction
|
181
|
+
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
182
|
+
```
|
183
|
+
|
184
|
+
After:
|
185
|
+
```
|
186
|
+
post = Post.create!
|
187
|
+
# => begin transaction
|
188
|
+
INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
|
189
|
+
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
190
|
+
commit transaction
|
191
|
+
|
192
|
+
comment = Comment.create!(post: post)
|
193
|
+
# => begin transaction
|
194
|
+
INSERT INTO "comments" ("post_id") VALUES (1)
|
195
|
+
|
196
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
197
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
198
|
+
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
199
|
+
commit transaction
|
200
|
+
|
201
|
+
comment.destroy!
|
202
|
+
# => begin transaction
|
203
|
+
DELETE FROM "comments" WHERE "comments"."id" = 1
|
204
|
+
|
205
|
+
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
206
|
+
"lock_version" = COALESCE("lock_version", 0) + 1,
|
207
|
+
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
208
|
+
commit transaction
|
209
|
+
```
|
210
|
+
|
211
|
+
Fixes #31199.
|
183
212
|
|
184
|
-
*
|
185
|
-
|
186
|
-
*Rafael Mendonça França*
|
187
|
-
|
188
|
-
* Deprecate `ColumnDumper#migration_keys`.
|
189
|
-
|
190
|
-
*Ryuta Kamizono*
|
191
|
-
|
192
|
-
* Fix `association_primary_key_type` for reflections with symbol primary key.
|
193
|
-
|
194
|
-
Fixes #27864.
|
195
|
-
|
196
|
-
*Daniel Colson*
|
197
|
-
|
198
|
-
* Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+.
|
199
|
-
|
200
|
-
MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html
|
201
|
-
MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
|
213
|
+
*bogdanvlviv*
|
202
214
|
|
203
|
-
|
204
|
-
Pass `stored: true` to persist the generated value (false by default).
|
215
|
+
* Add support for PostgreSQL operator classes to `add_index`.
|
205
216
|
|
206
217
|
Example:
|
207
218
|
|
208
|
-
|
209
|
-
t.string :name
|
210
|
-
t.virtual :upper_name, type: :string, as: "UPPER(name)"
|
211
|
-
t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
|
212
|
-
t.index :name_length # May be indexed, too!
|
213
|
-
end
|
214
|
-
|
215
|
-
*Ryuta Kamizono*
|
216
|
-
|
217
|
-
* Deprecate `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
|
218
|
-
|
219
|
-
*Ryuta Kamizono*
|
220
|
-
|
221
|
-
* Support foreign key creation for SQLite3.
|
222
|
-
|
223
|
-
*Ryuta Kamizono*
|
224
|
-
|
225
|
-
* Place generated migrations into the path set by `config.paths["db/migrate"]`.
|
219
|
+
add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
|
226
220
|
|
227
|
-
*
|
221
|
+
*Greg Navis*
|
228
222
|
|
229
|
-
*
|
223
|
+
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
230
224
|
|
231
|
-
|
232
|
-
|
233
|
-
* Add the touch option to `#increment!` and `#decrement!`.
|
225
|
+
Fixes #31120.
|
234
226
|
|
235
|
-
*
|
227
|
+
*kinnrot*
|
236
228
|
|
237
|
-
* Deprecate passing a class to the `class_name` because it eagerloads more classes than
|
238
|
-
necessary and potentially creates circular dependencies.
|
239
229
|
|
240
|
-
|
230
|
+
## Rails 5.2.0.beta2 (November 28, 2017) ##
|
241
231
|
|
242
|
-
*
|
232
|
+
* No changes.
|
243
233
|
|
244
|
-
Fixes #26834.
|
245
234
|
|
246
|
-
|
235
|
+
## Rails 5.2.0.beta1 (November 27, 2017) ##
|
247
236
|
|
248
|
-
*
|
237
|
+
* Add new error class `QueryCanceled` which will be raised
|
238
|
+
when canceling statement due to user request.
|
249
239
|
|
250
240
|
*Ryuta Kamizono*
|
251
241
|
|
252
|
-
*
|
242
|
+
* Add `#up_only` to database migrations for code that is only relevant when
|
243
|
+
migrating up, e.g. populating a new column.
|
253
244
|
|
254
|
-
*
|
245
|
+
*Rich Daley*
|
255
246
|
|
256
|
-
*
|
257
|
-
|
258
|
-
|
259
|
-
Fixes #27502.
|
260
|
-
|
261
|
-
*Jon Moss*
|
247
|
+
* Require raw SQL fragments to be explicitly marked when used in
|
248
|
+
relation query methods.
|
262
249
|
|
263
|
-
|
264
|
-
|
250
|
+
Before:
|
251
|
+
```
|
252
|
+
Article.order("LENGTH(title)")
|
253
|
+
```
|
265
254
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
Fixes #27514.
|
271
|
-
|
272
|
-
*Sean Griffin*
|
255
|
+
After:
|
256
|
+
```
|
257
|
+
Article.order(Arel.sql("LENGTH(title)"))
|
258
|
+
```
|
273
259
|
|
274
|
-
|
260
|
+
This prevents SQL injection if applications use the [strongly
|
261
|
+
discouraged] form `Article.order(params[:my_order])`, under the
|
262
|
+
mistaken belief that only column names will be accepted.
|
275
263
|
|
276
|
-
|
264
|
+
Raw SQL strings will now cause a deprecation warning, which will
|
265
|
+
become an UnknownAttributeReference error in Rails 6.0. Applications
|
266
|
+
can opt in to the future behavior by setting `allow_unsafe_raw_sql`
|
267
|
+
to `:disabled`.
|
277
268
|
|
278
|
-
|
269
|
+
Common and judged-safe string values (such as simple column
|
270
|
+
references) are unaffected:
|
271
|
+
```
|
272
|
+
Article.order("title DESC")
|
273
|
+
```
|
279
274
|
|
280
|
-
|
275
|
+
*Ben Toews*
|
281
276
|
|
282
|
-
|
283
|
-
|
284
|
-
|
277
|
+
* `update_all` will now pass its values to `Type#cast` before passing them to
|
278
|
+
`Type#serialize`. This means that `update_all(foo: 'true')` will properly
|
279
|
+
persist a boolean.
|
285
280
|
|
286
|
-
|
287
|
-
Topic.reset_counters(18, :messages, touch: :last_discussed_at)
|
288
|
-
|
289
|
-
# Touches `updated_at` and `last_discussed_at`.
|
290
|
-
Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
|
291
|
-
|
292
|
-
Fixes #26724.
|
293
|
-
|
294
|
-
*Jarred Trost*
|
295
|
-
|
296
|
-
* Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`.
|
297
|
-
|
298
|
-
*Ryuta Kamizono*
|
281
|
+
*Sean Griffin*
|
299
282
|
|
300
|
-
*
|
283
|
+
* Add new error class `StatementTimeout` which will be raised
|
284
|
+
when statement timeout exceeded.
|
301
285
|
|
302
286
|
*Ryuta Kamizono*
|
303
287
|
|
304
|
-
*
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
288
|
+
* Fix `bin/rails db:migrate` with specified `VERSION`.
|
289
|
+
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
290
|
+
Check a format of `VERSION`: Allow a migration version number
|
291
|
+
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
292
|
+
Raise error if target migration doesn't exist.
|
309
293
|
|
310
|
-
*
|
311
|
-
|
312
|
-
* Remove deprecated `#load_schema_for`.
|
294
|
+
*bogdanvlviv*
|
313
295
|
|
314
|
-
|
296
|
+
* Fixed a bug where column orders for an index weren't written to
|
297
|
+
`db/schema.rb` when using the sqlite adapter.
|
315
298
|
|
316
|
-
|
299
|
+
Fixes #30902.
|
317
300
|
|
318
|
-
*
|
301
|
+
*Paul Kuruvilla*
|
319
302
|
|
320
|
-
* Remove deprecated
|
303
|
+
* Remove deprecated method `#sanitize_conditions`.
|
321
304
|
|
322
305
|
*Rafael Mendonça França*
|
323
306
|
|
324
|
-
* Remove deprecated
|
307
|
+
* Remove deprecated method `#scope_chain`.
|
325
308
|
|
326
309
|
*Rafael Mendonça França*
|
327
310
|
|
328
|
-
* Remove deprecated
|
311
|
+
* Remove deprecated configuration `.error_on_ignored_order_or_limit`.
|
329
312
|
|
330
313
|
*Rafael Mendonça França*
|
331
314
|
|
332
|
-
*
|
333
|
-
order.
|
315
|
+
* Remove deprecated arguments from `#verify!`.
|
334
316
|
|
335
317
|
*Rafael Mendonça França*
|
336
318
|
|
337
|
-
*
|
319
|
+
* Remove deprecated argument `name` from `#indexes`.
|
338
320
|
|
339
321
|
*Rafael Mendonça França*
|
340
322
|
|
341
|
-
*
|
323
|
+
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
|
342
324
|
|
343
325
|
*Rafael Mendonça França*
|
344
326
|
|
345
|
-
* Remove deprecated
|
346
|
-
and `ActiveRecord::StatementInvalid#original_exception`.
|
327
|
+
* Remove deprecated method `supports_primary_key?`.
|
347
328
|
|
348
329
|
*Rafael Mendonça França*
|
349
330
|
|
350
|
-
*
|
351
|
-
|
352
|
-
All the deprecations on those methods were removed.
|
331
|
+
* Remove deprecated method `supports_migrations?`.
|
353
332
|
|
354
333
|
*Rafael Mendonça França*
|
355
334
|
|
356
|
-
* Remove deprecated `
|
335
|
+
* Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
|
357
336
|
|
358
337
|
*Rafael Mendonça França*
|
359
338
|
|
360
|
-
*
|
339
|
+
* Raises when calling `lock!` in a dirty record.
|
361
340
|
|
362
341
|
*Rafael Mendonça França*
|
363
342
|
|
364
|
-
*
|
365
|
-
`config.active_record.time_zone_aware_types` is not explicitly set.
|
343
|
+
* Remove deprecated support to passing a class to `:class_name` on associations.
|
366
344
|
|
367
345
|
*Rafael Mendonça França*
|
368
346
|
|
369
|
-
* Remove deprecated
|
347
|
+
* Remove deprecated argument `default` from `index_name_exists?`.
|
370
348
|
|
371
349
|
*Rafael Mendonça França*
|
372
350
|
|
373
|
-
* Remove deprecated `
|
374
|
-
`activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes.
|
351
|
+
* Remove deprecated support to `quoted_id` when typecasting an Active Record object.
|
375
352
|
|
376
353
|
*Rafael Mendonça França*
|
377
354
|
|
378
|
-
*
|
379
|
-
|
380
|
-
Introduces `ActiveRecord::Tasks::DatabaseTasks.structure_(load|dump)_flags` to customize the
|
381
|
-
eventual commands run against the database, e.g. mysqldump/pg_dump.
|
382
|
-
|
383
|
-
*Kir Shatrov*
|
384
|
-
|
385
|
-
* Notifications see frozen SQL string.
|
386
|
-
|
387
|
-
Fixes #23774.
|
355
|
+
* Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
|
356
|
+
ar_internal_metadata's data for a test database.
|
388
357
|
|
389
|
-
|
358
|
+
Before:
|
359
|
+
```
|
360
|
+
$ RAILS_ENV=test rails dbconsole
|
361
|
+
> SELECT * FROM ar_internal_metadata;
|
362
|
+
key|value|created_at|updated_at
|
363
|
+
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
364
|
+
```
|
390
365
|
|
391
|
-
|
366
|
+
After:
|
367
|
+
```
|
368
|
+
$ RAILS_ENV=test rails dbconsole
|
369
|
+
> SELECT * FROM ar_internal_metadata;
|
370
|
+
key|value|created_at|updated_at
|
371
|
+
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
372
|
+
```
|
392
373
|
|
393
|
-
|
374
|
+
Fixes #26731.
|
394
375
|
|
395
|
-
*
|
396
|
-
|
397
|
-
*Kir Shatrov*
|
376
|
+
*bogdanvlviv*
|
398
377
|
|
399
|
-
*
|
400
|
-
column names.
|
378
|
+
* Fix longer sequence name detection for serial columns.
|
401
379
|
|
402
|
-
Fixes #
|
380
|
+
Fixes #28332.
|
403
381
|
|
404
382
|
*Ryuta Kamizono*
|
405
383
|
|
406
|
-
*
|
384
|
+
* MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
|
407
385
|
|
408
|
-
|
409
|
-
|
410
|
-
* Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted
|
411
|
-
or updated because it would violate a not null constraint.
|
386
|
+
Fixes #30894.
|
412
387
|
|
413
388
|
*Ryuta Kamizono*
|
414
389
|
|
415
|
-
*
|
416
|
-
|
417
|
-
Race conditions can occur when an ActiveRecord is destroyed
|
418
|
-
twice or destroyed and updated. The callbacks should only be
|
419
|
-
triggered once, similar to a SQL database trigger.
|
390
|
+
* Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
|
420
391
|
|
421
|
-
|
392
|
+
Fixes #30886.
|
422
393
|
|
423
|
-
*
|
424
|
-
|
425
|
-
*Iain Beeston*
|
394
|
+
*Ryuta Kamizono*
|
426
395
|
|
427
|
-
*
|
428
|
-
use the aliased attribute name if needed.
|
396
|
+
* PostgreSQL `tsrange` now preserves subsecond precision.
|
429
397
|
|
430
|
-
|
398
|
+
PostgreSQL 9.1+ introduced range types, and Rails added support for using
|
399
|
+
this datatype in Active Record. However, the serialization of
|
400
|
+
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
401
|
+
cast the bounds that make up the range. This led to subseconds being
|
402
|
+
dropped in SQL commands:
|
431
403
|
|
432
|
-
|
433
|
-
use the aliased attribute name if needed.
|
404
|
+
Before:
|
434
405
|
|
435
|
-
|
406
|
+
connection.type_cast(tsrange.serialize(range_value))
|
407
|
+
# => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
|
436
408
|
|
437
|
-
|
409
|
+
Now:
|
438
410
|
|
439
|
-
|
411
|
+
connection.type_cast(tsrange.serialize(range_value))
|
412
|
+
# => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
|
440
413
|
|
441
|
-
*
|
414
|
+
*Thomas Cannon*
|
442
415
|
|
443
|
-
*
|
444
|
-
|
445
|
-
casting behavior.
|
416
|
+
* Passing a `Set` to `Relation#where` now behaves the same as passing an
|
417
|
+
array.
|
446
418
|
|
447
419
|
*Sean Griffin*
|
448
420
|
|
449
|
-
*
|
421
|
+
* Use given algorithm while removing index from database.
|
450
422
|
|
451
|
-
Fixes #
|
423
|
+
Fixes #24190.
|
452
424
|
|
453
|
-
*
|
425
|
+
*Mehmet Emin İNAÇ*
|
454
426
|
|
455
|
-
*
|
427
|
+
* Update payload names for `sql.active_record` instrumentation to be
|
428
|
+
more descriptive.
|
456
429
|
|
457
|
-
|
430
|
+
Fixes #30586.
|
458
431
|
|
459
|
-
*
|
460
|
-
for unknown IDs with a better error message.
|
432
|
+
*Jeremy Green*
|
461
433
|
|
462
|
-
|
463
|
-
|
464
|
-
primary key.
|
434
|
+
* Add new error class `LockWaitTimeout` which will be raised
|
435
|
+
when lock wait timeout exceeded.
|
465
436
|
|
466
|
-
*
|
437
|
+
*Gabriel Courtemanche*
|
467
438
|
|
468
|
-
*
|
469
|
-
`uuid-ossp`'s UUID generation function.
|
439
|
+
* Remove deprecated `#migration_keys`.
|
470
440
|
|
471
|
-
*
|
441
|
+
*Ryuta Kamizono*
|
472
442
|
|
473
|
-
*
|
474
|
-
of `Article.category(true)` where `category` is a singular
|
475
|
-
association.
|
443
|
+
* Automatically guess the inverse associations for STI.
|
476
444
|
|
477
|
-
|
478
|
-
in #20888. Unfortunately the suggested alternative of
|
479
|
-
`article.reload.category` does not expose the same behavior.
|
445
|
+
*Yuichiro Kaneko*
|
480
446
|
|
481
|
-
|
482
|
-
singular associations. This method has the same semantics as
|
483
|
-
passing true to the association reader used to have.
|
447
|
+
* Ensure `sum` honors `distinct` on `has_many :through` associations
|
484
448
|
|
485
|
-
|
449
|
+
Fixes #16791.
|
486
450
|
|
487
|
-
*
|
488
|
-
constants defined in `ActiveRecord::Associations::Preloader`.
|
451
|
+
*Aaron Wortham*
|
489
452
|
|
490
|
-
|
453
|
+
* Add `binary` fixture helper method.
|
491
454
|
|
492
|
-
*
|
493
|
-
values for Postgres HStore columns.
|
455
|
+
*Atsushi Yoshida*
|
494
456
|
|
495
|
-
|
457
|
+
* When using `Relation#or`, extract the common conditions and put them before the OR condition.
|
496
458
|
|
497
|
-
*
|
459
|
+
*Maxime Handfield Lapointe*
|
498
460
|
|
499
|
-
*
|
461
|
+
* `Relation#or` now accepts two relations who have different values for
|
462
|
+
`references` only, as `references` can be implicitly called by `where`.
|
500
463
|
|
501
|
-
|
464
|
+
Fixes #29411.
|
502
465
|
|
503
|
-
|
504
|
-
{ size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
|
466
|
+
*Sean Griffin*
|
505
467
|
|
506
|
-
|
468
|
+
* `ApplicationRecord` is no longer generated when generating models. If you
|
469
|
+
need to generate it, it can be created with `rails g application_record`.
|
507
470
|
|
508
|
-
*
|
509
|
-
and `exists?`.
|
471
|
+
*Lisa Ugray*
|
510
472
|
|
511
|
-
|
512
|
-
for performance. We should not unscope the order in the case.
|
473
|
+
* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
|
513
474
|
|
514
475
|
*Ryuta Kamizono*
|
515
476
|
|
516
|
-
*
|
517
|
-
|
518
|
-
|
519
|
-
Fixes #24195.
|
520
|
-
|
521
|
-
*Sen Zhang*
|
477
|
+
* When a `has_one` association is destroyed by `dependent: destroy`,
|
478
|
+
`destroyed_by_association` will now be set to the reflection, matching the
|
479
|
+
behaviour of `has_many` associations.
|
522
480
|
|
523
|
-
*
|
524
|
-
|
525
|
-
*Cohen Carlisle*
|
526
|
-
|
527
|
-
* Improved partial writes with HABTM and has many through associations
|
528
|
-
to fire database query only if relation has been changed.
|
529
|
-
|
530
|
-
Fixes #19663.
|
531
|
-
|
532
|
-
*Mehmet Emin İNAÇ*
|
481
|
+
*Lisa Ugray*
|
533
482
|
|
534
|
-
*
|
535
|
-
`ActiveRecord::QueryMethods#select`.
|
483
|
+
* Fix `unscoped(where: [columns])` removing the wrong bind values
|
536
484
|
|
537
|
-
|
485
|
+
When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
|
486
|
+
bind values used by the `or` instead. (possibly other cases too)
|
538
487
|
|
539
|
-
|
488
|
+
```
|
489
|
+
Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
|
490
|
+
# Currently:
|
491
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
492
|
+
# With fix:
|
493
|
+
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
494
|
+
```
|
540
495
|
|
541
|
-
|
542
|
-
|
543
|
-
*bogdanvlviv*
|
544
|
-
|
545
|
-
* Fixed support for case insensitive comparisons of `text` columns in
|
546
|
-
PostgreSQL.
|
496
|
+
*Maxime Handfield Lapointe*
|
547
497
|
|
548
|
-
|
498
|
+
* Values constructed using multi-parameter assignment will now use the
|
499
|
+
post-type-cast value for rendering in single-field form inputs.
|
549
500
|
|
550
|
-
*
|
501
|
+
*Sean Griffin*
|
551
502
|
|
552
|
-
|
503
|
+
* `Relation#joins` is no longer affected by the target model's
|
504
|
+
`current_scope`, with the exception of `unscoped`.
|
553
505
|
|
554
|
-
|
555
|
-
to be updated is unchanged.
|
506
|
+
Fixes #29338.
|
556
507
|
|
557
|
-
|
508
|
+
*Sean Griffin*
|
558
509
|
|
559
|
-
|
510
|
+
* Change sqlite3 boolean serialization to use 1 and 0
|
560
511
|
|
561
|
-
|
512
|
+
SQLite natively recognizes 1 and 0 as true and false, but does not natively
|
513
|
+
recognize 't' and 'f' as was previously serialized.
|
562
514
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
`Errors#messages` storage.
|
515
|
+
This change in serialization requires a migration of stored boolean data
|
516
|
+
for SQLite databases, so it's implemented behind a configuration flag
|
517
|
+
whose default false value is deprecated.
|
567
518
|
|
568
|
-
|
569
|
-
cause a small breaking change because in those cases the details could
|
570
|
-
be accessed as strings keys but now it can not.
|
519
|
+
*Lisa Ugray*
|
571
520
|
|
572
|
-
|
521
|
+
* Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
|
522
|
+
`in_batches`).
|
573
523
|
|
574
|
-
|
524
|
+
Previously, records would be fetched in batches, but all records would be retained in memory
|
525
|
+
until the end of the request or job.
|
575
526
|
|
576
|
-
*
|
577
|
-
in a non-dirty state with no attribute changes.
|
527
|
+
*Eugene Kenny*
|
578
528
|
|
579
|
-
|
529
|
+
* Prevent errors raised by `sql.active_record` notification subscribers from being converted into
|
530
|
+
`ActiveRecord::StatementInvalid` exceptions.
|
580
531
|
|
581
|
-
*
|
532
|
+
*Dennis Taylor*
|
582
533
|
|
583
|
-
*
|
584
|
-
saying the connection is closed rather than an undefined method error message.
|
534
|
+
* Fix eager loading/preloading association with scope including joins.
|
585
535
|
|
586
|
-
|
536
|
+
Fixes #28324.
|
587
537
|
|
588
|
-
*
|
589
|
-
in the array.
|
538
|
+
*Ryuta Kamizono*
|
590
539
|
|
591
|
-
|
540
|
+
* Fix transactions to apply state to child transactions
|
592
541
|
|
593
|
-
|
542
|
+
Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
|
543
|
+
inner transaction would still be marked as persisted.
|
594
544
|
|
595
|
-
|
596
|
-
|
545
|
+
This change fixes that by applying the state of the parent transaction to the child transaction when the
|
546
|
+
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
597
547
|
|
598
|
-
|
548
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
599
549
|
|
600
|
-
|
550
|
+
* Deprecate `set_state` method in `TransactionState`
|
601
551
|
|
602
|
-
|
603
|
-
|
552
|
+
Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
|
553
|
+
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
554
|
+
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
604
555
|
|
605
|
-
*
|
556
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
606
557
|
|
607
|
-
*
|
558
|
+
* Deprecate delegating to `arel` in `Relation`.
|
608
559
|
|
609
|
-
*
|
610
|
-
|
611
|
-
* Avoid loading records from database when they are already loaded using
|
612
|
-
the `pluck` method on a collection.
|
560
|
+
*Ryuta Kamizono*
|
613
561
|
|
614
|
-
|
562
|
+
* Fix eager loading to respect `store_full_sti_class` setting.
|
615
563
|
|
616
564
|
*Ryuta Kamizono*
|
617
565
|
|
618
|
-
*
|
619
|
-
|
620
|
-
|
621
|
-
Strict mode controls how MySQL handles invalid or missing values in
|
622
|
-
data-change statements such as INSERT or UPDATE. If strict mode is not
|
623
|
-
in effect, MySQL inserts adjusted values for invalid or missing values
|
624
|
-
and produces warnings.
|
625
|
-
|
626
|
-
def test_mysql_not_null_defaults_non_strict
|
627
|
-
using_strict(false) do
|
628
|
-
with_mysql_not_null_table do |klass|
|
629
|
-
record = klass.new
|
630
|
-
assert_nil record.non_null_integer
|
631
|
-
assert_nil record.non_null_string
|
632
|
-
assert_nil record.non_null_text
|
633
|
-
assert_nil record.non_null_blob
|
634
|
-
|
635
|
-
record.save!
|
636
|
-
record.reload
|
637
|
-
|
638
|
-
assert_equal 0, record.non_null_integer
|
639
|
-
assert_equal "", record.non_null_string
|
640
|
-
assert_equal "", record.non_null_text
|
641
|
-
assert_equal "", record.non_null_blob
|
642
|
-
end
|
643
|
-
end
|
644
|
-
end
|
645
|
-
|
646
|
-
https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
|
566
|
+
* Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
|
567
|
+
without being connected.
|
647
568
|
|
648
|
-
*
|
569
|
+
*Tsukasa Oishi*
|
649
570
|
|
650
|
-
*
|
651
|
-
|
652
|
-
|
571
|
+
* Previously, when building records using a `has_many :through` association,
|
572
|
+
if the child records were deleted before the parent was saved, they would
|
573
|
+
still be persisted. Now, if child records are deleted before the parent is saved
|
574
|
+
on a `has_many :through` association, the child records will not be persisted.
|
653
575
|
|
654
|
-
|
576
|
+
*Tobias Kraze*
|
655
577
|
|
656
|
-
|
578
|
+
* Merging two relations representing nested joins no longer transforms the joins of
|
579
|
+
the merged relation into LEFT OUTER JOIN. Example to clarify:
|
657
580
|
|
658
|
-
|
581
|
+
```
|
582
|
+
Author.joins(:posts).merge(Post.joins(:comments))
|
583
|
+
# Before the change:
|
584
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
|
659
585
|
|
660
|
-
|
586
|
+
# After the change:
|
587
|
+
#=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
|
588
|
+
```
|
661
589
|
|
662
|
-
|
663
|
-
force a DISTINCT. This solves issues when using count after a left_joins.
|
590
|
+
TODO: Add to the Rails 5.2 upgrade guide
|
664
591
|
|
665
592
|
*Maxime Handfield Lapointe*
|
666
593
|
|
667
|
-
*
|
668
|
-
`
|
594
|
+
* `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
|
595
|
+
`locking_column`, without default value, is null in the database.
|
669
596
|
|
670
|
-
*
|
597
|
+
*bogdanvlviv*
|
671
598
|
|
672
|
-
*
|
673
|
-
|
599
|
+
* Fix destroying existing object does not work well when optimistic locking enabled and
|
600
|
+
`locking_column` is null in the database.
|
674
601
|
|
675
|
-
|
602
|
+
*bogdanvlviv*
|
676
603
|
|
677
|
-
|
604
|
+
* Use bulk INSERT to insert fixtures for better performance.
|
678
605
|
|
679
|
-
*
|
606
|
+
*Kir Shatrov*
|
680
607
|
|
681
|
-
|
608
|
+
* Prevent creation of bind param if casted value is nil.
|
682
609
|
|
683
|
-
*
|
684
|
-
database.
|
610
|
+
*Ryuta Kamizono*
|
685
611
|
|
686
|
-
|
612
|
+
* Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.
|
687
613
|
|
688
|
-
*
|
614
|
+
*Ryuta Kamizono*
|
689
615
|
|
690
|
-
|
616
|
+
* Loading model schema from database is now thread-safe.
|
691
617
|
|
692
|
-
|
618
|
+
Fixes #28589.
|
693
619
|
|
694
|
-
*
|
620
|
+
*Vikrant Chaudhary*, *David Abdemoulaie*
|
695
621
|
|
696
|
-
* Add
|
622
|
+
* Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
|
623
|
+
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
624
|
+
that does not include a timestamp any more.
|
697
625
|
|
698
|
-
|
699
|
-
|
626
|
+
NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
|
627
|
+
until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
|
700
628
|
|
701
|
-
|
629
|
+
*DHH*
|
702
630
|
|
703
|
-
|
631
|
+
* Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump
|
704
632
|
|
705
|
-
*
|
706
|
-
the current `error_on_ignored_order`.
|
633
|
+
*Rusty Geldmacher*, *Guillermo Iguaran*
|
707
634
|
|
708
|
-
|
635
|
+
* Add type caster to `RuntimeReflection#alias_name`
|
709
636
|
|
710
|
-
|
637
|
+
Fixes #28959.
|
711
638
|
|
712
|
-
|
713
|
-
# ...
|
714
|
-
end
|
639
|
+
*Jon Moss*
|
715
640
|
|
716
|
-
|
641
|
+
* Deprecate `supports_statement_cache?`.
|
717
642
|
|
718
|
-
*
|
643
|
+
*Ryuta Kamizono*
|
719
644
|
|
720
|
-
*
|
721
|
-
the
|
645
|
+
* Raise error `UnknownMigrationVersionError` on the movement of migrations
|
646
|
+
when the current migration does not exist.
|
722
647
|
|
723
|
-
|
648
|
+
*bogdanvlviv*
|
724
649
|
|
725
|
-
|
650
|
+
* Fix `bin/rails db:forward` first migration.
|
726
651
|
|
727
|
-
*
|
728
|
-
the resulting output is actually up to 20 characters, not
|
729
|
-
effectively 17 to leave room for the default "...".
|
730
|
-
Also call `#parameterize` before `#truncate` and make the
|
731
|
-
`separator: /-/` to maximize the information included in the
|
732
|
-
output.
|
652
|
+
*bogdanvlviv*
|
733
653
|
|
734
|
-
|
654
|
+
* Support Descending Indexes for MySQL.
|
735
655
|
|
736
|
-
|
656
|
+
MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
|
657
|
+
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
737
658
|
|
738
|
-
*
|
739
|
-
same connection to two threads.
|
659
|
+
*Ryuta Kamizono*
|
740
660
|
|
741
|
-
|
661
|
+
* Fix inconsistency with changed attributes when overriding Active Record attribute reader.
|
742
662
|
|
743
|
-
*
|
663
|
+
*bogdanvlviv*
|
744
664
|
|
745
|
-
*
|
746
|
-
|
747
|
-
cases.
|
665
|
+
* When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
|
666
|
+
Previously this method always returned an empty array.
|
748
667
|
|
749
668
|
*Kevin McPhillips*
|
750
669
|
|
751
|
-
* Removed the unused methods `ActiveRecord::Base.connection_id` and
|
752
|
-
`ActiveRecord::Base.connection_id=`.
|
753
|
-
|
754
|
-
*Sean Griffin*
|
755
|
-
|
756
|
-
* Ensure hashes can be assigned to attributes created using `composed_of`.
|
757
|
-
|
758
|
-
Fixes #25210.
|
759
|
-
|
760
|
-
*Sean Griffin*
|
761
|
-
|
762
|
-
* Fix logging edge case where if an attribute was of the binary type and
|
763
|
-
was provided as a Hash.
|
764
|
-
|
765
|
-
*Jon Moss*
|
766
|
-
|
767
|
-
* Handle JSON deserialization correctly if the column default from database
|
768
|
-
adapter returns `''` instead of `nil`.
|
769
|
-
|
770
|
-
*Johannes Opper*
|
771
|
-
|
772
|
-
* Introduce new Active Record transaction error classes for catching
|
773
|
-
transaction serialization failures or deadlocks.
|
774
|
-
|
775
|
-
*Erol Fornoles*
|
776
|
-
|
777
|
-
* PostgreSQL: Fix `db:structure:load` silent failure on SQL error.
|
778
|
-
|
779
|
-
The command line flag `-v ON_ERROR_STOP=1` should be used
|
780
|
-
when invoking `psql` to make sure errors are not suppressed.
|
781
|
-
|
782
|
-
Example:
|
783
|
-
|
784
|
-
psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db
|
785
|
-
|
786
|
-
Fixes #23818.
|
787
|
-
|
788
|
-
*Ralin Chimev*
|
789
|
-
|
790
670
|
|
791
|
-
Please check [5-
|
671
|
+
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
|