activerecord 5.2.3.rc1 → 6.0.0.beta1
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 +326 -696
- data/MIT-LICENSE +3 -1
- data/README.rdoc +1 -1
- data/examples/performance.rb +1 -1
- data/lib/active_record.rb +2 -1
- data/lib/active_record/aggregations.rb +4 -2
- data/lib/active_record/associations.rb +16 -12
- data/lib/active_record/associations/association.rb +35 -19
- data/lib/active_record/associations/association_scope.rb +4 -6
- data/lib/active_record/associations/belongs_to_association.rb +36 -42
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +0 -4
- data/lib/active_record/associations/builder/belongs_to.rb +14 -50
- data/lib/active_record/associations/builder/collection_association.rb +1 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +17 -38
- data/lib/active_record/associations/collection_association.rb +11 -25
- data/lib/active_record/associations/collection_proxy.rb +32 -6
- data/lib/active_record/associations/foreign_association.rb +7 -0
- data/lib/active_record/associations/has_many_association.rb +1 -1
- data/lib/active_record/associations/has_many_through_association.rb +14 -14
- data/lib/active_record/associations/has_one_association.rb +28 -30
- data/lib/active_record/associations/has_one_through_association.rb +5 -5
- data/lib/active_record/associations/join_dependency.rb +15 -20
- data/lib/active_record/associations/join_dependency/join_association.rb +6 -0
- data/lib/active_record/associations/join_dependency/join_part.rb +2 -2
- data/lib/active_record/associations/preloader.rb +31 -28
- data/lib/active_record/associations/preloader/association.rb +1 -2
- data/lib/active_record/associations/singular_association.rb +2 -16
- data/lib/active_record/attribute_assignment.rb +7 -10
- data/lib/active_record/attribute_methods.rb +34 -56
- data/lib/active_record/attribute_methods/dirty.rb +64 -26
- data/lib/active_record/attribute_methods/primary_key.rb +8 -7
- data/lib/active_record/attribute_methods/read.rb +16 -48
- data/lib/active_record/attribute_methods/serialization.rb +1 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +1 -1
- data/lib/active_record/attribute_methods/write.rb +15 -16
- data/lib/active_record/autosave_association.rb +1 -1
- data/lib/active_record/base.rb +2 -2
- data/lib/active_record/callbacks.rb +3 -17
- data/lib/active_record/collection_cache_key.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +10 -14
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +25 -84
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +14 -11
- data/lib/active_record/connection_adapters/abstract/quoting.rb +5 -11
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +15 -11
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +30 -13
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +0 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +40 -26
- data/lib/active_record/connection_adapters/abstract/transaction.rb +81 -52
- data/lib/active_record/connection_adapters/abstract_adapter.rb +95 -31
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +65 -90
- data/lib/active_record/connection_adapters/connection_specification.rb +52 -42
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +5 -9
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +29 -7
- data/lib/active_record/connection_adapters/mysql/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +3 -4
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +65 -10
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +8 -4
- data/lib/active_record/connection_adapters/postgresql/column.rb +1 -2
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +16 -1
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +1 -4
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +9 -7
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +4 -4
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +11 -36
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +9 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +38 -20
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +75 -56
- data/lib/active_record/connection_adapters/schema_cache.rb +5 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +5 -5
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +14 -9
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +93 -60
- data/lib/active_record/connection_handling.rb +132 -26
- data/lib/active_record/core.rb +76 -43
- data/lib/active_record/counter_cache.rb +4 -29
- data/lib/active_record/database_configurations.rb +184 -0
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +74 -0
- data/lib/active_record/enum.rb +22 -7
- data/lib/active_record/errors.rb +24 -21
- data/lib/active_record/explain.rb +1 -1
- data/lib/active_record/fixture_set/model_metadata.rb +33 -0
- data/lib/active_record/fixture_set/render_context.rb +17 -0
- data/lib/active_record/fixture_set/table_row.rb +153 -0
- data/lib/active_record/fixture_set/table_rows.rb +47 -0
- data/lib/active_record/fixtures.rb +140 -472
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +12 -2
- data/lib/active_record/integration.rb +56 -16
- data/lib/active_record/internal_metadata.rb +5 -1
- data/lib/active_record/locking/optimistic.rb +2 -2
- data/lib/active_record/locking/pessimistic.rb +3 -3
- data/lib/active_record/log_subscriber.rb +7 -26
- data/lib/active_record/migration.rb +38 -37
- data/lib/active_record/migration/command_recorder.rb +35 -5
- data/lib/active_record/migration/compatibility.rb +34 -16
- data/lib/active_record/model_schema.rb +30 -9
- data/lib/active_record/nested_attributes.rb +2 -2
- data/lib/active_record/no_touching.rb +7 -0
- data/lib/active_record/persistence.rb +18 -7
- data/lib/active_record/query_cache.rb +11 -4
- data/lib/active_record/querying.rb +19 -11
- data/lib/active_record/railtie.rb +71 -42
- data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
- data/lib/active_record/railties/controller_runtime.rb +30 -35
- data/lib/active_record/railties/databases.rake +94 -43
- data/lib/active_record/reflection.rb +46 -34
- data/lib/active_record/relation.rb +150 -69
- data/lib/active_record/relation/batches.rb +13 -10
- data/lib/active_record/relation/calculations.rb +34 -23
- data/lib/active_record/relation/delegation.rb +4 -13
- data/lib/active_record/relation/finder_methods.rb +12 -25
- data/lib/active_record/relation/merger.rb +2 -6
- data/lib/active_record/relation/predicate_builder.rb +4 -6
- data/lib/active_record/relation/predicate_builder/array_handler.rb +5 -4
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +1 -4
- data/lib/active_record/relation/predicate_builder/base_handler.rb +1 -2
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +1 -2
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -4
- data/lib/active_record/relation/predicate_builder/range_handler.rb +3 -23
- data/lib/active_record/relation/query_attribute.rb +15 -12
- data/lib/active_record/relation/query_methods.rb +26 -47
- data/lib/active_record/relation/where_clause.rb +4 -0
- data/lib/active_record/relation/where_clause_factory.rb +1 -2
- data/lib/active_record/result.rb +30 -11
- data/lib/active_record/sanitization.rb +2 -39
- data/lib/active_record/schema.rb +1 -10
- data/lib/active_record/schema_dumper.rb +12 -6
- data/lib/active_record/schema_migration.rb +4 -0
- data/lib/active_record/scoping.rb +9 -8
- data/lib/active_record/scoping/default.rb +8 -1
- data/lib/active_record/scoping/named.rb +10 -14
- data/lib/active_record/statement_cache.rb +30 -3
- data/lib/active_record/store.rb +39 -8
- data/lib/active_record/table_metadata.rb +1 -4
- data/lib/active_record/tasks/database_tasks.rb +89 -23
- data/lib/active_record/tasks/mysql_database_tasks.rb +2 -4
- data/lib/active_record/tasks/postgresql_database_tasks.rb +5 -7
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -8
- data/lib/active_record/test_databases.rb +38 -0
- data/lib/active_record/test_fixtures.rb +224 -0
- data/lib/active_record/timestamp.rb +4 -6
- data/lib/active_record/transactions.rb +2 -21
- data/lib/active_record/translation.rb +1 -1
- data/lib/active_record/type.rb +3 -4
- data/lib/active_record/type/adapter_specific_registry.rb +1 -8
- data/lib/active_record/type_caster/connection.rb +1 -6
- data/lib/active_record/type_caster/map.rb +1 -4
- data/lib/active_record/validations/uniqueness.rb +13 -25
- data/lib/arel.rb +44 -0
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes.rb +67 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +63 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +44 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values.rb +16 -0
- data/lib/arel/nodes/values_list.rb +24 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +257 -0
- data/lib/arel/select_manager.rb +271 -0
- data/lib/arel/table.rb +110 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/visitors/depth_first.rb +199 -0
- data/lib/arel/visitors/dot.rb +292 -0
- data/lib/arel/visitors/ibm_db.rb +21 -0
- data/lib/arel/visitors/informix.rb +56 -0
- data/lib/arel/visitors/mssql.rb +143 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +159 -0
- data/lib/arel/visitors/oracle12.rb +67 -0
- data/lib/arel/visitors/postgresql.rb +116 -0
- data/lib/arel/visitors/sqlite.rb +39 -0
- data/lib/arel/visitors/to_sql.rb +913 -0
- data/lib/arel/visitors/visitor.rb +42 -0
- data/lib/arel/visitors/where_sql.rb +23 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/rails/generators/active_record/migration.rb +14 -1
- data/lib/rails/generators/active_record/migration/migration_generator.rb +2 -5
- data/lib/rails/generators/active_record/model/model_generator.rb +1 -0
- metadata +101 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c6ced19e10b6f6d4eb33ac9745ce89e3b4ee124c02080e582abe07b9e5ac9a6
|
4
|
+
data.tar.gz: d0267bc9be2b86eea525eebd296a3eba6dd098ae154c6ec6b91978164e91a898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa88cf19b4df3cafcb246c31b104bc0df9a231f131d8c046fa20adb20f06285da1379a55ee82b3ef18e313212b4ae88f8f35752ae99bffcd0e669ca6f255b1d
|
7
|
+
data.tar.gz: 37f5229326765cb0c16f1501c4f3ade8594166a7999402f1016e23dfc9ec01ca009fa6abaf6e0751e288d533393592fe1db64fd0301c1ae1e1bfe5ff4c08d010
|
data/CHANGELOG.md
CHANGED
@@ -1,937 +1,567 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Remove deprecated `#set_state` from the transaction object.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
*Juani Villarejo*
|
8
|
-
|
9
|
-
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
10
|
-
|
11
|
-
*Ryuta Kamizono*
|
12
|
-
|
13
|
-
* Don't allow `where` with invalid value matches to nil values.
|
14
|
-
|
15
|
-
Fixes #33624.
|
16
|
-
|
17
|
-
*Ryuta Kamizono*
|
18
|
-
|
19
|
-
* Restore an ability that class level `update` without giving ids.
|
20
|
-
|
21
|
-
Fixes #34743.
|
22
|
-
|
23
|
-
*Ryuta Kamizono*
|
24
|
-
|
25
|
-
* Fix join table column quoting with SQLite.
|
26
|
-
|
27
|
-
*Gannon McGibbon*
|
28
|
-
|
29
|
-
* Ensure that `delete_all` on collection proxy returns affected count.
|
30
|
-
|
31
|
-
*Ryuta Kamizono*
|
32
|
-
|
33
|
-
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
34
|
-
|
35
|
-
*Gannon McGibbon*
|
36
|
-
|
37
|
-
|
38
|
-
## Rails 5.2.2.1 (March 11, 2019) ##
|
39
|
-
|
40
|
-
* No changes.
|
41
|
-
|
42
|
-
|
43
|
-
## Rails 5.2.2 (December 04, 2018) ##
|
44
|
-
|
45
|
-
* Do not ignore the scoping with query methods in the scope block.
|
46
|
-
|
47
|
-
*Ryuta Kamizono*
|
48
|
-
|
49
|
-
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
50
|
-
|
51
|
-
*Gannon McGibbon*
|
52
|
-
|
53
|
-
* Allow spaces in postgres table names.
|
54
|
-
|
55
|
-
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
|
56
|
-
adapter.
|
57
|
-
|
58
|
-
*Gannon McGibbon*
|
59
|
-
|
60
|
-
* Cached columns_hash fields should be excluded from ResultSet#column_types
|
61
|
-
|
62
|
-
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
63
|
-
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
class DeveloperName < ActiveRecord::Type::String
|
67
|
-
def deserialize(value)
|
68
|
-
"Developer: #{value}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class AttributedDeveloper < ActiveRecord::Base
|
73
|
-
self.table_name = "developers"
|
74
|
-
|
75
|
-
attribute :name, DeveloperName.new
|
76
|
-
|
77
|
-
self.ignored_columns += ["name"]
|
78
|
-
end
|
79
|
-
|
80
|
-
developer = AttributedDeveloper.create
|
81
|
-
developer.update_column :name, "name"
|
82
|
-
|
83
|
-
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
84
|
-
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
85
|
-
```
|
86
|
-
|
87
|
-
*Dmitry Tsepelev*
|
88
|
-
|
89
|
-
* Values of enum are frozen, raising an error when attempting to modify them.
|
90
|
-
|
91
|
-
*Emmanuel Byrd*
|
92
|
-
|
93
|
-
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
94
|
-
if the attribute does not exist.
|
95
|
-
|
96
|
-
*Sean Griffin*
|
97
|
-
|
98
|
-
* Do not use prepared statement in queries that have a large number of binds.
|
99
|
-
|
100
|
-
*Ryuta Kamizono*
|
101
|
-
|
102
|
-
* Fix query cache to load before first request.
|
103
|
-
|
104
|
-
*Eileen M. Uchitelle*
|
5
|
+
*Rafael Mendonça França*
|
105
6
|
|
106
|
-
*
|
7
|
+
* Remove deprecated `#supports_statement_cache?` from the database adapters.
|
107
8
|
|
108
|
-
|
9
|
+
*Rafael Mendonça França*
|
109
10
|
|
110
|
-
|
11
|
+
* Remove deprecated `#insert_fixtures` from the database adapters.
|
111
12
|
|
112
|
-
*
|
13
|
+
*Rafael Mendonça França*
|
113
14
|
|
114
|
-
|
15
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
|
115
16
|
|
116
|
-
*
|
17
|
+
*Rafael Mendonça França*
|
117
18
|
|
118
|
-
|
19
|
+
* Do not allow passing the column name to `sum` when a block is passed.
|
119
20
|
|
120
|
-
*
|
21
|
+
*Rafael Mendonça França*
|
121
22
|
|
122
|
-
|
23
|
+
* Do not allow passing the column name to `count` when a block is passed.
|
123
24
|
|
124
|
-
*
|
25
|
+
*Rafael Mendonça França*
|
125
26
|
|
126
|
-
|
27
|
+
* Remove delegation of missing methods in a relation to arel.
|
127
28
|
|
128
|
-
*
|
29
|
+
*Rafael Mendonça França*
|
129
30
|
|
130
|
-
|
31
|
+
* Remove delegation of missing methods in a relation to private methods of the class.
|
131
32
|
|
132
|
-
*
|
33
|
+
*Rafael Mendonça França*
|
133
34
|
|
134
|
-
|
35
|
+
* Deprecate `config.activerecord.sqlite3.represent_boolean_as_integer`.
|
135
36
|
|
136
|
-
*
|
37
|
+
*Rafael Mendonça França*
|
137
38
|
|
138
|
-
|
39
|
+
* Change `SQLite3Adapter` to always represent boolean values as integers.
|
139
40
|
|
140
|
-
*
|
41
|
+
*Rafael Mendonça França*
|
141
42
|
|
142
|
-
|
43
|
+
* Remove ability to specify a timestamp name for `#cache_key`.
|
143
44
|
|
45
|
+
*Rafael Mendonça França*
|
144
46
|
|
145
|
-
|
47
|
+
* Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
|
146
48
|
|
147
|
-
*
|
49
|
+
*Rafael Mendonça França*
|
148
50
|
|
51
|
+
* Remove deprecated `expand_hash_conditions_for_aggregates`.
|
149
52
|
|
150
|
-
|
53
|
+
*Rafael Mendonça França*
|
151
54
|
|
152
|
-
*
|
55
|
+
* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
|
153
56
|
|
154
|
-
|
57
|
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
|
155
58
|
|
156
|
-
*
|
59
|
+
*Laerti Papa*
|
157
60
|
|
158
|
-
*
|
61
|
+
* Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
|
159
62
|
|
160
|
-
*
|
63
|
+
*Gannon McGibbon*
|
161
64
|
|
162
|
-
*
|
65
|
+
* Add support for endless ranges introduces in Ruby 2.6.
|
163
66
|
|
164
|
-
*
|
67
|
+
*Greg Navis*
|
165
68
|
|
166
|
-
*
|
69
|
+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
|
167
70
|
|
168
71
|
*Ryuta Kamizono*
|
169
72
|
|
170
|
-
*
|
73
|
+
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
|
171
74
|
|
172
|
-
|
75
|
+
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
|
76
|
+
format for InnoDB tables. The default setting is `DYNAMIC`.
|
77
|
+
The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
|
173
78
|
|
174
79
|
*Ryuta Kamizono*
|
175
80
|
|
176
|
-
* Fix
|
177
|
-
|
178
|
-
*Brian Durand*
|
179
|
-
|
180
|
-
* Fix parent record should not get saved with duplicate children records.
|
181
|
-
|
182
|
-
Fixes #32940.
|
183
|
-
|
184
|
-
*Santosh Wadghule*
|
185
|
-
|
186
|
-
* Fix that association's after_touch is not called with counter cache.
|
81
|
+
* Fix join table column quoting with SQLite.
|
187
82
|
|
188
|
-
|
83
|
+
*Gannon McGibbon*
|
189
84
|
|
190
|
-
|
85
|
+
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
191
86
|
|
192
|
-
*
|
87
|
+
*Alfred Dominic*
|
193
88
|
|
194
|
-
|
89
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
195
90
|
|
196
91
|
*Ryuta Kamizono*
|
197
92
|
|
198
|
-
*
|
199
|
-
|
200
|
-
*Jolyon Pawlyn*
|
201
|
-
|
202
|
-
* Fix that building record with assigning multiple has_one associations
|
203
|
-
wrongly persists through record.
|
204
|
-
|
205
|
-
Fixes #32511.
|
206
|
-
|
207
|
-
*Sam DeCesare*
|
93
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
208
94
|
|
209
|
-
*
|
210
|
-
query cache.
|
95
|
+
*Gannon McGibbon*
|
211
96
|
|
212
|
-
|
97
|
+
* Add the ability to prevent writes to a database for the duration of a block.
|
213
98
|
|
99
|
+
Allows the application to prevent writes to a database. This can be useful when
|
100
|
+
you're building out multiple databases and want to make sure you're not sending
|
101
|
+
writes when you want a read.
|
214
102
|
|
215
|
-
|
103
|
+
If `while_preventing_writes` is called and the query is considered a write
|
104
|
+
query the database will raise an exception regardless of whether the database
|
105
|
+
user is able to write.
|
216
106
|
|
217
|
-
|
107
|
+
This is not meant to be a catch-all for write queries but rather a way to enforce
|
108
|
+
read-only queries without opening a second connection. One purpose of this is to
|
109
|
+
catch accidental writes, not all writes.
|
218
110
|
|
219
|
-
*
|
111
|
+
*Eileen M. Uchitelle*
|
220
112
|
|
221
|
-
*
|
113
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
222
114
|
|
223
|
-
|
224
|
-
have a specified precision then on assignment the value is rounded to
|
225
|
-
that precision. This behavior is now applied to time columns as well.
|
115
|
+
*Gannon McGibbon*
|
226
116
|
|
227
|
-
|
117
|
+
* Allow spaces in postgres table names.
|
228
118
|
|
229
|
-
|
119
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
|
230
120
|
|
231
|
-
*
|
121
|
+
*Gannon McGibbon*
|
232
122
|
|
233
|
-
|
234
|
-
because until #24542 the quoting for time columns didn't remove the date
|
235
|
-
component. To ensure that values are consistent we now normalize the
|
236
|
-
date component to 2001-01-01 on reading and writing.
|
123
|
+
* Cached columns_hash fields should be excluded from ResultSet#column_types
|
237
124
|
|
238
|
-
|
125
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
126
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
239
127
|
|
240
|
-
|
128
|
+
```ruby
|
129
|
+
class DeveloperName < ActiveRecord::Type::String
|
130
|
+
def deserialize(value)
|
131
|
+
"Developer: #{value}"
|
132
|
+
end
|
133
|
+
end
|
241
134
|
|
242
|
-
|
243
|
-
|
244
|
-
date component is removed irrespective of what the date is.
|
135
|
+
class AttributedDeveloper < ActiveRecord::Base
|
136
|
+
self.table_name = "developers"
|
245
137
|
|
246
|
-
|
138
|
+
attribute :name, DeveloperName.new
|
247
139
|
|
248
|
-
|
249
|
-
|
140
|
+
self.ignored_columns += ["name"]
|
141
|
+
end
|
250
142
|
|
251
|
-
|
143
|
+
developer = AttributedDeveloper.create
|
144
|
+
developer.update_column :name, "name"
|
252
145
|
|
253
|
-
|
146
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
147
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
148
|
+
```
|
254
149
|
|
255
|
-
*
|
150
|
+
*Dmitry Tsepelev*
|
256
151
|
|
257
|
-
|
152
|
+
* Make the implicit order column configurable.
|
258
153
|
|
259
|
-
|
154
|
+
When calling ordered finder methods such as +first+ or +last+ without an
|
155
|
+
explicit order clause, ActiveRecord sorts records by primary key. This can
|
156
|
+
result in unpredictable and surprising behaviour when the primary key is
|
157
|
+
not an auto-incrementing integer, for example when it's a UUID. This change
|
158
|
+
makes it possible to override the column used for implicit ordering such
|
159
|
+
that +first+ and +last+ will return more predictable results.
|
260
160
|
|
261
|
-
|
161
|
+
Example:
|
262
162
|
|
263
|
-
|
264
|
-
|
265
|
-
|
163
|
+
class Project < ActiveRecord::Base
|
164
|
+
self.implicit_order_column = "created_at"
|
165
|
+
end
|
266
166
|
|
267
|
-
|
167
|
+
*Tekin Suleyman*
|
268
168
|
|
269
|
-
|
169
|
+
* Bump minimum PostgreSQL version to 9.3.
|
270
170
|
|
271
|
-
*
|
171
|
+
*Yasuo Honda*
|
272
172
|
|
273
|
-
|
173
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
274
174
|
|
275
|
-
*
|
175
|
+
*Emmanuel Byrd*
|
276
176
|
|
277
|
-
*
|
177
|
+
* Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
|
278
178
|
|
279
|
-
|
179
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
|
280
180
|
|
281
|
-
|
282
|
-
Using a `Relation` for performing queries is the prefered API.
|
181
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
|
283
182
|
|
284
|
-
|
183
|
+
Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
|
285
184
|
|
286
|
-
|
185
|
+
Example:
|
287
186
|
|
288
187
|
```
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
188
|
+
class MySubclassedError < ActiveRecord::StatementInvalid
|
189
|
+
def initialize(message, sql:, binds:)
|
190
|
+
super(message, sql: sql, binds: binds)
|
191
|
+
end
|
192
|
+
end
|
294
193
|
```
|
295
194
|
|
296
|
-
|
297
|
-
|
298
|
-
*Yutaro Kanagawa*
|
299
|
-
|
300
|
-
* Fix `count(:all)` with eager loading and having an order other than the driving table.
|
301
|
-
|
302
|
-
Fixes #31783.
|
303
|
-
|
304
|
-
*Ryuta Kamizono*
|
305
|
-
|
306
|
-
* Clear the transaction state when an Active Record object is duped.
|
307
|
-
|
308
|
-
Fixes #31670.
|
309
|
-
|
310
|
-
*Yuriy Ustushenko*
|
311
|
-
|
312
|
-
* Support for PostgreSQL foreign tables.
|
313
|
-
|
314
|
-
*fatkodima*
|
315
|
-
|
316
|
-
* Fix relation merger issue with `left_outer_joins`.
|
317
|
-
|
318
|
-
*Mehmet Emin İNAÇ*
|
319
|
-
|
320
|
-
* Don't allow destroyed object mutation after `save` or `save!` is called.
|
321
|
-
|
322
|
-
*Ryuta Kamizono*
|
323
|
-
|
324
|
-
* Take into account association conditions when deleting through records.
|
325
|
-
|
326
|
-
Fixes #18424.
|
327
|
-
|
328
|
-
*Piotr Jakubowski*
|
195
|
+
*Gannon McGibbon*
|
329
196
|
|
330
|
-
*
|
197
|
+
* Add an `:if_not_exists` option to `create_table`.
|
331
198
|
|
332
|
-
|
199
|
+
Example:
|
333
200
|
|
334
|
-
|
335
|
-
|
336
|
-
has_many :books, through: :author
|
337
|
-
has_many :subscriptions, through: :books
|
201
|
+
create_table :posts, if_not_exists: true do |t|
|
202
|
+
t.string :title
|
338
203
|
end
|
339
204
|
|
340
|
-
|
341
|
-
has_one :post
|
342
|
-
has_many :books
|
343
|
-
has_many :subscriptions, through: :books
|
344
|
-
end
|
205
|
+
That would execute:
|
345
206
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
end
|
207
|
+
CREATE TABLE IF NOT EXISTS posts (
|
208
|
+
...
|
209
|
+
)
|
350
210
|
|
351
|
-
|
352
|
-
|
353
|
-
end
|
211
|
+
If the table already exists, `if_not_exists: false` (the default) raises an
|
212
|
+
exception whereas `if_not_exists: true` does nothing.
|
354
213
|
|
355
|
-
|
214
|
+
*fatkodima*, *Stefan Kanev*
|
356
215
|
|
357
|
-
|
216
|
+
* Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
|
358
217
|
|
359
|
-
|
218
|
+
*Christophe Maximin*
|
360
219
|
|
361
|
-
|
362
|
-
just like it would if `post` were persisted.
|
220
|
+
* Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
|
363
221
|
|
364
|
-
|
222
|
+
*Gannon McGibbon*
|
365
223
|
|
366
|
-
|
224
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
225
|
+
if the attribute does not exist.
|
367
226
|
|
368
|
-
*
|
369
|
-
The `first(n)` finder now respects the `limit()`, making it consistent
|
370
|
-
with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
|
227
|
+
*Sean Griffin*
|
371
228
|
|
372
|
-
|
229
|
+
* Add support for hash and url configs in database hash of `ActiveRecord::Base.connected_to`.
|
373
230
|
|
374
|
-
|
231
|
+
````
|
232
|
+
User.connected_to(database: { writing: "postgres://foo" }) do
|
233
|
+
User.create!(name: "Gannon")
|
234
|
+
end
|
375
235
|
|
376
|
-
|
377
|
-
|
236
|
+
config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
|
237
|
+
User.connected_to(database: { reading: config }) do
|
238
|
+
User.count
|
239
|
+
end
|
240
|
+
````
|
378
241
|
|
379
|
-
*
|
242
|
+
*Gannon McGibbon*
|
380
243
|
|
381
|
-
*
|
244
|
+
* Support default expression for MySQL.
|
382
245
|
|
383
|
-
|
246
|
+
MySQL 8.0.13 and higher supports default value to be a function or expression.
|
384
247
|
|
385
|
-
|
248
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-table.html
|
386
249
|
|
387
250
|
*Ryuta Kamizono*
|
388
251
|
|
389
|
-
*
|
252
|
+
* Support expression indexes for MySQL.
|
390
253
|
|
391
|
-
|
254
|
+
MySQL 8.0.13 and higher supports functional key parts that index
|
255
|
+
expression values rather than column or column prefix values.
|
392
256
|
|
393
|
-
|
394
|
-
information.
|
257
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-index.html
|
395
258
|
|
396
|
-
*
|
259
|
+
*Ryuta Kamizono*
|
397
260
|
|
398
|
-
*
|
261
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
399
262
|
|
400
|
-
|
401
|
-
of database queries in the log to facilitate N+1 query resolution
|
402
|
-
and other debugging.
|
263
|
+
Fixes #33056.
|
403
264
|
|
404
|
-
|
405
|
-
recommended for use in the production environment since it relies
|
406
|
-
on Ruby's `Kernel#caller_locations` which is fairly slow.
|
265
|
+
*Federico Martinez*
|
407
266
|
|
408
|
-
|
267
|
+
* Add basic API for connection switching to support multiple databases.
|
409
268
|
|
410
|
-
|
269
|
+
1) Adds a `connects_to` method for models to connect to multiple databases. Example:
|
411
270
|
|
412
271
|
```
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
# end
|
418
|
-
class Post < ApplicationRecord
|
272
|
+
class AnimalsModel < ApplicationRecord
|
273
|
+
self.abstract_class = true
|
274
|
+
|
275
|
+
connects_to database: { writing: :animals_primary, reading: :animals_replica }
|
419
276
|
end
|
420
277
|
|
421
|
-
|
422
|
-
|
423
|
-
# end
|
424
|
-
class Comment < ApplicationRecord
|
425
|
-
belongs_to :post, touch: true, counter_cache: true
|
278
|
+
class Dog < AnimalsModel
|
279
|
+
# connected to both the animals_primary db for writing and the animals_replica for reading
|
426
280
|
end
|
427
281
|
```
|
428
282
|
|
429
|
-
|
283
|
+
2) Adds a `connected_to` block method for switching connection roles or connecting to
|
284
|
+
a database that the model didn't connect to. Connecting to the database in this block is
|
285
|
+
useful when you have another defined connection, for example `slow_replica` that you don't
|
286
|
+
want to connect to by default but need in the console, or a specific code block.
|
287
|
+
|
430
288
|
```
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
commit transaction
|
436
|
-
|
437
|
-
comment = Comment.create!(post: post)
|
438
|
-
# => begin transaction
|
439
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
440
|
-
|
441
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
442
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
443
|
-
|
444
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
|
445
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
446
|
-
rollback transaction
|
447
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
448
|
-
|
449
|
-
Comment.take.destroy!
|
450
|
-
# => begin transaction
|
451
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
452
|
-
|
453
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
454
|
-
"lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
|
455
|
-
|
456
|
-
UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
|
457
|
-
"lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
|
458
|
-
rollback transaction
|
459
|
-
# => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
|
289
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
290
|
+
Dog.first # finds dog from replica connected to AnimalsBase
|
291
|
+
Book.first # doesn't have a reading connection, will raise an error
|
292
|
+
end
|
460
293
|
```
|
461
294
|
|
462
|
-
After:
|
463
295
|
```
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
|
468
|
-
commit transaction
|
469
|
-
|
470
|
-
comment = Comment.create!(post: post)
|
471
|
-
# => begin transaction
|
472
|
-
INSERT INTO "comments" ("post_id") VALUES (1)
|
473
|
-
|
474
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
|
475
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
476
|
-
"updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
|
477
|
-
commit transaction
|
478
|
-
|
479
|
-
comment.destroy!
|
480
|
-
# => begin transaction
|
481
|
-
DELETE FROM "comments" WHERE "comments"."id" = 1
|
482
|
-
|
483
|
-
UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
|
484
|
-
"lock_version" = COALESCE("lock_version", 0) + 1,
|
485
|
-
"updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
|
486
|
-
commit transaction
|
296
|
+
ActiveRecord::Base.connected_to(database: :slow_replica) do
|
297
|
+
SlowReplicaModel.first # if the db config has a slow_replica configuration this will be used to do the lookup, otherwise this will throw an exception
|
298
|
+
end
|
487
299
|
```
|
488
300
|
|
489
|
-
|
490
|
-
|
491
|
-
*bogdanvlviv*
|
492
|
-
|
493
|
-
* Add support for PostgreSQL operator classes to `add_index`.
|
494
|
-
|
495
|
-
Example:
|
496
|
-
|
497
|
-
add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
|
498
|
-
|
499
|
-
*Greg Navis*
|
500
|
-
|
501
|
-
* Don't allow scopes to be defined which conflict with instance methods on `Relation`.
|
502
|
-
|
503
|
-
Fixes #31120.
|
504
|
-
|
505
|
-
*kinnrot*
|
506
|
-
|
507
|
-
* Add new error class `QueryCanceled` which will be raised
|
508
|
-
when canceling statement due to user request.
|
301
|
+
*Eileen M. Uchitelle*
|
509
302
|
|
510
|
-
|
303
|
+
* Enum raises on invalid definition values
|
511
304
|
|
512
|
-
|
513
|
-
|
305
|
+
When defining a Hash enum it can be easy to use [] instead of {}. This
|
306
|
+
commit checks that only valid definition values are provided, those can
|
307
|
+
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
308
|
+
raises an ArgumentError.
|
514
309
|
|
515
|
-
|
310
|
+
Fixes #33961
|
516
311
|
|
517
|
-
*
|
518
|
-
relation query methods.
|
312
|
+
*Alberto Almagro*
|
519
313
|
|
520
|
-
|
521
|
-
```
|
522
|
-
Article.order("LENGTH(title)")
|
523
|
-
```
|
314
|
+
* Reloading associations now clears the Query Cache like `Persistence#reload` does.
|
524
315
|
|
525
|
-
After:
|
526
316
|
```
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
mistaken belief that only column names will be accepted.
|
533
|
-
|
534
|
-
Raw SQL strings will now cause a deprecation warning, which will
|
535
|
-
become an UnknownAttributeReference error in Rails 6.0. Applications
|
536
|
-
can opt in to the future behavior by setting `allow_unsafe_raw_sql`
|
537
|
-
to `:disabled`.
|
317
|
+
class Post < ActiveRecord::Base
|
318
|
+
has_one :category
|
319
|
+
belongs_to :author
|
320
|
+
has_many :comments
|
321
|
+
end
|
538
322
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
323
|
+
# Each of the following will now clear the query cache.
|
324
|
+
post.reload_category
|
325
|
+
post.reload_author
|
326
|
+
post.comments.reload
|
543
327
|
```
|
544
328
|
|
545
|
-
*
|
329
|
+
*Christophe Maximin*
|
546
330
|
|
547
|
-
* `
|
548
|
-
|
549
|
-
|
331
|
+
* Added `index` option for `change_table` migration helpers.
|
332
|
+
With this change you can create indexes while adding new
|
333
|
+
columns into the existing tables.
|
550
334
|
|
551
|
-
|
552
|
-
|
553
|
-
* Add new error class `StatementTimeout` which will be raised
|
554
|
-
when statement timeout exceeded.
|
555
|
-
|
556
|
-
*Ryuta Kamizono*
|
557
|
-
|
558
|
-
* Fix `bin/rails db:migrate` with specified `VERSION`.
|
559
|
-
`bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
|
560
|
-
Check a format of `VERSION`: Allow a migration version number
|
561
|
-
or name of a migration file. Raise error if format of `VERSION` is invalid.
|
562
|
-
Raise error if target migration doesn't exist.
|
563
|
-
|
564
|
-
*bogdanvlviv*
|
565
|
-
|
566
|
-
* Fixed a bug where column orders for an index weren't written to
|
567
|
-
`db/schema.rb` when using the sqlite adapter.
|
568
|
-
|
569
|
-
Fixes #30902.
|
570
|
-
|
571
|
-
*Paul Kuruvilla*
|
572
|
-
|
573
|
-
* Remove deprecated method `#sanitize_conditions`.
|
574
|
-
|
575
|
-
*Rafael Mendonça França*
|
576
|
-
|
577
|
-
* Remove deprecated method `#scope_chain`.
|
578
|
-
|
579
|
-
*Rafael Mendonça França*
|
580
|
-
|
581
|
-
* Remove deprecated configuration `.error_on_ignored_order_or_limit`.
|
582
|
-
|
583
|
-
*Rafael Mendonça França*
|
584
|
-
|
585
|
-
* Remove deprecated arguments from `#verify!`.
|
586
|
-
|
587
|
-
*Rafael Mendonça França*
|
588
|
-
|
589
|
-
* Remove deprecated argument `name` from `#indexes`.
|
590
|
-
|
591
|
-
*Rafael Mendonça França*
|
592
|
-
|
593
|
-
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
|
594
|
-
|
595
|
-
*Rafael Mendonça França*
|
335
|
+
Example:
|
596
336
|
|
597
|
-
|
337
|
+
change_table(:languages) do |t|
|
338
|
+
t.string :country_code, index: true
|
339
|
+
end
|
598
340
|
|
599
|
-
*
|
341
|
+
*Mehmet Emin İNAÇ*
|
600
342
|
|
601
|
-
*
|
343
|
+
* Fix `transaction` reverting for migrations.
|
602
344
|
|
603
|
-
|
345
|
+
Before: Commands inside a `transaction` in a reverted migration ran uninverted.
|
346
|
+
Now: This change fixes that by reverting commands inside `transaction` block.
|
604
347
|
|
605
|
-
*
|
348
|
+
*fatkodima*, *David Verhasselt*
|
606
349
|
|
607
|
-
|
350
|
+
* Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
|
608
351
|
|
609
|
-
*
|
352
|
+
*Gannon McGibbon*, *Max Albrecht*
|
610
353
|
|
611
|
-
|
354
|
+
* Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
|
612
355
|
|
613
|
-
*
|
356
|
+
*Gannon McGibbon*
|
614
357
|
|
615
|
-
|
358
|
+
* Don't update counter cache unless the record is actually saved.
|
616
359
|
|
617
|
-
|
360
|
+
Fixes #31493, #33113, #33117.
|
618
361
|
|
619
|
-
*
|
362
|
+
*Ryuta Kamizono*
|
620
363
|
|
621
|
-
*
|
364
|
+
* Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
|
622
365
|
|
623
|
-
*
|
366
|
+
*Gannon McGibbon*, *Kevin Cheng*
|
624
367
|
|
625
|
-
*
|
626
|
-
ar_internal_metadata's data for a test database.
|
368
|
+
* SQLite3 adapter supports expression indexes.
|
627
369
|
|
628
|
-
Before:
|
629
|
-
```
|
630
|
-
$ RAILS_ENV=test rails dbconsole
|
631
|
-
> SELECT * FROM ar_internal_metadata;
|
632
|
-
key|value|created_at|updated_at
|
633
|
-
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
634
370
|
```
|
371
|
+
create_table :users do |t|
|
372
|
+
t.string :email
|
373
|
+
end
|
635
374
|
|
636
|
-
|
637
|
-
```
|
638
|
-
$ RAILS_ENV=test rails dbconsole
|
639
|
-
> SELECT * FROM ar_internal_metadata;
|
640
|
-
key|value|created_at|updated_at
|
641
|
-
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
375
|
+
add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
|
642
376
|
```
|
643
377
|
|
644
|
-
|
378
|
+
*Gray Kemmey*
|
645
379
|
|
646
|
-
|
380
|
+
* Allow subclasses to redefine autosave callbacks for associated records.
|
647
381
|
|
648
|
-
|
382
|
+
Fixes #33305.
|
649
383
|
|
650
|
-
|
384
|
+
*Andrey Subbota*
|
651
385
|
|
652
|
-
|
386
|
+
* Bump minimum MySQL version to 5.5.8.
|
653
387
|
|
654
|
-
*
|
388
|
+
*Yasuo Honda*
|
655
389
|
|
656
|
-
|
657
|
-
|
658
|
-
*Ryuta Kamizono*
|
390
|
+
* Use MySQL utf8mb4 character set by default.
|
659
391
|
|
660
|
-
|
392
|
+
`utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
|
393
|
+
The previous default 3-Byte encoding character set `utf8` is not enough to support them.
|
661
394
|
|
662
|
-
|
395
|
+
*Yasuo Honda*
|
663
396
|
|
664
|
-
|
665
|
-
|
666
|
-
* PostgreSQL `tsrange` now preserves subsecond precision.
|
667
|
-
|
668
|
-
PostgreSQL 9.1+ introduced range types, and Rails added support for using
|
669
|
-
this datatype in Active Record. However, the serialization of
|
670
|
-
`PostgreSQL::OID::Range` was incomplete, because it did not properly
|
671
|
-
cast the bounds that make up the range. This led to subseconds being
|
672
|
-
dropped in SQL commands:
|
673
|
-
|
674
|
-
Before:
|
675
|
-
|
676
|
-
connection.type_cast(tsrange.serialize(range_value))
|
677
|
-
# => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
|
678
|
-
|
679
|
-
Now:
|
680
|
-
|
681
|
-
connection.type_cast(tsrange.serialize(range_value))
|
682
|
-
# => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
|
683
|
-
|
684
|
-
*Thomas Cannon*
|
685
|
-
|
686
|
-
* Passing a `Set` to `Relation#where` now behaves the same as passing an
|
687
|
-
array.
|
688
|
-
|
689
|
-
*Sean Griffin*
|
690
|
-
|
691
|
-
* Use given algorithm while removing index from database.
|
692
|
-
|
693
|
-
Fixes #24190.
|
694
|
-
|
695
|
-
*Mehmet Emin İNAÇ*
|
696
|
-
|
697
|
-
* Update payload names for `sql.active_record` instrumentation to be
|
698
|
-
more descriptive.
|
397
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
699
398
|
|
700
|
-
|
399
|
+
*Darwin Wu*
|
701
400
|
|
702
|
-
|
401
|
+
* Configuration item `config.filter_parameters` could also filter out
|
402
|
+
sensitive values of database columns when call `#inspect`.
|
403
|
+
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
404
|
+
specify sensitive attributes to specific model.
|
703
405
|
|
704
|
-
|
705
|
-
|
406
|
+
```
|
407
|
+
Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
|
408
|
+
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
|
409
|
+
SecureAccount.filter_attributes += [:name]
|
410
|
+
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
|
411
|
+
```
|
706
412
|
|
707
|
-
*
|
413
|
+
*Zhang Kang*, *Yoshiyuki Kinjo*
|
708
414
|
|
709
|
-
*
|
415
|
+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
|
416
|
+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
417
|
+
and `joins_per_query` methods in `DatabaseLimits`.
|
710
418
|
|
711
419
|
*Ryuta Kamizono*
|
712
420
|
|
713
|
-
*
|
714
|
-
|
715
|
-
*Yuichiro Kaneko*
|
716
|
-
|
717
|
-
* Ensure `sum` honors `distinct` on `has_many :through` associations.
|
718
|
-
|
719
|
-
Fixes #16791.
|
421
|
+
* `ActiveRecord::Base.configurations` now returns an object.
|
720
422
|
|
721
|
-
|
423
|
+
`ActiveRecord::Base.configurations` used to return a hash, but this
|
424
|
+
is an inflexible data model. In order to improve multiple-database
|
425
|
+
handling in Rails, we've changed this to return an object. Some methods
|
426
|
+
are provided to make the object behave hash-like in order to ease the
|
427
|
+
transition process. Since most applications don't manipulate the hash
|
428
|
+
we've decided to add backwards-compatible functionality that will throw
|
429
|
+
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
430
|
+
will use the new version internally and externally.
|
722
431
|
|
723
|
-
|
432
|
+
For example, the following `database.yml`:
|
724
433
|
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
* `Relation#or` now accepts two relations who have different values for
|
732
|
-
`references` only, as `references` can be implicitly called by `where`.
|
733
|
-
|
734
|
-
Fixes #29411.
|
735
|
-
|
736
|
-
*Sean Griffin*
|
737
|
-
|
738
|
-
* `ApplicationRecord` is no longer generated when generating models. If you
|
739
|
-
need to generate it, it can be created with `rails g application_record`.
|
740
|
-
|
741
|
-
*Lisa Ugray*
|
742
|
-
|
743
|
-
* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
|
434
|
+
```
|
435
|
+
development:
|
436
|
+
adapter: sqlite3
|
437
|
+
database: db/development.sqlite3
|
438
|
+
```
|
744
439
|
|
745
|
-
|
440
|
+
Used to become a hash:
|
746
441
|
|
747
|
-
|
748
|
-
|
749
|
-
|
442
|
+
```
|
443
|
+
{ "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
|
444
|
+
```
|
750
445
|
|
751
|
-
|
446
|
+
Is now converted into the following object:
|
752
447
|
|
753
|
-
|
448
|
+
```
|
449
|
+
#<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
|
450
|
+
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
|
451
|
+
@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
|
452
|
+
]
|
453
|
+
```
|
754
454
|
|
755
|
-
|
756
|
-
|
455
|
+
Iterating over the database configurations has also changed. Instead of
|
456
|
+
calling hash methods on the `configurations` hash directly, a new method `configs_for` has
|
457
|
+
been provided that allows you to select the correct configuration. `env_name`, and
|
458
|
+
`spec_name` arguments are optional. For example these return an array of
|
459
|
+
database config objects for the requested environment and a single database config object
|
460
|
+
will be returned for the requested environment and specification name respectively.
|
757
461
|
|
758
462
|
```
|
759
|
-
|
760
|
-
|
761
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
|
762
|
-
# With fix:
|
763
|
-
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
|
463
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development")
|
464
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
764
465
|
```
|
765
466
|
|
766
|
-
*
|
767
|
-
|
768
|
-
* Values constructed using multi-parameter assignment will now use the
|
769
|
-
post-type-cast value for rendering in single-field form inputs.
|
467
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
770
468
|
|
771
|
-
|
469
|
+
* Add database configuration to disable advisory locks.
|
772
470
|
|
773
|
-
|
774
|
-
|
471
|
+
```
|
472
|
+
production:
|
473
|
+
adapter: postgresql
|
474
|
+
advisory_locks: false
|
475
|
+
```
|
775
476
|
|
776
|
-
|
477
|
+
*Guo Xiang*
|
777
478
|
|
778
|
-
|
479
|
+
* SQLite3 adapter `alter_table` method restores foreign keys.
|
779
480
|
|
780
|
-
*
|
481
|
+
*Yasuo Honda*
|
781
482
|
|
782
|
-
|
783
|
-
recognize 't' and 'f' as was previously serialized.
|
483
|
+
* Allow `:to_table` option to `invert_remove_foreign_key`.
|
784
484
|
|
785
|
-
|
786
|
-
for SQLite databases, so it's implemented behind a configuration flag
|
787
|
-
whose default false value is deprecated.
|
788
|
-
|
789
|
-
*Lisa Ugray*
|
485
|
+
Example:
|
790
486
|
|
791
|
-
|
792
|
-
`in_batches`).
|
487
|
+
remove_foreign_key :accounts, to_table: :owners
|
793
488
|
|
794
|
-
|
795
|
-
until the end of the request or job.
|
489
|
+
*Nikolay Epifanov*, *Rich Chen*
|
796
490
|
|
797
|
-
|
491
|
+
* Add environment & load_config dependency to `bin/rake db:seed` to enable
|
492
|
+
seed load in environments without Rails and custom DB configuration
|
798
493
|
|
799
|
-
*
|
800
|
-
`ActiveRecord::StatementInvalid` exceptions.
|
494
|
+
*Tobias Bielohlawek*
|
801
495
|
|
802
|
-
|
496
|
+
* Fix default value for mysql time types with specified precision.
|
803
497
|
|
804
|
-
*
|
498
|
+
*Nikolay Kondratyev*
|
805
499
|
|
806
|
-
|
500
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
807
501
|
|
808
502
|
*Ryuta Kamizono*
|
809
503
|
|
810
|
-
*
|
811
|
-
|
812
|
-
Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
|
813
|
-
inner transaction would still be marked as persisted.
|
814
|
-
|
815
|
-
This change fixes that by applying the state of the parent transaction to the child transaction when the
|
816
|
-
parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
|
817
|
-
|
818
|
-
*Eileen M. Uchitelle*, *Aaron Patterson*
|
819
|
-
|
820
|
-
* Deprecate `set_state` method in `TransactionState`.
|
821
|
-
|
822
|
-
Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
|
823
|
-
state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
|
824
|
-
`set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
|
825
|
-
|
826
|
-
*Eileen M. Uchitelle*, *Aaron Patterson*
|
504
|
+
* Migrations raise when duplicate column definition.
|
827
505
|
|
828
|
-
|
506
|
+
Fixes #33024.
|
829
507
|
|
830
|
-
*
|
508
|
+
*Federico Martinez*
|
831
509
|
|
832
|
-
*
|
833
|
-
without being connected.
|
510
|
+
* Bump minimum SQLite version to 3.8
|
834
511
|
|
835
|
-
*
|
512
|
+
*Yasuo Honda*
|
836
513
|
|
837
|
-
*
|
838
|
-
if the child records were deleted before the parent was saved, they would
|
839
|
-
still be persisted. Now, if child records are deleted before the parent is saved
|
840
|
-
on a `has_many :through` association, the child records will not be persisted.
|
514
|
+
* Fix parent record should not get saved with duplicate children records.
|
841
515
|
|
842
|
-
|
516
|
+
Fixes #32940.
|
843
517
|
|
844
|
-
*
|
845
|
-
the merged relation into LEFT OUTER JOIN.
|
518
|
+
*Santosh Wadghule*
|
846
519
|
|
847
|
-
|
520
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
848
521
|
|
849
|
-
|
850
|
-
Author.joins(:posts).merge(Post.joins(:comments))
|
851
|
-
# Before the change:
|
852
|
-
#=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
|
522
|
+
*Brian Durand*
|
853
523
|
|
854
|
-
|
855
|
-
|
856
|
-
```
|
524
|
+
* Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
|
525
|
+
use loaded association ids if present.
|
857
526
|
|
858
|
-
*
|
527
|
+
*Graham Turner*
|
859
528
|
|
860
|
-
*
|
861
|
-
`locking_column`, without default value, is null in the database.
|
529
|
+
* Add support to preload associations of polymorphic associations when not all the records have the requested associations.
|
862
530
|
|
863
|
-
*
|
531
|
+
*Dana Sherson*
|
864
532
|
|
865
|
-
*
|
866
|
-
`locking_column` is null in the database.
|
533
|
+
* Add `touch_all` method to `ActiveRecord::Relation`.
|
867
534
|
|
868
|
-
|
535
|
+
Example:
|
869
536
|
|
870
|
-
|
537
|
+
Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
871
538
|
|
872
|
-
*
|
539
|
+
*fatkodima*, *duggiefresh*
|
873
540
|
|
874
|
-
*
|
541
|
+
* Add `ActiveRecord::Base.base_class?` predicate.
|
875
542
|
|
876
|
-
*
|
543
|
+
*Bogdan Gusiev*
|
877
544
|
|
878
|
-
*
|
545
|
+
* Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
|
879
546
|
|
880
|
-
*
|
547
|
+
*Tan Huynh*, *Yukio Mizuta*
|
881
548
|
|
882
|
-
*
|
549
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
883
550
|
|
884
|
-
|
551
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
885
552
|
|
886
|
-
|
553
|
+
* Deprecate `update_attributes`/`!` in favor of `update`/`!`.
|
887
554
|
|
888
|
-
*
|
889
|
-
in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
|
890
|
-
that does not include a timestamp any more.
|
555
|
+
*Eddie Lebow*
|
891
556
|
|
892
|
-
|
893
|
-
|
557
|
+
* Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
|
558
|
+
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
894
559
|
|
895
560
|
*DHH*
|
896
561
|
|
897
|
-
*
|
898
|
-
|
899
|
-
*Rusty Geldmacher*, *Guillermo Iguaran*
|
900
|
-
|
901
|
-
* Add type caster to `RuntimeReflection#alias_name`.
|
902
|
-
|
903
|
-
Fixes #28959.
|
904
|
-
|
905
|
-
*Jon Moss*
|
906
|
-
|
907
|
-
* Deprecate `supports_statement_cache?`.
|
908
|
-
|
909
|
-
*Ryuta Kamizono*
|
910
|
-
|
911
|
-
* Raise error `UnknownMigrationVersionError` on the movement of migrations
|
912
|
-
when the current migration does not exist.
|
562
|
+
* Add `Relation#pick` as short-hand for single-value plucks.
|
913
563
|
|
914
|
-
*
|
915
|
-
|
916
|
-
* Fix `bin/rails db:forward` first migration.
|
917
|
-
|
918
|
-
*bogdanvlviv*
|
919
|
-
|
920
|
-
* Support Descending Indexes for MySQL.
|
921
|
-
|
922
|
-
MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
|
923
|
-
See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
|
924
|
-
|
925
|
-
*Ryuta Kamizono*
|
926
|
-
|
927
|
-
* Fix inconsistency with changed attributes when overriding Active Record attribute reader.
|
928
|
-
|
929
|
-
*bogdanvlviv*
|
930
|
-
|
931
|
-
* When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
|
932
|
-
Previously this method always returned an empty array.
|
933
|
-
|
934
|
-
*Kevin McPhillips*
|
564
|
+
*DHH*
|
935
565
|
|
936
566
|
|
937
|
-
Please check [5-
|
567
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
|