activerecord 4.1.15 → 4.2.11.3
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 +1162 -1792
- data/README.rdoc +15 -10
- data/lib/active_record.rb +4 -0
- data/lib/active_record/aggregations.rb +15 -8
- data/lib/active_record/association_relation.rb +13 -0
- data/lib/active_record/associations.rb +158 -49
- data/lib/active_record/associations/alias_tracker.rb +3 -12
- data/lib/active_record/associations/association.rb +16 -4
- data/lib/active_record/associations/association_scope.rb +83 -38
- data/lib/active_record/associations/belongs_to_association.rb +28 -10
- data/lib/active_record/associations/builder/association.rb +15 -4
- data/lib/active_record/associations/builder/belongs_to.rb +7 -29
- data/lib/active_record/associations/builder/collection_association.rb +5 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +8 -13
- data/lib/active_record/associations/builder/has_many.rb +1 -1
- data/lib/active_record/associations/builder/has_one.rb +2 -2
- data/lib/active_record/associations/builder/singular_association.rb +8 -1
- data/lib/active_record/associations/collection_association.rb +63 -27
- data/lib/active_record/associations/collection_proxy.rb +29 -35
- data/lib/active_record/associations/foreign_association.rb +11 -0
- data/lib/active_record/associations/has_many_association.rb +83 -22
- data/lib/active_record/associations/has_many_through_association.rb +49 -26
- data/lib/active_record/associations/has_one_association.rb +1 -1
- data/lib/active_record/associations/join_dependency.rb +26 -13
- data/lib/active_record/associations/join_dependency/join_association.rb +25 -15
- data/lib/active_record/associations/join_dependency/join_part.rb +0 -1
- data/lib/active_record/associations/preloader.rb +36 -26
- data/lib/active_record/associations/preloader/association.rb +14 -11
- data/lib/active_record/associations/preloader/through_association.rb +4 -3
- data/lib/active_record/associations/singular_association.rb +17 -2
- data/lib/active_record/associations/through_association.rb +5 -12
- data/lib/active_record/attribute.rb +163 -0
- data/lib/active_record/attribute_assignment.rb +19 -11
- data/lib/active_record/attribute_decorators.rb +66 -0
- data/lib/active_record/attribute_methods.rb +56 -94
- data/lib/active_record/attribute_methods/before_type_cast.rb +7 -2
- data/lib/active_record/attribute_methods/dirty.rb +107 -43
- data/lib/active_record/attribute_methods/primary_key.rb +7 -8
- data/lib/active_record/attribute_methods/query.rb +1 -1
- data/lib/active_record/attribute_methods/read.rb +22 -59
- data/lib/active_record/attribute_methods/serialization.rb +16 -150
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +38 -40
- data/lib/active_record/attribute_methods/write.rb +9 -24
- data/lib/active_record/attribute_set.rb +81 -0
- data/lib/active_record/attribute_set/builder.rb +106 -0
- data/lib/active_record/attributes.rb +147 -0
- data/lib/active_record/autosave_association.rb +19 -12
- data/lib/active_record/base.rb +13 -24
- data/lib/active_record/callbacks.rb +6 -6
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +84 -52
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +52 -50
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/quoting.rb +60 -60
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +39 -4
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +138 -56
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +14 -34
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +268 -71
- data/lib/active_record/connection_adapters/abstract/transaction.rb +125 -118
- data/lib/active_record/connection_adapters/abstract_adapter.rb +171 -59
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +293 -139
- data/lib/active_record/connection_adapters/column.rb +29 -240
- data/lib/active_record/connection_adapters/connection_specification.rb +15 -24
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +16 -32
- data/lib/active_record/connection_adapters/mysql_adapter.rb +67 -144
- data/lib/active_record/connection_adapters/postgresql/array_parser.rb +15 -27
- data/lib/active_record/connection_adapters/postgresql/column.rb +20 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +40 -25
- data/lib/active_record/connection_adapters/postgresql/oid.rb +29 -388
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +100 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +52 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +13 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +46 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +11 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +36 -0
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +13 -0
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +19 -0
- data/lib/active_record/connection_adapters/postgresql/oid/float.rb +21 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +59 -0
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +13 -0
- data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +13 -0
- data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +11 -0
- data/lib/active_record/connection_adapters/postgresql/oid/json.rb +35 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +43 -0
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +43 -0
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +79 -0
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +19 -0
- data/lib/active_record/connection_adapters/postgresql/oid/time.rb +11 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +109 -0
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +21 -0
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +26 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +28 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +46 -136
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +4 -4
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +152 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +131 -43
- data/lib/active_record/connection_adapters/postgresql/utils.rb +77 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +224 -477
- data/lib/active_record/connection_adapters/schema_cache.rb +14 -28
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +61 -75
- data/lib/active_record/connection_handling.rb +1 -1
- data/lib/active_record/core.rb +163 -39
- data/lib/active_record/counter_cache.rb +60 -6
- data/lib/active_record/enum.rb +9 -11
- data/lib/active_record/errors.rb +53 -30
- data/lib/active_record/explain.rb +1 -1
- data/lib/active_record/explain_subscriber.rb +1 -1
- data/lib/active_record/fixtures.rb +55 -69
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +35 -10
- data/lib/active_record/integration.rb +4 -4
- data/lib/active_record/legacy_yaml_adapter.rb +30 -0
- data/lib/active_record/locking/optimistic.rb +46 -26
- data/lib/active_record/migration.rb +71 -46
- data/lib/active_record/migration/command_recorder.rb +19 -2
- data/lib/active_record/migration/join_table.rb +1 -1
- data/lib/active_record/model_schema.rb +52 -58
- data/lib/active_record/nested_attributes.rb +5 -5
- data/lib/active_record/no_touching.rb +1 -1
- data/lib/active_record/persistence.rb +46 -26
- data/lib/active_record/query_cache.rb +3 -3
- data/lib/active_record/querying.rb +10 -7
- data/lib/active_record/railtie.rb +18 -11
- data/lib/active_record/railties/databases.rake +50 -51
- data/lib/active_record/readonly_attributes.rb +0 -1
- data/lib/active_record/reflection.rb +273 -114
- data/lib/active_record/relation.rb +57 -25
- data/lib/active_record/relation/batches.rb +0 -2
- data/lib/active_record/relation/calculations.rb +41 -37
- data/lib/active_record/relation/finder_methods.rb +70 -47
- data/lib/active_record/relation/merger.rb +39 -29
- data/lib/active_record/relation/predicate_builder.rb +16 -8
- data/lib/active_record/relation/predicate_builder/array_handler.rb +32 -13
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -5
- data/lib/active_record/relation/query_methods.rb +114 -65
- data/lib/active_record/relation/spawn_methods.rb +3 -0
- data/lib/active_record/result.rb +18 -7
- data/lib/active_record/sanitization.rb +12 -2
- data/lib/active_record/schema.rb +0 -1
- data/lib/active_record/schema_dumper.rb +59 -28
- data/lib/active_record/schema_migration.rb +5 -4
- data/lib/active_record/scoping/default.rb +6 -4
- data/lib/active_record/scoping/named.rb +4 -0
- data/lib/active_record/serializers/xml_serializer.rb +3 -7
- data/lib/active_record/statement_cache.rb +95 -10
- data/lib/active_record/store.rb +5 -5
- data/lib/active_record/tasks/database_tasks.rb +61 -6
- data/lib/active_record/tasks/mysql_database_tasks.rb +32 -17
- data/lib/active_record/tasks/postgresql_database_tasks.rb +20 -9
- data/lib/active_record/timestamp.rb +9 -7
- data/lib/active_record/transactions.rb +53 -27
- data/lib/active_record/type.rb +23 -0
- data/lib/active_record/type/big_integer.rb +13 -0
- data/lib/active_record/type/binary.rb +50 -0
- data/lib/active_record/type/boolean.rb +31 -0
- data/lib/active_record/type/date.rb +50 -0
- data/lib/active_record/type/date_time.rb +54 -0
- data/lib/active_record/type/decimal.rb +64 -0
- data/lib/active_record/type/decimal_without_scale.rb +11 -0
- data/lib/active_record/type/decorator.rb +14 -0
- data/lib/active_record/type/float.rb +19 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +23 -0
- data/lib/active_record/type/integer.rb +59 -0
- data/lib/active_record/type/mutable.rb +16 -0
- data/lib/active_record/type/numeric.rb +36 -0
- data/lib/active_record/type/serialized.rb +62 -0
- data/lib/active_record/type/string.rb +40 -0
- data/lib/active_record/type/text.rb +11 -0
- data/lib/active_record/type/time.rb +26 -0
- data/lib/active_record/type/time_value.rb +38 -0
- data/lib/active_record/type/type_map.rb +64 -0
- data/lib/active_record/type/unsigned_integer.rb +15 -0
- data/lib/active_record/type/value.rb +110 -0
- data/lib/active_record/validations.rb +25 -19
- data/lib/active_record/validations/associated.rb +5 -3
- data/lib/active_record/validations/presence.rb +5 -3
- data/lib/active_record/validations/uniqueness.rb +25 -29
- data/lib/rails/generators/active_record/migration/migration_generator.rb +8 -4
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +1 -1
- data/lib/rails/generators/active_record/model/templates/model.rb +1 -1
- metadata +66 -11
- data/lib/active_record/connection_adapters/postgresql/cast.rb +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 238110845ec2f5b8ff734d31c9673e4863b9c87d71a4f2dc62c4159542e80ccf
|
4
|
+
data.tar.gz: ee2a8873472201b9fc479c51a025f1f374692d316c497383d8d4e77a0350ed6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd15b24d6b2f78181be0ea9d5d3e5610a44d485bc1ab5cd090a2546aa8ea9470047fecd295c626c8e319c09af0d078e59cb1458ad70cdc48a66d63da4cab8e60
|
7
|
+
data.tar.gz: 0e888e548162c2a9c706ab73fabdd8097e72b09f468c2b5d71ac50b8e81b3a4082eec56de388d9a59477184415d000110e09ae1ae3ce7fc68af23d4a3f6a6798
|
data/CHANGELOG.md
CHANGED
@@ -1,2673 +1,2043 @@
|
|
1
|
-
## Rails 4.
|
1
|
+
## Rails 4.2.11.3 (May 15, 2020) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
Fixes #23327.
|
6
|
-
|
7
|
-
*Rick Song*
|
8
|
-
|
9
|
-
* No longer pass deprecated option `-i` to `pg_dump`.
|
10
|
-
|
11
|
-
*Paul Sadauskas*
|
12
|
-
|
13
|
-
|
14
|
-
## Rails 4.1.14.2 (February 26, 2016) ##
|
15
|
-
|
16
|
-
* No changes.
|
17
|
-
|
18
|
-
|
19
|
-
## Rails 4.1.14.1 (January 25, 2015) ##
|
20
|
-
|
21
|
-
* No changes.
|
22
|
-
|
23
|
-
|
24
|
-
## Rails 4.1.14 (November 12, 2015) ##
|
25
|
-
|
26
|
-
* No longer pass deprecated option `-i` to `pg_dump`.
|
27
|
-
|
28
|
-
*Paul Sadauskas*
|
29
|
-
|
30
|
-
* Includes HABTM returns correct size now. It's caused by the join dependency
|
31
|
-
only instantiates one HABTM object because the join table hasn't a primary key.
|
32
|
-
|
33
|
-
Fixes #16032.
|
34
|
-
|
35
|
-
Examples:
|
36
|
-
|
37
|
-
before:
|
38
|
-
|
39
|
-
Project.first.salaried_developers.size # => 3
|
40
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
41
|
-
|
42
|
-
after:
|
43
|
-
|
44
|
-
Project.first.salaried_developers.size # => 3
|
45
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
46
|
-
|
47
|
-
*Bigxiang*
|
48
|
-
|
49
|
-
|
50
|
-
## Rails 4.1.13 (August 24, 2015) ##
|
51
|
-
|
52
|
-
* Don't define autosave association callbacks twice from
|
53
|
-
`accepts_nested_attributes_for`.
|
54
|
-
|
55
|
-
Fixes #18704.
|
56
|
-
|
57
|
-
*Sean Griffin*
|
58
|
-
|
59
|
-
|
60
|
-
## Rails 4.1.12 (June 25, 2015) ##
|
61
|
-
|
62
|
-
* Raises the right exception when declares a has many through
|
63
|
-
association with missing source.
|
64
|
-
|
65
|
-
*Mauro George*
|
66
|
-
|
67
|
-
* Revert behavior of `db:schema:load` back to loading the full
|
68
|
-
environment. This ensures that initializers are run.
|
69
|
-
|
70
|
-
Fixes #19545.
|
71
|
-
|
72
|
-
*Yves Senn*
|
73
|
-
|
74
|
-
* Rename `:class` to `:anonymous_class` in association options.
|
75
|
-
|
76
|
-
Fixes #19659.
|
77
|
-
|
78
|
-
*Andrew White*
|
79
|
-
|
80
|
-
* Fix referencing wrong table aliases while joining tables of has many through
|
81
|
-
association (only when calling calculation methods).
|
82
|
-
|
83
|
-
Fixes #19276.
|
84
|
-
|
85
|
-
*pinglamb*
|
86
|
-
|
87
|
-
|
88
|
-
## Rails 4.1.11 (June 16, 2015) ##
|
89
|
-
|
90
|
-
* No changes.
|
91
|
-
|
92
|
-
|
93
|
-
## Rails 4.1.10 (March 19, 2015) ##
|
94
|
-
|
95
|
-
* Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
|
96
|
-
|
97
|
-
Fixes #17139.
|
98
|
-
|
99
|
-
*Miklos Fazekas*
|
100
|
-
|
101
|
-
* A `NullRelation` should represent nothing. This fixes a bug where
|
102
|
-
`Comment.where(post_id: Post.none)` returned a non-empty result.
|
103
|
-
|
104
|
-
Closes #15176.
|
105
|
-
|
106
|
-
*Matthew Draper*, *Yves Senn*
|
107
|
-
|
108
|
-
* Respect custom primary keys for associations when calling `Relation#where`
|
109
|
-
|
110
|
-
Fixes #18813.
|
111
|
-
|
112
|
-
*Sean Griffin*
|
113
|
-
|
114
|
-
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
115
|
-
|
116
|
-
SplitTest.group(:key).count
|
117
|
-
Property.group(:value).count
|
118
|
-
|
119
|
-
*Bogdan Gusiev*
|
120
|
-
|
121
|
-
* Fixed setting of foreign_key for through associations while building of new record.
|
122
|
-
|
123
|
-
Fixes #12698.
|
124
|
-
|
125
|
-
*Ivan Antropov*
|
126
|
-
|
127
|
-
* Fixed automatic inverse_of for models nested in module.
|
128
|
-
|
129
|
-
*Andrew McCloud*
|
130
|
-
|
131
|
-
* Fix `reaping_frequency` option when the value is a string.
|
132
|
-
|
133
|
-
This usually happens when it is configured using `DATABASE_URL`.
|
134
|
-
|
135
|
-
*korbin*
|
136
|
-
|
137
|
-
|
138
|
-
## Rails 4.1.9 (January 6, 2015) ##
|
139
|
-
|
140
|
-
* `db:schema:load` and `db:structure:load` no longer purge the database
|
141
|
-
before loading the schema. This is left for the user to do.
|
142
|
-
`db:test:prepare` will still purge the database.
|
143
|
-
|
144
|
-
Closes #17945.
|
145
|
-
|
146
|
-
*Yves Senn*
|
147
|
-
|
148
|
-
* Bring back `db:test:prepare` to synchronize the test database schema.
|
149
|
-
|
150
|
-
Manual synchronization using `bin/rake db:test:prepare` is required
|
151
|
-
when a migration is rolled-back, edited and reapplied.
|
152
|
-
|
153
|
-
`ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
|
154
|
-
to synchronize the schema. Plugins can use this task as a hook to
|
155
|
-
provide custom behavior after the schema has been loaded.
|
156
|
-
|
157
|
-
NOTE: `test:prepare` runs before the schema was synchronized.
|
158
|
-
|
159
|
-
Fixes #17171, #15787.
|
160
|
-
|
161
|
-
*Yves Senn*
|
162
|
-
|
163
|
-
* Renaming a table in pg also renames the primary key index.
|
164
|
-
|
165
|
-
Fixes #12856
|
166
|
-
|
167
|
-
*Sean Griffin*
|
168
|
-
|
169
|
-
* Make it possible to access fixtures excluded by a `default_scope`.
|
170
|
-
|
171
|
-
*Yves Senn*
|
172
|
-
|
173
|
-
* `timestamps` and `add_timestamps` passes additional options along.
|
174
|
-
(like `null: false`)
|
175
|
-
|
176
|
-
Closes #17624.
|
177
|
-
|
178
|
-
*Yves Senn*
|
179
|
-
|
180
|
-
|
181
|
-
## Rails 4.1.8 (November 16, 2014) ##
|
182
|
-
|
183
|
-
* Cache `CollectionAssociation#reader` proxies separately before and after
|
184
|
-
the owner has been saved so that the proxy is not cached without the
|
185
|
-
owner's id.
|
186
|
-
|
187
|
-
*Ben Woosley*
|
188
|
-
|
189
|
-
* Fix preloading of associations which unscope a default scope.
|
190
|
-
|
191
|
-
Fixes #11036.
|
192
|
-
|
193
|
-
*Byron Bischoff*
|
194
|
-
|
195
|
-
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
196
|
-
|
197
|
-
Fixes #15931.
|
198
|
-
|
199
|
-
*Jeff Browning*
|
200
|
-
|
201
|
-
* Allow included modules to override association methods.
|
202
|
-
|
203
|
-
Fixes #16684.
|
204
|
-
|
205
|
-
*Yves Senn*
|
206
|
-
|
207
|
-
* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
|
208
|
-
the database connection to the current environment.
|
209
|
-
|
210
|
-
Fixes #16757.
|
211
|
-
|
212
|
-
*Joshua Cody*, *Yves Senn*
|
213
|
-
|
214
|
-
* `db:purge` with MySQL respects `Rails.env`.
|
215
|
-
|
216
|
-
*Yves Senn*
|
217
|
-
|
218
|
-
* Fixed automatic maintaining test schema to properly handle sql structure
|
219
|
-
schema format.
|
220
|
-
|
221
|
-
Fixes #15394.
|
222
|
-
|
223
|
-
*Wojciech Wnętrzak*
|
224
|
-
|
225
|
-
* Fix has_many :through relation merging failing when dynamic conditions are
|
226
|
-
passed as a lambda with an arity of one.
|
227
|
-
|
228
|
-
Fixes #16128.
|
229
|
-
|
230
|
-
*Agis Anastasopoulos*
|
231
|
-
|
232
|
-
|
233
|
-
## Rails 4.1.7.1 (November 19, 2014) ##
|
234
|
-
|
235
|
-
* No changes.
|
236
|
-
|
237
|
-
|
238
|
-
## Rails 4.1.7 (October 29, 2014) ##
|
239
|
-
|
240
|
-
* No changes.
|
241
|
-
|
242
|
-
|
243
|
-
## Rails 4.1.6 (September 11, 2014) ##
|
244
|
-
|
245
|
-
* Fixed a regression where whitespaces were stripped from DISTINCT queries in
|
246
|
-
PostgreSQL.
|
247
|
-
|
248
|
-
*Agis Anastasopoulos*
|
249
|
-
|
250
|
-
Fixes #16623.
|
251
|
-
|
252
|
-
* Fixed an issue where custom accessor methods (such as those generated by
|
253
|
-
`enum`) with the same name as a global method are incorrectly overridden
|
254
|
-
when subclassing.
|
255
|
-
|
256
|
-
Fixes #16288.
|
257
|
-
|
258
|
-
* Baseclass becomes! subclass.
|
259
|
-
|
260
|
-
Before this change, a record which changed its STI type, could not be found when updated.
|
261
|
-
Setting update_record to the base class, ensures the record can be found.
|
262
|
-
|
263
|
-
Fixes #14785.
|
264
|
-
|
265
|
-
*Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
|
266
|
-
|
267
|
-
* Fix regression on after_commit that didnt fire when having nested transactions.
|
268
|
-
|
269
|
-
Fixes #16425.
|
270
|
-
|
271
|
-
*arthurnn*
|
272
|
-
|
273
|
-
* Define `id_was` to get the previous value of the primary key.
|
274
|
-
|
275
|
-
Currently when we call id_was and we have a custom primary key name
|
276
|
-
Active Record will return the current value of the primary key. This
|
277
|
-
make impossible to correctly do an update operation if you change the
|
278
|
-
id.
|
279
|
-
|
280
|
-
Fixes #16413.
|
281
|
-
|
282
|
-
*Rafael Mendonça França*
|
283
|
-
|
284
|
-
* Fix the schema dump generated for tables without constraints and with
|
285
|
-
primary key with default value of custom PostgreSQL function result.
|
286
|
-
|
287
|
-
Fixes #16111.
|
288
|
-
|
289
|
-
*Andrey Novikov*
|
290
|
-
|
291
|
-
* Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
|
292
|
-
|
293
|
-
With 4.1.x, `serialize` started returning a string when `JSON` was passed as
|
294
|
-
the second attribute. It will now return a hash as per previous versions.
|
295
|
-
|
296
|
-
Example:
|
297
|
-
|
298
|
-
class Post < ActiveRecord::Base
|
299
|
-
serialize :comment, JSON
|
300
|
-
end
|
301
|
-
|
302
|
-
class Comment
|
303
|
-
include ActiveModel::Model
|
304
|
-
attr_accessor :category, :text
|
305
|
-
end
|
306
|
-
|
307
|
-
post = Post.create!
|
308
|
-
post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
|
309
|
-
post.save!
|
310
|
-
|
311
|
-
# 4.0
|
312
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
313
|
-
|
314
|
-
# 4.1 before
|
315
|
-
post.comment # => "#<Comment:0x007f80ab48ff98>"
|
316
|
-
|
317
|
-
# 4.1 after
|
318
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
319
|
-
|
320
|
-
When using `JSON` as the coder in `serialize`, Active Record will use the
|
321
|
-
new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
|
322
|
-
`ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
|
323
|
-
correctly using the `#as_json` hook.
|
324
|
-
|
325
|
-
To keep the previous behaviour, supply a custom coder instead
|
326
|
-
([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
|
327
|
-
|
328
|
-
Fixes #15594.
|
329
|
-
|
330
|
-
*Jenn Cooper*
|
331
|
-
|
332
|
-
* Fixed error in `reset_counters` when associations have `select` scope.
|
333
|
-
(Call to `count` generates invalid SQL.)
|
334
|
-
|
335
|
-
*Cade Truitt*
|
336
|
-
|
337
|
-
* After a successful `reload`, `new_record?` is always false.
|
338
|
-
|
339
|
-
Fixes #12101.
|
340
|
-
|
341
|
-
*Matthew Draper*
|
342
|
-
|
343
|
-
* Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
|
344
|
-
are part of the URI structure, not the actual host.
|
345
|
-
|
346
|
-
Fixes #15705.
|
347
|
-
|
348
|
-
*Andy Bakun*, *Aaron Stone*
|
349
|
-
|
350
|
-
* Don't error when quoting user defined types in PostgreSQL.
|
351
|
-
|
352
|
-
Fixes #15697.
|
353
|
-
|
354
|
-
*Sean Griffin*
|
355
|
-
|
356
|
-
* Ensure both parent IDs are set on join records when both sides of a
|
357
|
-
through association are new.
|
358
|
-
|
359
|
-
*Sean Griffin*
|
360
|
-
|
361
|
-
* Pluck now works when selecting columns from different tables with the same
|
362
|
-
name.
|
363
|
-
|
364
|
-
Fixes #15649.
|
365
|
-
|
366
|
-
*Sean Griffin*
|
367
|
-
|
368
|
-
* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
|
369
|
-
`Enumerable#find` does.
|
370
|
-
|
371
|
-
Fixes #15382.
|
372
|
-
|
373
|
-
*James Yang*
|
374
|
-
|
375
|
-
* `ActiveRecord::SchemaMigration` has no primary key regardless of the
|
376
|
-
`primary_key_prefix_type` configuration.
|
377
|
-
|
378
|
-
Fixes #15051.
|
379
|
-
|
380
|
-
*JoseLuis Torres*, *Yves Senn*
|
381
|
-
|
382
|
-
* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
|
383
|
-
|
384
|
-
Fixes #15538.
|
385
|
-
|
386
|
-
*Yves Senn*
|
387
|
-
|
388
|
-
* Fixed `columns_for_distinct` of postgresql adapter to work correctly
|
389
|
-
with orders without sort direction modifiers.
|
390
|
-
|
391
|
-
*Nikolay Kondratyev*
|
392
|
-
|
393
|
-
* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
|
394
|
-
Fixes duplication in combination with `store_accessor`.
|
395
|
-
|
396
|
-
Fixes #15369.
|
397
|
-
|
398
|
-
*Yves Senn*
|
399
|
-
|
400
|
-
* `rake railties:install:migrations` respects the order of railties.
|
401
|
-
|
402
|
-
*Arun Agrawal*
|
403
|
-
|
404
|
-
|
405
|
-
## Rails 4.1.5 (August 18, 2014) ##
|
406
|
-
|
407
|
-
* No changes.
|
408
|
-
|
409
|
-
|
410
|
-
## Rails 4.1.4 (July 2, 2014) ##
|
411
|
-
|
412
|
-
* Fix regression added from the latest security fix.
|
413
|
-
|
414
|
-
*Sean Griffin*, *Matthew Draper*
|
415
|
-
|
416
|
-
|
417
|
-
## Rails 4.1.3 (July 2, 2014) ##
|
418
|
-
|
419
|
-
* Fix SQL Injection Vulnerability in 'range' quoting.
|
420
|
-
|
421
|
-
Fixes CVE-2014-3483
|
422
|
-
|
423
|
-
*Rafael Mendonça França*
|
424
|
-
|
425
|
-
|
426
|
-
## Rails 4.1.2 (June 26, 2014) ##
|
427
|
-
|
428
|
-
* Fix regression on eager loading association based on SQL query rather than
|
429
|
-
existing column.
|
430
|
-
|
431
|
-
Fixes #15480.
|
3
|
+
* No changes.
|
432
4
|
|
433
|
-
*Lauro Caetano*, *Carlos Antonio da Silva*
|
434
5
|
|
435
|
-
|
436
|
-
Fixing regression case, where redefining the same has_an_belongs_to_many
|
437
|
-
definition into a subclass would raise.
|
6
|
+
## Rails 4.2.11.2 (May 15, 2020) ##
|
438
7
|
|
439
|
-
|
8
|
+
* No changes.
|
440
9
|
|
441
|
-
*arthurnn*
|
442
10
|
|
443
|
-
|
444
|
-
When defining a has_and_belongs_to_many, internally we convert that to two has_many.
|
445
|
-
But as `reflections` is a public API, people expect to see the right macro.
|
11
|
+
## Rails 4.2.11.1 (March 11, 2019) ##
|
446
12
|
|
447
|
-
|
13
|
+
* No changes.
|
448
14
|
|
449
|
-
*arthurnn*
|
450
15
|
|
451
|
-
|
16
|
+
## Rails 4.2.11 (November 27, 2018) ##
|
452
17
|
|
453
|
-
|
18
|
+
* No changes.
|
454
19
|
|
455
|
-
*Godfrey Chan*
|
456
20
|
|
457
|
-
|
458
|
-
`update_column`.
|
21
|
+
## Rails 4.2.10 (September 27, 2017) ##
|
459
22
|
|
460
|
-
|
23
|
+
* `Relation#joins` is no longer affected by the target model's
|
24
|
+
`current_scope`, with the exception of `unscoped`.
|
461
25
|
|
462
|
-
|
463
|
-
on a NullRelation should return a Hash.
|
26
|
+
Fixes #29338.
|
464
27
|
|
465
|
-
*
|
28
|
+
*Sean Griffin*
|
466
29
|
|
467
|
-
|
30
|
+
## Rails 4.2.9 (June 26, 2017) ##
|
468
31
|
|
469
|
-
|
32
|
+
* Fix regression caused by `collection_singular_ids=` ignoring different primary key on relationship.
|
470
33
|
|
471
|
-
*
|
34
|
+
*Nick Pezza*
|
472
35
|
|
473
|
-
*
|
474
|
-
table inside a schema.
|
36
|
+
* Fix `rake db:schema:load` with subdirectories.
|
475
37
|
|
476
|
-
|
38
|
+
*Ryuta Kamizono*
|
477
39
|
|
478
|
-
|
40
|
+
* Fix `rake db:migrate:status` with subdirectories.
|
479
41
|
|
480
|
-
*
|
481
|
-
extension names in PostgreSQL when migrating.
|
42
|
+
*Ryuta Kamizono*
|
482
43
|
|
483
|
-
|
44
|
+
* Fix regression of #1969 with SELECT aliases in HAVING clause.
|
484
45
|
|
485
|
-
*
|
486
|
-
their limit dropped from the schema.
|
46
|
+
*Eugene Kenny*
|
487
47
|
|
488
|
-
|
48
|
+
* Fix `wait_timeout` to configurable for mysql2 adapter.
|
489
49
|
|
490
|
-
|
50
|
+
Fixes #26556.
|
491
51
|
|
492
|
-
*
|
493
|
-
association.
|
52
|
+
*Ryuta Kamizono*
|
494
53
|
|
495
|
-
|
54
|
+
* Make `table_name=` reset current statement cache,
|
55
|
+
so queries are not run against the previous table name.
|
496
56
|
|
497
|
-
*
|
57
|
+
*namusyaka*
|
498
58
|
|
499
|
-
* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
|
500
|
-
strings in column names as equal.
|
501
59
|
|
502
|
-
|
503
|
-
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
504
|
-
throw a `StatementInvalid` exception.
|
60
|
+
## Rails 4.2.8 (February 21, 2017) ##
|
505
61
|
|
506
|
-
|
62
|
+
* Using a mysql2 connection after it fails to reconnect will now have an error message
|
63
|
+
saying the connection is closed rather than an undefined method error message.
|
507
64
|
|
508
|
-
*
|
509
|
-
attributes defined in parent classes.
|
65
|
+
*Dylan Thacker-Smith*
|
510
66
|
|
511
|
-
|
67
|
+
* Bust Model.attribute_names cache when resetting column information
|
512
68
|
|
513
|
-
*
|
69
|
+
*James Coleman*
|
514
70
|
|
515
|
-
*
|
71
|
+
* Fix query caching when type information is reset
|
516
72
|
|
517
|
-
|
73
|
+
Backports ancillary fix in 5.0.
|
518
74
|
|
519
|
-
*
|
75
|
+
*James Coleman*
|
520
76
|
|
521
|
-
*
|
522
|
-
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
77
|
+
* Allow `joins` to be unscoped.
|
523
78
|
|
524
|
-
|
79
|
+
Fixes #13775.
|
525
80
|
|
526
|
-
|
527
|
-
Point.create(value: 1.0/0)
|
528
|
-
Point.last.value # => 0.0
|
81
|
+
*Takashi Kokubun*
|
529
82
|
|
530
|
-
|
531
|
-
|
532
|
-
Point.last.value # => Infinity
|
83
|
+
* Hashes can once again be passed to setters of `composed_of`, if all of the
|
84
|
+
mapping methods are methods implemented on `Hash`.
|
533
85
|
|
534
|
-
|
86
|
+
Fixes #25978.
|
535
87
|
|
536
|
-
*
|
88
|
+
*Sean Griffin*
|
537
89
|
|
538
|
-
Fixes #10410.
|
539
90
|
|
540
|
-
|
91
|
+
## Rails 4.2.7 (July 12, 2016) ##
|
541
92
|
|
542
|
-
*
|
93
|
+
* Inspecting an object with an associated array of over 10 elements no longer
|
94
|
+
truncates the array, preventing `inspect` from looping infinitely in some
|
95
|
+
cases.
|
543
96
|
|
544
|
-
|
545
|
-
size calculation if the collection is not cached or loaded.
|
97
|
+
*Kevin McPhillips*
|
546
98
|
|
547
|
-
|
99
|
+
* Ensure hashes can be assigned to attributes created using `composed_of`.
|
100
|
+
Fixes #25210.
|
548
101
|
|
549
|
-
*
|
102
|
+
*Sean Griffin*
|
550
103
|
|
551
|
-
*
|
104
|
+
* Queries such as `Computer.joins(:monitor).group(:status).count` will now be
|
105
|
+
interpreted as `Computer.joins(:monitor).group('computers.status').count`
|
106
|
+
so that when `Computer` and `Monitor` have both `status` columns we don't
|
107
|
+
have conflicts in projection.
|
552
108
|
|
553
|
-
|
554
|
-
In 4.0 series it is delegated to `Array#join`.
|
109
|
+
*Rafael Sales*
|
555
110
|
|
556
|
-
|
111
|
+
* ActiveRecord::Relation#count: raise an ArgumentError when finder options
|
112
|
+
are specified or an ActiveRecord::StatementInvalid when an invalid type
|
113
|
+
is provided for a column name (e.g. a Hash).
|
557
114
|
|
558
|
-
|
115
|
+
Fixes #20434
|
559
116
|
|
560
|
-
|
561
|
-
in that column, the SQL logger would throw an exception when trying
|
562
|
-
to log that nil value. This only occurs when updating a record
|
563
|
-
that already has a non-nil value in that column since an initial nil
|
564
|
-
value isn't included in the SQL anyway (at least, when dirty checking
|
565
|
-
is enabled.) The column's new value will now be logged as `<NULL binary data>`
|
566
|
-
to parallel the existing `<N bytes of binary data>` for non-nil values.
|
117
|
+
*Konstantinos Rousis*
|
567
118
|
|
568
|
-
|
119
|
+
* Correctly pass MySQL options when using structure_dump or structure_load
|
569
120
|
|
570
|
-
|
121
|
+
Specifically, it fixes an issue when using SSL authentication.
|
571
122
|
|
572
|
-
|
573
|
-
was ignored and overwritten by strict mode option.
|
123
|
+
*Alex Coomans*
|
574
124
|
|
575
|
-
Fixes #14895.
|
576
125
|
|
577
|
-
|
126
|
+
## Rails 4.2.6 (March 07, 2016) ##
|
578
127
|
|
579
|
-
*
|
128
|
+
* Fix a bug where using `t.foreign_key` twice with the same `to_table` within
|
129
|
+
the same table definition would only create one foreign key.
|
580
130
|
|
581
|
-
|
131
|
+
*George Millo*
|
582
132
|
|
583
|
-
|
133
|
+
* Fix regression in dirty attribute tracking after #dup. Changes to the
|
134
|
+
clone no longer show as changed attributes in the original object.
|
584
135
|
|
585
|
-
*
|
136
|
+
*Dominic Cleal*
|
586
137
|
|
587
|
-
|
138
|
+
* Fix regression when loading fixture files with symbol keys.
|
588
139
|
|
589
|
-
|
590
|
-
on Reflections. This causes a problem when rails loads fixtures, because it
|
591
|
-
uses the reflections to set database with fixtures.
|
140
|
+
Closes #22584.
|
592
141
|
|
593
|
-
|
142
|
+
*Yves Senn*
|
594
143
|
|
595
|
-
|
144
|
+
* Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
|
596
145
|
|
597
|
-
|
146
|
+
Fixes #22346.
|
598
147
|
|
599
|
-
|
148
|
+
*Nick Muerdter*, *ckoenig*
|
600
149
|
|
601
|
-
|
150
|
+
* Introduce `connection.data_sources` and `connection.data_source_exists?`.
|
151
|
+
These methods determine what relations can be used to back Active Record
|
152
|
+
models (usually tables and views).
|
602
153
|
|
603
|
-
*
|
154
|
+
*Yves Senn*, *Matthew Draper*
|
604
155
|
|
605
|
-
Fixes #14752.
|
606
156
|
|
607
|
-
|
157
|
+
## Rails 4.2.5.2 (February 26, 2016) ##
|
608
158
|
|
609
|
-
*
|
159
|
+
* No changes.
|
610
160
|
|
611
|
-
If a `has_many` association is adjusted using a scope, and another `has_many :through`
|
612
|
-
uses this association, then the scope adjustment is unexpectedly neglected.
|
613
161
|
|
614
|
-
|
162
|
+
## Rails 4.2.5.1 (January 25, 2015) ##
|
615
163
|
|
616
|
-
|
164
|
+
* No changes.
|
617
165
|
|
618
|
-
* When a destroyed record is duped, the dup is not `destroyed?`.
|
619
166
|
|
620
|
-
|
167
|
+
## Rails 4.2.5 (November 12, 2015) ##
|
621
168
|
|
622
|
-
*
|
169
|
+
* No longer pass deprecated option `-i` to `pg_dump`.
|
623
170
|
|
624
|
-
|
171
|
+
*Paul Sadauskas*
|
625
172
|
|
626
|
-
|
173
|
+
* Set `scope.reordering_value` to `true` if :reordering values are specified.
|
627
174
|
|
628
|
-
|
629
|
-
generates a SQL statement containing each id of the collection:
|
175
|
+
Fixes #21886.
|
630
176
|
|
631
|
-
|
177
|
+
*Hiroaki Izu*
|
632
178
|
|
633
|
-
|
634
|
-
|
179
|
+
* Avoid disabling errors on the PostgreSQL connection when enabling the
|
180
|
+
standard_conforming_strings setting. Errors were previously disabled because
|
181
|
+
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
|
182
|
+
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
|
183
|
+
setting exists. Disabling errors caused problems when using a connection
|
184
|
+
pooling tool like PgBouncer because it's not guaranteed to have the same
|
185
|
+
connection between calls to `execute` and it could leave the connection
|
186
|
+
with errors disabled.
|
635
187
|
|
636
|
-
|
188
|
+
Fixes #22101.
|
637
189
|
|
638
|
-
|
190
|
+
*Harry Marr*
|
639
191
|
|
640
|
-
|
192
|
+
* Includes HABTM returns correct size now. It's caused by the join dependency
|
193
|
+
only instantiates one HABTM object because the join table hasn't a primary key.
|
641
194
|
|
642
|
-
|
195
|
+
Fixes #16032.
|
643
196
|
|
644
|
-
|
197
|
+
Examples:
|
645
198
|
|
646
|
-
|
199
|
+
before:
|
647
200
|
|
648
|
-
|
201
|
+
Project.first.salaried_developers.size # => 3
|
202
|
+
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
649
203
|
|
650
|
-
|
204
|
+
after:
|
651
205
|
|
652
|
-
|
206
|
+
Project.first.salaried_developers.size # => 3
|
207
|
+
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
653
208
|
|
654
|
-
*
|
209
|
+
*Bigxiang*
|
655
210
|
|
656
|
-
|
211
|
+
* Descriptive error message when fixtures contain a missing column.
|
657
212
|
|
658
|
-
|
659
|
-
# => true
|
660
|
-
Post.where(author_id: author.id) == author.posts
|
661
|
-
# => true
|
213
|
+
Closes #21201.
|
662
214
|
|
663
|
-
|
215
|
+
*Yves Senn*
|
664
216
|
|
665
|
-
|
217
|
+
* `bin/rake db:migrate` uses
|
218
|
+
`ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
|
219
|
+
`Migrator.migrations_paths`.
|
666
220
|
|
667
|
-
*
|
221
|
+
*Tobias Bielohlawek*
|
668
222
|
|
669
|
-
|
223
|
+
* Fix `rewhere` in a `has_many` association.
|
670
224
|
|
671
|
-
|
225
|
+
Fixes #21955.
|
672
226
|
|
673
|
-
*
|
674
|
-
which created invalid SQL.
|
227
|
+
*Josh Branchaud*, *Kal*
|
675
228
|
|
676
|
-
|
229
|
+
* Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
|
230
|
+
drying up Kernel.system() calls within this namespace and to avoid
|
231
|
+
shell expansion by using a paramter list instead of string as arguments
|
232
|
+
for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
|
233
|
+
test units passing.
|
677
234
|
|
678
|
-
*
|
235
|
+
*Bryan Paxton*
|
679
236
|
|
680
|
-
*
|
237
|
+
* Avoid leaking the first relation we call `first` on, per model.
|
681
238
|
|
682
|
-
Fixes #
|
239
|
+
Fixes #21921.
|
683
240
|
|
684
|
-
*
|
241
|
+
*Matthew Draper*, *Jean Boussier*
|
685
242
|
|
686
|
-
*
|
243
|
+
* Allow deserialization of Active Record models that were YAML encoded prior
|
244
|
+
to Rails 4.2
|
687
245
|
|
688
|
-
|
246
|
+
*Sean Griffin*
|
689
247
|
|
690
|
-
|
248
|
+
* Correctly apply `unscope` when preloading through associations.
|
691
249
|
|
692
|
-
*
|
693
|
-
could previously have incorrectly accrued additional conditions (e.g. as a result of
|
694
|
-
a previous query). CollectionProxy now always defers to the association scope's
|
695
|
-
`arel` method so the (incorrect) inherited one should be entirely concealed.
|
250
|
+
*Jimmy Bourassa*
|
696
251
|
|
697
|
-
|
252
|
+
* Ensure `select` quotes aliased attributes, even when using `from`.
|
698
253
|
|
699
|
-
|
254
|
+
Fixes #21488
|
700
255
|
|
701
|
-
*
|
256
|
+
*Sean Griffin & @johanlunds*
|
702
257
|
|
703
|
-
|
258
|
+
* Correct query for PostgreSQL 8.2 compatibility.
|
704
259
|
|
705
|
-
*
|
260
|
+
*Ben Murphy*, *Matthew Draper*
|
706
261
|
|
707
|
-
*
|
262
|
+
* Uniqueness validator raises descriptive error when running on a persisted
|
263
|
+
record without primary key.
|
708
264
|
|
709
|
-
|
265
|
+
Closes #21304.
|
710
266
|
|
711
|
-
*
|
267
|
+
*Yves Senn*
|
712
268
|
|
713
|
-
* Fixed error where .persisted? throws SystemStackError for an unsaved model with a
|
714
|
-
custom primary key that didn't save due to validation error.
|
715
269
|
|
716
|
-
|
270
|
+
## Rails 4.2.4 (August 24, 2015) ##
|
717
271
|
|
718
|
-
|
272
|
+
* Skip statement cache on through association reader.
|
719
273
|
|
720
|
-
|
721
|
-
|
274
|
+
If the through class has default scopes we should skip the statement
|
275
|
+
cache.
|
722
276
|
|
723
|
-
|
277
|
+
Closes #20745.
|
724
278
|
|
725
|
-
*
|
279
|
+
*Rafael Mendonça França*
|
726
280
|
|
727
|
-
*
|
281
|
+
* Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
|
282
|
+
the limit: 8 was not coming through. This caused it to become Int[] data type
|
283
|
+
after doing a rebuild off of schema.rb.
|
728
284
|
|
729
|
-
|
285
|
+
*Jake Waller*
|
730
286
|
|
731
|
-
|
287
|
+
* Fix state being carried over from previous transaction.
|
732
288
|
|
733
|
-
|
734
|
-
|
735
|
-
`has_one` object did not get saved to the db.
|
289
|
+
Considering the following example where `name` is a required attribute.
|
290
|
+
Before we had `new_record?` returning `true` for a persisted record:
|
736
291
|
|
737
|
-
|
292
|
+
author = Author.create! name: 'foo'
|
293
|
+
author.name = nil
|
294
|
+
author.save # => false
|
295
|
+
author.new_record? # => true
|
738
296
|
|
297
|
+
Fixes #20824.
|
739
298
|
|
740
|
-
|
299
|
+
*Roque Pinel*
|
741
300
|
|
742
|
-
*
|
301
|
+
* Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
|
302
|
+
when validating associations.
|
743
303
|
|
304
|
+
Fixes #20882.
|
744
305
|
|
745
|
-
|
306
|
+
*Sean Griffin*
|
746
307
|
|
747
|
-
*
|
748
|
-
|
308
|
+
* Fix through associations using scopes having the scope merged multiple
|
309
|
+
times.
|
749
310
|
|
750
|
-
Fixes #
|
311
|
+
Fixes #20721.
|
312
|
+
Fixes #20727.
|
751
313
|
|
752
|
-
*
|
314
|
+
*Sean Griffin*
|
753
315
|
|
316
|
+
* `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
|
317
|
+
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
754
318
|
|
755
|
-
|
319
|
+
Fixes #20743.
|
756
320
|
|
757
|
-
|
321
|
+
*Yves Senn*
|
758
322
|
|
759
|
-
|
323
|
+
* Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
|
324
|
+
a wrong type to a namespaced association.
|
760
325
|
|
761
|
-
|
326
|
+
Fixes #20545.
|
762
327
|
|
763
|
-
*
|
764
|
-
authority.
|
328
|
+
*Diego Carrion*
|
765
329
|
|
766
|
-
|
767
|
-
|
330
|
+
* Prevent error when using `force_reload: true` on an unassigned polymorphic
|
331
|
+
belongs_to association.
|
768
332
|
|
769
|
-
|
770
|
-
sqlite3:relative/path
|
771
|
-
sqlite3:/full/path
|
333
|
+
Fixes #20426.
|
772
334
|
|
773
|
-
|
774
|
-
as it did in Rails 4.0, but with a deprecation warning: in the next
|
775
|
-
release, that spelling will instead be interpreted as an absolute
|
776
|
-
path.
|
335
|
+
*James Dabbs*
|
777
336
|
|
778
|
-
*Matthew Draper*
|
779
337
|
|
780
|
-
|
338
|
+
## Rails 4.2.3 (June 25, 2015) ##
|
781
339
|
|
782
|
-
|
340
|
+
* Let `WITH` queries (Common Table Expressions) be explainable.
|
783
341
|
|
784
|
-
*
|
342
|
+
*Vladimir Kochnev*
|
785
343
|
|
786
|
-
*
|
787
|
-
joins are involved.
|
344
|
+
* Fix n+1 query problem when eager loading nil associations (fixes #18312)
|
788
345
|
|
789
|
-
|
346
|
+
*Sammy Larbi*
|
790
347
|
|
791
|
-
|
348
|
+
* Fixed an error which would occur in dirty checking when calling
|
349
|
+
`update_attributes` from a getter.
|
792
350
|
|
793
|
-
|
794
|
-
value for any enum attribute is always evaluated as 0 during
|
795
|
-
uniqueness validation.
|
351
|
+
Fixes #20531.
|
796
352
|
|
797
|
-
|
353
|
+
*Sean Griffin*
|
798
354
|
|
799
|
-
|
355
|
+
* Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
|
356
|
+
as columns.
|
800
357
|
|
801
|
-
|
802
|
-
`has_and_belongs_to_many` assocations *and* on `has_many :through`
|
803
|
-
associations. Before this change, `before_add` callbacks would be fired
|
804
|
-
before the record was saved on `has_and_belongs_to_many` associations, but
|
805
|
-
*not* on `has_many :through` associations.
|
358
|
+
Fixes #20360.
|
806
359
|
|
807
|
-
|
360
|
+
*Sean Griffin*
|
808
361
|
|
809
|
-
*
|
810
|
-
conflicting private method defined on its ancestors.
|
362
|
+
* Clear query cache when `ActiveRecord::Base#reload` is called.
|
811
363
|
|
812
|
-
|
364
|
+
*Shane Hender*
|
813
365
|
|
814
|
-
|
366
|
+
* Pass `:extend` option for `has_and_belongs_to_many` associations to the
|
367
|
+
underlying `has_many :through`.
|
815
368
|
|
816
|
-
*
|
369
|
+
*Jaehyun Shin*
|
817
370
|
|
818
|
-
|
819
|
-
it was overriden by chained conditions in the same field. Now it
|
820
|
-
is merged like any other scope.
|
371
|
+
* Make `unscope` aware of "less than" and "greater than" conditions.
|
821
372
|
|
822
|
-
|
373
|
+
*TAKAHASHI Kazuaki*
|
823
374
|
|
824
|
-
|
825
|
-
|
826
|
-
scope :active, -> { where state: 'active' }
|
827
|
-
scope :inactive, -> { where state: 'inactive' }
|
828
|
-
end
|
375
|
+
* Revert behavior of `db:schema:load` back to loading the full
|
376
|
+
environment. This ensures that initializers are run.
|
829
377
|
|
830
|
-
|
831
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
|
378
|
+
Fixes #19545.
|
832
379
|
|
833
|
-
|
834
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
|
380
|
+
*Yves Senn*
|
835
381
|
|
836
|
-
|
837
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
|
382
|
+
* Fix missing index when using `timestamps` with the `index` option.
|
838
383
|
|
839
|
-
|
384
|
+
The `index` option used with `timestamps` should be passed to both
|
385
|
+
`column` definitions for `created_at` and `updated_at` rather than just
|
386
|
+
the first.
|
840
387
|
|
841
|
-
|
842
|
-
default_scope { where state: 'pending' }
|
843
|
-
scope :active, -> { where state: 'active' }
|
844
|
-
scope :inactive, -> { where state: 'inactive' }
|
845
|
-
end
|
388
|
+
*Paul Mucur*
|
846
389
|
|
847
|
-
|
848
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
|
390
|
+
* Rename `:class` to `:anonymous_class` in association options.
|
849
391
|
|
850
|
-
|
851
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'active'
|
392
|
+
Fixes #19659.
|
852
393
|
|
853
|
-
|
854
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'inactive'
|
394
|
+
*Andrew White*
|
855
395
|
|
856
|
-
|
857
|
-
|
858
|
-
`except`.
|
396
|
+
* Fixed a bug where uniqueness validations would error on out of range values,
|
397
|
+
even if an validation should have prevented it from hitting the database.
|
859
398
|
|
860
|
-
|
399
|
+
*Andrey Voronkov*
|
861
400
|
|
862
|
-
|
863
|
-
|
864
|
-
scope :active, -> { unscope(where: :state).where(state: 'active') }
|
865
|
-
scope :inactive, -> { rewhere state: 'inactive' }
|
866
|
-
end
|
401
|
+
* Foreign key related methods in the migration DSL respect
|
402
|
+
`ActiveRecord::Base.pluralize_table_names = false`.
|
867
403
|
|
868
|
-
|
869
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
|
404
|
+
Fixes #19643.
|
870
405
|
|
871
|
-
|
872
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
|
406
|
+
*Mehmet Emin İNAÇ*
|
873
407
|
|
874
|
-
|
875
|
-
# SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
|
408
|
+
* Reduce memory usage from loading types on pg.
|
876
409
|
|
877
|
-
|
410
|
+
Fixes #19578.
|
878
411
|
|
879
|
-
|
412
|
+
*Sean Griffin*
|
880
413
|
|
881
|
-
|
414
|
+
* Fix referencing wrong table aliases while joining tables of has many through
|
415
|
+
association (only when calling calculation methods).
|
882
416
|
|
883
|
-
|
884
|
-
in multi-threaded environments.
|
417
|
+
Fixes #19276.
|
885
418
|
|
886
|
-
|
419
|
+
*pinglamb*
|
887
420
|
|
888
|
-
|
421
|
+
* Don't attempt to update counter caches, when the column wasn't selected.
|
889
422
|
|
890
|
-
|
891
|
-
the columns.
|
423
|
+
Fixes #19437.
|
892
424
|
|
893
|
-
|
894
|
-
explicitly named then reverting the migration adding the named one
|
895
|
-
would instead drop the unnamed one.
|
425
|
+
*Sean Griffin*
|
896
426
|
|
897
|
-
|
898
|
-
|
427
|
+
* Correctly persist a serialized attribute that has been returned to
|
428
|
+
its default value by an in-place modification.
|
899
429
|
|
900
|
-
|
430
|
+
Fixes #19467.
|
901
431
|
|
902
|
-
*
|
432
|
+
*Matthew Draper*
|
903
433
|
|
904
|
-
|
905
|
-
which is true by default. Now schema dump does not happen at the
|
906
|
-
end of migration rake task if `dump_schema_after_migration` is false.
|
434
|
+
* Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
|
907
435
|
|
908
|
-
*
|
436
|
+
*James Cox*
|
909
437
|
|
910
|
-
*
|
911
|
-
|
438
|
+
* Dont enroll records in the transaction if they dont have commit callbacks.
|
439
|
+
That was causing a memory grow problem when creating a lot of records inside a transaction.
|
912
440
|
|
913
|
-
|
441
|
+
Fixes #15549.
|
914
442
|
|
915
|
-
*
|
443
|
+
*Will Bryant*, *Aaron Patterson*
|
916
444
|
|
917
|
-
*
|
445
|
+
* Correctly create through records when created on a has many through
|
446
|
+
association when using `where`.
|
918
447
|
|
919
|
-
|
920
|
-
of the transaction level state, and it was leaking that state.
|
448
|
+
Fixes #19073.
|
921
449
|
|
922
|
-
|
450
|
+
*Sean Griffin*
|
923
451
|
|
924
|
-
*arthurnn*
|
925
452
|
|
926
|
-
|
927
|
-
the underlying `has_many :through` association.
|
453
|
+
## Rails 4.2.2 (June 16, 2015) ##
|
928
454
|
|
929
|
-
|
455
|
+
* No Changes *
|
930
456
|
|
931
|
-
*Yves Senn*
|
932
457
|
|
933
|
-
|
458
|
+
## Rails 4.2.1 (March 19, 2015) ##
|
934
459
|
|
935
|
-
|
936
|
-
not supported by the ActiveRecord schema dumper. For example, expressions
|
937
|
-
indexes would not be detected.
|
460
|
+
* Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
|
938
461
|
|
939
|
-
Fixes #
|
462
|
+
Fixes #17139.
|
940
463
|
|
941
|
-
*
|
464
|
+
*Miklos Fazekas*
|
942
465
|
|
943
|
-
*
|
466
|
+
* `remove_reference` with `foreign_key: true` removes the foreign key before
|
467
|
+
removing the column. This fixes a bug where it was not possible to remove
|
468
|
+
the column on MySQL.
|
944
469
|
|
945
|
-
|
946
|
-
would be `["1","2","3"]`, removing the empty strings from the array,
|
947
|
-
which would be incorrect. Now it will correctly produce `["1","","2","","3"]`
|
948
|
-
as the result of parsing the above PostgreSQL array.
|
470
|
+
Fixes #18664.
|
949
471
|
|
950
|
-
|
472
|
+
*Yves Senn*
|
951
473
|
|
952
|
-
|
474
|
+
* Add a `:foreign_key` option to `references` and associated migration
|
475
|
+
methods. The model and migration generators now use this option, rather than
|
476
|
+
the `add_foreign_key` form.
|
953
477
|
|
954
|
-
*
|
478
|
+
*Sean Griffin*
|
955
479
|
|
956
|
-
|
957
|
-
defined by `ActiveRecord::Base`.
|
480
|
+
* Fix rounding problem for PostgreSQL timestamp column.
|
958
481
|
|
959
|
-
|
482
|
+
If timestamp column have the precision, it need to format according to
|
483
|
+
the precision of timestamp column.
|
960
484
|
|
961
|
-
|
962
|
-
has_many :errors
|
963
|
-
end
|
964
|
-
# Will raise ArgumentError.
|
485
|
+
*Ryuta Kamizono*
|
965
486
|
|
966
|
-
|
487
|
+
* Respect the database default charset for `schema_migrations` table.
|
967
488
|
|
968
|
-
|
489
|
+
The charset of `version` column in `schema_migrations` table is depend
|
490
|
+
on the database default charset and collation rather than the encoding
|
491
|
+
of the connection.
|
969
492
|
|
970
|
-
*
|
971
|
-
When `select_*` methods receive a `Relation` object, they should be able to
|
972
|
-
get the arel/binds from it.
|
973
|
-
Also fix regressions on `select_rows` that was ignoring the binds.
|
493
|
+
*Ryuta Kamizono*
|
974
494
|
|
975
|
-
|
495
|
+
* Respect custom primary keys for associations when calling `Relation#where`
|
976
496
|
|
977
|
-
|
497
|
+
Fixes #18813.
|
978
498
|
|
979
|
-
*
|
980
|
-
without issues.
|
499
|
+
*Sean Griffin*
|
981
500
|
|
982
|
-
|
983
|
-
|
984
|
-
dump due to the fields not being correctly serialized before being dumped
|
985
|
-
to YAML. Now it is possible to dump and load the same object as many times
|
986
|
-
as needed without any issues.
|
501
|
+
* Fixed several edge cases which could result in a counter cache updating
|
502
|
+
twice or not updating at all for `has_many` and `has_many :through`.
|
987
503
|
|
988
|
-
Fixes #
|
504
|
+
Fixes #10865.
|
989
505
|
|
990
|
-
*
|
506
|
+
*Sean Griffin*
|
991
507
|
|
992
|
-
*
|
993
|
-
|
508
|
+
* Foreign keys added by migrations were given random, generated names. This
|
509
|
+
meant a different `structure.sql` would be generated every time a developer
|
510
|
+
ran migrations on their machine.
|
994
511
|
|
995
|
-
|
512
|
+
The generated part of foreign key names is now a hash of the table name and
|
513
|
+
column name, which is consistent every time you run the migration.
|
996
514
|
|
997
|
-
*
|
515
|
+
*Chris Sinjakli*
|
998
516
|
|
999
|
-
|
1000
|
-
with methods defined within `ActiveRecord::Base` but not its ancestors,
|
1001
|
-
as well as conflicts with methods generated by other enums on the same
|
1002
|
-
class.
|
517
|
+
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
1003
518
|
|
1004
|
-
|
519
|
+
SplitTest.group(:key).count
|
520
|
+
Property.group(:value).count
|
1005
521
|
|
1006
|
-
*
|
522
|
+
*Bogdan Gusiev*
|
1007
523
|
|
1008
|
-
*
|
524
|
+
* Don't define autosave association callbacks twice from
|
525
|
+
`accepts_nested_attributes_for`.
|
1009
526
|
|
1010
|
-
|
1011
|
-
dangerous if it conflicts with an existing class method defined within
|
1012
|
-
`ActiveRecord::Base` but not its ancestors.
|
527
|
+
Fixes #18704.
|
1013
528
|
|
1014
|
-
|
529
|
+
*Sean Griffin*
|
1015
530
|
|
1016
|
-
|
531
|
+
* Integer types will no longer raise a `RangeError` when assigning an
|
532
|
+
attribute, but will instead raise when going to the database.
|
1017
533
|
|
1018
|
-
|
534
|
+
Fixes several vague issues which were never reported directly. See the
|
535
|
+
commit message from the commit which added this line for some examples.
|
1019
536
|
|
1020
|
-
|
1021
|
-
# Before: SELECT * ... LIMIT 1 FOR UPDATE
|
1022
|
-
# After: SELECT * ... LIMIT 1 FOR SHARE NOWAIT
|
537
|
+
*Sean Griffin*
|
1023
538
|
|
1024
|
-
|
539
|
+
* Values which would error while being sent to the database (such as an
|
540
|
+
ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
|
541
|
+
assignment. They will still error when sent to the database, but you are
|
542
|
+
given the ability to re-assign it to a valid value.
|
1025
543
|
|
1026
|
-
|
544
|
+
Fixes #18580.
|
1027
545
|
|
1028
|
-
*
|
546
|
+
*Sean Griffin*
|
1029
547
|
|
1030
|
-
|
548
|
+
* Don't remove join dependencies in `Relation#exists?`
|
1031
549
|
|
1032
|
-
|
550
|
+
Fixes #18632.
|
1033
551
|
|
1034
|
-
|
552
|
+
*Sean Griffin*
|
1035
553
|
|
1036
|
-
|
1037
|
-
post.comments.reset
|
1038
|
-
post.comments.loaded? # => true
|
554
|
+
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
1039
555
|
|
1040
|
-
|
556
|
+
Fixes #18629.
|
1041
557
|
|
1042
|
-
|
1043
|
-
post.comments.reset
|
1044
|
-
post.comments.loaded? # => false
|
558
|
+
*Sean Griffin*
|
1045
559
|
|
1046
|
-
|
560
|
+
* No longer issue deprecation warning when including a scope with extensions.
|
561
|
+
Previously every scope with extension methods was transformed into an
|
562
|
+
instance dependent scope. Including such a scope would wrongfully issue a
|
563
|
+
deprecation warning. This is no longer the case.
|
1047
564
|
|
1048
|
-
|
565
|
+
Fixes #18467.
|
1049
566
|
|
1050
|
-
*
|
567
|
+
*Yves Senn*
|
1051
568
|
|
1052
|
-
|
569
|
+
* Correctly use the type provided by `serialize` when updating records using
|
570
|
+
optimistic locking.
|
1053
571
|
|
1054
|
-
|
1055
|
-
conversation.status = :active
|
1056
|
-
conversation.status = :archived
|
1057
|
-
conversation.status_was # => 0
|
572
|
+
Fixes #18385.
|
1058
573
|
|
1059
|
-
|
574
|
+
*Sean Griffin*
|
1060
575
|
|
1061
|
-
|
1062
|
-
|
1063
|
-
conversation.status = :archived
|
1064
|
-
conversation.status_was # => "active"
|
576
|
+
* `attribute_will_change!` will no longer cause non-persistable attributes to
|
577
|
+
be sent to the database.
|
1065
578
|
|
1066
|
-
|
579
|
+
Fixes #18407.
|
1067
580
|
|
1068
|
-
*
|
1069
|
-
anymore.
|
581
|
+
*Sean Griffin*
|
1070
582
|
|
1071
|
-
|
1072
|
-
consistent results among different database engines. But for singular
|
1073
|
-
associations this behavior is not needed since we will have one record to
|
1074
|
-
return. As this ORDER BY option can lead some performance issues we are
|
1075
|
-
removing it for singular associations accessors.
|
583
|
+
* Format the datetime string according to the precision of the datetime field.
|
1076
584
|
|
1077
|
-
|
585
|
+
Incompatible to rounding behavior between MySQL 5.6 and earlier.
|
1078
586
|
|
1079
|
-
|
587
|
+
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
|
588
|
+
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
1080
589
|
|
1081
|
-
|
590
|
+
http://bugs.mysql.com/bug.php?id=68760
|
1082
591
|
|
1083
|
-
|
592
|
+
*Ryuta Kamizono*
|
1084
593
|
|
1085
|
-
|
1086
|
-
# Before: => SELECT id FROM "posts"
|
1087
|
-
# After: => SELECT "posts"."id" FROM "posts"
|
594
|
+
* Allow precision option for MySQL datetimes.
|
1088
595
|
|
1089
|
-
*
|
596
|
+
*Ryuta Kamizono*
|
1090
597
|
|
1091
|
-
*
|
1092
|
-
in `find_in_batches`.
|
598
|
+
* Clear query cache on rollback.
|
1093
599
|
|
1094
|
-
|
1095
|
-
yielded to the block. This means that you only get it, when you hit the
|
1096
|
-
`batch_size` treshold. This could shadow the issue in development.
|
600
|
+
*Florian Weingarten*
|
1097
601
|
|
1098
|
-
|
602
|
+
* Fixed setting of foreign_key for through associations while building of new record.
|
1099
603
|
|
1100
|
-
|
604
|
+
Fixes #12698.
|
1101
605
|
|
1102
|
-
|
1103
|
-
(`first`, `second`, `third`, `fourth`, and `fifth`) are now available as
|
1104
|
-
full-fledged finders in ActiveRecord. The biggest benefit of this is ordering
|
1105
|
-
of the records returned now defaults to the table's primary key in ascending order.
|
606
|
+
*Ivan Antropov*
|
1106
607
|
|
1107
|
-
|
608
|
+
* Fixed automatic inverse_of for models nested in module.
|
1108
609
|
|
1109
|
-
|
610
|
+
*Andrew McCloud*
|
1110
611
|
|
1111
|
-
|
612
|
+
* Fix `reaping_frequency` option when the value is a string.
|
1112
613
|
|
1113
|
-
|
1114
|
-
# => 'SELECT "users".* FROM "users"'
|
614
|
+
This usually happens when it is configured using `DATABASE_URL`.
|
1115
615
|
|
1116
|
-
|
1117
|
-
# => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1'
|
616
|
+
*korbin*
|
1118
617
|
|
1119
|
-
|
618
|
+
* Fix error message when trying to create an associated record and the foreign
|
619
|
+
key is missing.
|
1120
620
|
|
1121
|
-
|
1122
|
-
# => 'SELECT "users".* FROM "users" LIMIT -1 OFFSET 3' # sqlite3 gem
|
1123
|
-
# => 'SELECT "users".* FROM "users" OFFSET 3' # pg gem
|
1124
|
-
# => 'SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 3' # mysql2 gem
|
621
|
+
Before this fix the following exception was being raised:
|
1125
622
|
|
1126
|
-
|
1127
|
-
# => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 4'
|
623
|
+
NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
|
1128
624
|
|
1129
|
-
|
625
|
+
Now the message is:
|
1130
626
|
|
1131
|
-
|
1132
|
-
models that did not define any transactional callbacks (i.e.
|
1133
|
-
`after_commit`, `after_rollback` or `after_create`).
|
627
|
+
ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
|
1134
628
|
|
1135
|
-
|
629
|
+
*Rafael Mendonça França*
|
1136
630
|
|
1137
|
-
|
631
|
+
* Fix change detection problem for PostgreSQL bytea type and
|
632
|
+
`ArgumentError: string contains null byte` exception with pg-0.18.
|
1138
633
|
|
1139
|
-
|
634
|
+
Fixes #17680.
|
1140
635
|
|
1141
|
-
*
|
636
|
+
*Lars Kanis*
|
1142
637
|
|
1143
|
-
*
|
638
|
+
* When a table has a composite primary key, the `primary_key` method for
|
639
|
+
SQLite3 and PostgreSQL adapters was only returning the first field of the key.
|
640
|
+
Ensures that it will return nil instead, as Active Record doesn't support
|
641
|
+
composite primary keys.
|
1144
642
|
|
1145
|
-
|
643
|
+
Fixes #18070.
|
1146
644
|
|
1147
|
-
*
|
645
|
+
*arthurnn*
|
1148
646
|
|
1149
|
-
*
|
647
|
+
* Ensure `first!` and friends work on loaded associations.
|
1150
648
|
|
1151
|
-
|
1152
|
-
the `inheritance_column` setting doesn't exist. This prevents setting associations
|
1153
|
-
via the attributes hash if the association name clashes with the value of the setting,
|
1154
|
-
typically `:type`. This worked previously in Rails 3.2.
|
649
|
+
Fixes #18237.
|
1155
650
|
|
1156
|
-
*
|
651
|
+
*Sean Griffin*
|
1157
652
|
|
1158
|
-
*
|
653
|
+
* Dump the default `nil` for PostgreSQL UUID primary key.
|
1159
654
|
|
1160
|
-
|
655
|
+
*Ryuta Kamizono*
|
1161
656
|
|
1162
|
-
|
1163
|
-
|
1164
|
-
end
|
657
|
+
* Don't raise when writing an attribute with an out-of-range datetime passed
|
658
|
+
by the user.
|
1165
659
|
|
1166
|
-
|
660
|
+
*Grey Baker*
|
1167
661
|
|
1168
|
-
|
662
|
+
* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
|
663
|
+
be marked as having changed when set to the same negative value.
|
1169
664
|
|
1170
|
-
|
665
|
+
Fixes #18161.
|
1171
666
|
|
1172
|
-
|
667
|
+
*Daniel Fox*
|
1173
668
|
|
1174
|
-
*Godfrey Chan*
|
1175
669
|
|
1176
|
-
|
670
|
+
## Rails 4.2.0 (December 20, 2014) ##
|
1177
671
|
|
1178
|
-
|
672
|
+
* Introduce `force: :cascade` option for `create_table`. Using this option
|
673
|
+
will recreate tables even if they have dependent objects (like foreign keys).
|
674
|
+
`db/schema.rb` now uses `force: :cascade`. This makes it possible to
|
675
|
+
reload the schema when foreign keys are in place.
|
1179
676
|
|
1180
|
-
*
|
677
|
+
*Matthew Draper*, *Yves Senn*
|
1181
678
|
|
1182
|
-
|
679
|
+
* `db:schema:load` and `db:structure:load` no longer purge the database
|
680
|
+
before loading the schema. This is left for the user to do.
|
681
|
+
`db:test:prepare` will still purge the database.
|
1183
682
|
|
1184
|
-
|
683
|
+
Fixes #17945.
|
1185
684
|
|
1186
|
-
*
|
1187
|
-
`DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
|
1188
|
-
reading in `database.yml` and setting Active Record appropriately. Active Record
|
1189
|
-
expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
|
1190
|
-
rip out this functionality without deprecating. This presents a problem though
|
1191
|
-
when both config is set, and a `DATABASE_URL` is present. Currently the
|
1192
|
-
`DATABASE_URL` should "win" and none of the values in `database.yml` are
|
1193
|
-
used. This is somewhat unexpected, if one were to set values such as
|
1194
|
-
`pool` in the `production:` group of `database.yml` they are ignored.
|
685
|
+
*Yves Senn*
|
1195
686
|
|
1196
|
-
|
687
|
+
* Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
|
1197
688
|
|
1198
|
-
|
1199
|
-
- `rake db:<tasks>`
|
1200
|
-
- `ActiveRecord.establish_connection`
|
689
|
+
*Ryuta Kamizono*
|
1201
690
|
|
1202
|
-
|
1203
|
-
- `rake db:<tasks>`
|
1204
|
-
- `rails <server> | <console>`
|
1205
|
-
- `rails dbconsole`
|
691
|
+
* Add `foreign_type` option to `has_one` and `has_many` association macros.
|
1206
692
|
|
1207
|
-
|
1208
|
-
this is to put all of this logic in one place so it is guaranteed to be used.
|
693
|
+
This option enables to define the column name of associated object's type for polymorphic associations.
|
1209
694
|
|
1210
|
-
|
695
|
+
*Ulisses Almeida, Kassio Borges*
|
1211
696
|
|
1212
|
-
|
1213
|
-
|
1214
|
-
No DATABASE_URL
|
1215
|
-
=> Error
|
1216
|
-
```
|
697
|
+
* `add_timestamps` and `remove_timestamps` now properly reversible with
|
698
|
+
options.
|
1217
699
|
|
1218
|
-
|
1219
|
-
database.yml present
|
1220
|
-
No DATABASE_URL
|
1221
|
-
=> Use database.yml configuration
|
1222
|
-
```
|
700
|
+
*Noam Gagliardi-Rabinovich*
|
1223
701
|
|
1224
|
-
|
1225
|
-
No database.yml
|
1226
|
-
DATABASE_URL present
|
1227
|
-
=> use DATABASE_URL configuration
|
1228
|
-
```
|
702
|
+
* Bring back `db:test:prepare` to synchronize the test database schema.
|
1229
703
|
|
1230
|
-
|
1231
|
-
|
1232
|
-
DATABASE_URL present
|
1233
|
-
=> Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
|
1234
|
-
sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
|
1235
|
-
they are discarded as the `url` sub key "wins".
|
1236
|
-
```
|
704
|
+
Manual synchronization using `bin/rake db:test:prepare` is required
|
705
|
+
when a migration is rolled-back, edited and reapplied.
|
1237
706
|
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
707
|
+
`ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
|
708
|
+
to synchronize the schema. Plugins can use this task as a hook to
|
709
|
+
provide custom behavior after the schema has been loaded.
|
1241
710
|
|
1242
|
-
|
1243
|
-
behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
|
711
|
+
NOTE: `test:prepare` runs before the schema is synchronized.
|
1244
712
|
|
1245
|
-
|
713
|
+
Fixes #17171, #15787.
|
1246
714
|
|
1247
|
-
*
|
715
|
+
*Yves Senn*
|
1248
716
|
|
1249
|
-
|
717
|
+
* Change `reflections` public api to return the keys as String objects.
|
1250
718
|
|
1251
|
-
|
719
|
+
Fixes #16928.
|
1252
720
|
|
1253
|
-
|
1254
|
-
create or drop both the test and development databases.
|
721
|
+
*arthurnn*
|
1255
722
|
|
1256
|
-
|
1257
|
-
the test database.
|
723
|
+
* Renaming a table in pg also renames the primary key index.
|
1258
724
|
|
1259
|
-
|
725
|
+
Fixes #12856
|
1260
726
|
|
1261
|
-
*
|
1262
|
-
and it will be included in the announce message.
|
727
|
+
*Sean Griffin*
|
1263
728
|
|
1264
|
-
|
729
|
+
* Make it possible to access fixtures excluded by a `default_scope`.
|
1265
730
|
|
1266
|
-
*
|
1267
|
-
method to retrieve a specific table definition.
|
1268
|
-
This ensures that `change_table` and `create_table` will use
|
1269
|
-
similar objects.
|
731
|
+
*Yves Senn*
|
1270
732
|
|
1271
|
-
|
733
|
+
* Fix preloading of associations with a scope containing joins along with
|
734
|
+
conditions on the joined association.
|
1272
735
|
|
1273
|
-
*
|
736
|
+
*Siddharth Sharma*
|
1274
737
|
|
1275
|
-
*
|
1276
|
-
In case the YAML passed as paramter is nil, uses an empty string.
|
738
|
+
* Add `Table#name` to match `TableDefinition#name`.
|
1277
739
|
|
1278
|
-
|
740
|
+
*Cody Cutrer*
|
1279
741
|
|
1280
|
-
|
742
|
+
* Cache `CollectionAssociation#reader` proxies separately before and after
|
743
|
+
the owner has been saved so that the proxy is not cached without the
|
744
|
+
owner's id.
|
1281
745
|
|
1282
|
-
*
|
1283
|
-
and `ActiveRecord::Base.symbolized_sti_name` without replacement.
|
746
|
+
*Ben Woosley*
|
1284
747
|
|
1285
|
-
|
748
|
+
* `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
|
1286
749
|
|
1287
|
-
*
|
1288
|
-
your test schema, the `rake db:test:*` tasks are deprecated. This
|
1289
|
-
doesn't stop you manually running other tasks on your test database
|
1290
|
-
if needed:
|
750
|
+
*Franky W.*
|
1291
751
|
|
1292
|
-
|
752
|
+
* Fix preloading of associations which unscope a default scope.
|
1293
753
|
|
1294
|
-
|
754
|
+
Fixes #11036.
|
1295
755
|
|
1296
|
-
*
|
756
|
+
*Byron Bischoff*
|
1297
757
|
|
1298
|
-
|
758
|
+
* Added SchemaDumper support for tables with jsonb columns.
|
1299
759
|
|
1300
|
-
*
|
1301
|
-
raising a NoMethodError internally by calling `reflect_on_association` for `NilClass:Class`.
|
760
|
+
*Ted O'Meara*
|
1302
761
|
|
1303
|
-
|
762
|
+
* Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
|
763
|
+
`Relation` for performing queries and updates is the prefered API.
|
1304
764
|
|
1305
|
-
*
|
765
|
+
*Sean Griffin*
|
1306
766
|
|
1307
|
-
*
|
767
|
+
* Queries now properly type cast values that are part of a join statement,
|
768
|
+
even when using type decorators such as `serialize`.
|
1308
769
|
|
1309
|
-
|
770
|
+
*Melanie Gilman & Sean Griffin*
|
1310
771
|
|
1311
|
-
|
1312
|
-
|
1313
|
-
end
|
772
|
+
* MySQL enum type lookups, with values matching another type, no longer result
|
773
|
+
in an endless loop.
|
1314
774
|
|
1315
|
-
|
775
|
+
Fixes #17402.
|
1316
776
|
|
1317
|
-
|
1318
|
-
conversation.female!
|
1319
|
-
conversation.female? # => true
|
1320
|
-
conversation.gender # => "female"
|
777
|
+
*Yves Senn*
|
1321
778
|
|
1322
|
-
|
1323
|
-
conversation.gender = nil
|
1324
|
-
conversation.gender.nil? # => true
|
1325
|
-
conversation.gender # => nil
|
779
|
+
* Raise `ArgumentError` when the body of a scope is not callable.
|
1326
780
|
|
1327
|
-
|
781
|
+
*Mauro George*
|
1328
782
|
|
1329
|
-
*
|
1330
|
-
key is expected to contain a database URL. The database URL will be
|
1331
|
-
expanded into a hash and merged.
|
783
|
+
* Use type column first in multi-column indexes created with `add-reference`.
|
1332
784
|
|
1333
|
-
*
|
785
|
+
*Derek Prior*
|
1334
786
|
|
1335
|
-
*
|
787
|
+
* Fix `Relation.rewhere` to work with Range values.
|
1336
788
|
|
1337
|
-
|
789
|
+
*Dan Olson*
|
1338
790
|
|
1339
|
-
|
791
|
+
* `AR::UnknownAttributeError` now includes the class name of a record.
|
1340
792
|
|
1341
|
-
|
1342
|
-
# =>
|
793
|
+
User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
|
794
|
+
# => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
|
1343
795
|
|
1344
|
-
|
1345
|
-
# => ArgumentError, 'Invalid argument for .where.not(), got nil.'
|
796
|
+
*Yuki Nishijima*
|
1346
797
|
|
1347
|
-
|
798
|
+
* Fix a regression causing `after_create` callbacks to run before associated
|
799
|
+
records are autosaved.
|
1348
800
|
|
1349
|
-
|
1350
|
-
`ActiveRecord::Base.establish_connection`. Instead, a symbol must be given.
|
801
|
+
Fixes #17209.
|
1351
802
|
|
1352
|
-
*
|
803
|
+
*Agis Anastasopoulos*
|
1353
804
|
|
1354
|
-
*
|
1355
|
-
|
805
|
+
* Honor overridden `rack.test` in Rack environment for the connection
|
806
|
+
management middleware.
|
1356
807
|
|
1357
|
-
|
808
|
+
*Simon Eskildsen*
|
1358
809
|
|
1359
|
-
|
810
|
+
* Add a truncate method to the connection.
|
1360
811
|
|
1361
|
-
*
|
812
|
+
*Aaron Patterson*
|
1362
813
|
|
1363
|
-
|
1364
|
-
particular column, for instance AR attribute query methods has a branch
|
1365
|
-
like this:
|
814
|
+
* Don't autosave unchanged has_one through records.
|
1366
815
|
|
1367
|
-
|
1368
|
-
!value.zero?
|
1369
|
-
end
|
816
|
+
*Alan Kennedy*, *Steve Parrington*
|
1370
817
|
|
1371
|
-
|
1372
|
-
as running [].zero?, which results in a NoMethodError exception.
|
818
|
+
* Do not dump foreign keys for ignored tables.
|
1373
819
|
|
1374
|
-
|
1375
|
-
true for number?/text? checks.
|
820
|
+
*Yves Senn*
|
1376
821
|
|
1377
|
-
|
822
|
+
* PostgreSQL adapter correctly dumps foreign keys targeting tables
|
823
|
+
outside the schema search path.
|
1378
824
|
|
1379
|
-
|
1380
|
-
`ActiveRecord::NoDatabaseError` will now be raised. When being used with Rails
|
1381
|
-
the error message will include information on how to create a database:
|
1382
|
-
`rake db:create`. Supported adapters: postgresql, mysql, mysql2, sqlite3
|
825
|
+
Fixes #16907.
|
1383
826
|
|
1384
|
-
*
|
827
|
+
*Matthew Draper*, *Yves Senn*
|
1385
828
|
|
1386
|
-
*
|
1387
|
-
|
829
|
+
* When a thread is killed, rollback the active transaction, instead of
|
830
|
+
committing it during the stack unwind. Previously, we could commit half-
|
831
|
+
completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
|
832
|
+
distinguish a thread kill from an ordinary non-local (block) return, so must
|
833
|
+
default to committing.
|
1388
834
|
|
1389
|
-
|
835
|
+
*Chris Hanks*
|
1390
836
|
|
1391
|
-
|
837
|
+
* A `NullRelation` should represent nothing. This fixes a bug where
|
838
|
+
`Comment.where(post_id: Post.none)` returned a non-empty result.
|
1392
839
|
|
1393
|
-
|
1394
|
-
comment.post.destroy
|
1395
|
-
comment.destroy # no longer raises an error
|
840
|
+
Fixes #15176.
|
1396
841
|
|
1397
|
-
*
|
842
|
+
*Matthew Draper*, *Yves Senn*
|
1398
843
|
|
1399
|
-
*
|
1400
|
-
|
844
|
+
* Include default column limits in schema.rb. Allows defaults to be changed
|
845
|
+
in the future without affecting old migrations that assumed old defaults.
|
1401
846
|
|
1402
|
-
|
847
|
+
*Jeremy Kemper*
|
1403
848
|
|
1404
|
-
|
849
|
+
* MySQL: schema.rb now includes TEXT and BLOB column limits.
|
1405
850
|
|
1406
|
-
|
1407
|
-
Book.new(ratings: [1, 2]) # worked before
|
1408
|
-
Book.new(ratings: ['1', '2']) # now works as well
|
851
|
+
*Jeremy Kemper*
|
1409
852
|
|
1410
|
-
|
853
|
+
* MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
|
1411
854
|
|
1412
|
-
*
|
855
|
+
*Jeremy Kemper*
|
1413
856
|
|
1414
|
-
|
857
|
+
* SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
|
1415
858
|
|
1416
|
-
|
1417
|
-
number)
|
1418
|
-
values(
|
1419
|
-
5152
|
1420
|
-
)
|
859
|
+
*Girish Sonawane*
|
1421
860
|
|
1422
|
-
|
1423
|
-
|
861
|
+
* Introduce `connection.supports_views?` to check whether the current adapter
|
862
|
+
has support for SQL views. Connection adapters should define this method.
|
1424
863
|
|
1425
|
-
*
|
864
|
+
*Yves Senn*
|
1426
865
|
|
1427
|
-
*
|
866
|
+
* Allow included modules to override association methods.
|
1428
867
|
|
1429
|
-
Fixes
|
868
|
+
Fixes #16684.
|
1430
869
|
|
1431
|
-
*
|
1432
|
-
to an `Array` by calling `#to_a` before using these methods.
|
870
|
+
*Yves Senn*
|
1433
871
|
|
1434
|
-
|
1435
|
-
|
872
|
+
* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
|
873
|
+
the database connection to the current environment.
|
1436
874
|
|
1437
|
-
|
875
|
+
Fixes #16757.
|
1438
876
|
|
1439
|
-
|
1440
|
-
Author.where(name: 'Hank Moody').compact!
|
877
|
+
*Joshua Cody*, *Yves Senn*
|
1441
878
|
|
1442
|
-
|
1443
|
-
authors = Author.where(name: 'Hank Moody').to_a
|
1444
|
-
authors.compact!
|
879
|
+
* MySQL: set the connection collation along with the charset.
|
1445
880
|
|
1446
|
-
|
881
|
+
Sets the connection collation to the database collation configured in
|
882
|
+
database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
|
883
|
+
collation for that charset (utf8mb4_general_ci) when you may have chosen
|
884
|
+
a different collation, like utf8mb4_unicode_ci.
|
1447
885
|
|
1448
|
-
|
1449
|
-
|
886
|
+
This only applies to literal string comparisons, not column values, so it
|
887
|
+
is unlikely to affect you.
|
1450
888
|
|
1451
|
-
|
1452
|
-
if the value was a single `ActiveRecord::Base` object. e.g.
|
889
|
+
*Jeremy Kemper*
|
1453
890
|
|
1454
|
-
|
891
|
+
* `default_sequence_name` from the PostgreSQL adapter returns a `String`.
|
1455
892
|
|
1456
|
-
|
1457
|
-
generated. This change supports arguments in the `where` query
|
1458
|
-
conditions where the key is a `belongs_to` association name and the
|
1459
|
-
value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
|
1460
|
-
`ActiveRecord::Relation` object.
|
893
|
+
*Yves Senn*
|
1461
894
|
|
1462
|
-
|
1463
|
-
|
1464
|
-
end
|
895
|
+
* Fix a regression where whitespaces were stripped from DISTINCT queries in
|
896
|
+
PostgreSQL.
|
1465
897
|
|
1466
|
-
|
898
|
+
*Agis Anastasopoulos*
|
1467
899
|
|
1468
|
-
|
1469
|
-
# SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
|
900
|
+
Fixes #16623.
|
1470
901
|
|
1471
|
-
|
1472
|
-
|
1473
|
-
in the same query as `Post.where(author_id: [1,2])`:
|
902
|
+
* Fix has_many :through relation merging failing when dynamic conditions are
|
903
|
+
passed as a lambda with an arity of one.
|
1474
904
|
|
1475
|
-
|
1476
|
-
Post.where(author: authors_array)
|
1477
|
-
# SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IN (1, 2)
|
905
|
+
Fixes #16128.
|
1478
906
|
|
1479
|
-
|
1480
|
-
query as `Post.where(author_id: Author.where(last_name: "Emde"))`
|
907
|
+
*Agis Anastasopoulos*
|
1481
908
|
|
1482
|
-
|
1483
|
-
# SELECT "posts".* FROM "posts"
|
1484
|
-
# WHERE "posts"."author_id" IN (
|
1485
|
-
# SELECT "authors"."id" FROM "authors"
|
1486
|
-
# WHERE "authors"."last_name" = 'Emde')
|
909
|
+
* Fix `Relation#exists?` to work with polymorphic associations.
|
1487
910
|
|
1488
|
-
|
1489
|
-
appropriately, with the polymorphic `association_type` field added
|
1490
|
-
to the query to match the base class of the value. This feature
|
1491
|
-
previously only worked when the value was a single `ActveRecord::Base`.
|
911
|
+
Fixes #15821.
|
1492
912
|
|
1493
|
-
|
1494
|
-
belongs_to :author, polymorphic: true
|
1495
|
-
end
|
913
|
+
*Kassio Borges*
|
1496
914
|
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
915
|
+
* Currently, Active Record rescues any errors raised within
|
916
|
+
`after_rollback`/`after_create` callbacks and prints them to the logs.
|
917
|
+
Future versions of Rails will not rescue these errors anymore and
|
918
|
+
just bubble them up like the other callbacks.
|
1500
919
|
|
1501
|
-
|
920
|
+
This commit adds an opt-in flag to enable not rescuing the errors.
|
1502
921
|
|
1503
|
-
|
922
|
+
Example:
|
1504
923
|
|
1505
|
-
|
924
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
925
|
+
config.active_record.raise_in_transactional_callbacks = true
|
1506
926
|
|
1507
|
-
|
927
|
+
Fixes #13460.
|
1508
928
|
|
1509
|
-
*
|
929
|
+
*arthurnn*
|
1510
930
|
|
1511
|
-
*
|
931
|
+
* Fix an issue where custom accessor methods (such as those generated by
|
932
|
+
`enum`) with the same name as a global method are incorrectly overridden
|
933
|
+
when subclassing.
|
1512
934
|
|
1513
|
-
|
1514
|
-
as: "SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id")
|
935
|
+
Fixes #16288.
|
1515
936
|
|
1516
|
-
|
937
|
+
*Godfrey Chan*
|
1517
938
|
|
1518
|
-
|
1519
|
-
|
939
|
+
* `*_was` and `changes` now work correctly for in-place attribute changes as
|
940
|
+
well.
|
1520
941
|
|
1521
|
-
*
|
942
|
+
*Sean Griffin*
|
1522
943
|
|
1523
|
-
*
|
944
|
+
* Fix regression on `after_commit` that did not fire with nested transactions.
|
1524
945
|
|
1525
|
-
|
1526
|
-
so we need to load the Rails environment, otherwise the config wont be in place.
|
946
|
+
Fixes #16425.
|
1527
947
|
|
1528
948
|
*arthurnn*
|
1529
949
|
|
1530
|
-
*
|
950
|
+
* Do not try to write timestamps when a table has no timestamps columns.
|
1531
951
|
|
1532
|
-
Fixes #
|
952
|
+
Fixes #8813.
|
1533
953
|
|
1534
|
-
|
954
|
+
*Sergey Potapov*
|
1535
955
|
|
1536
|
-
|
1537
|
-
Account.group(:firm_name).sum('0.01 * credit_limit')
|
1538
|
-
# => { '37signals' => '0.5' }
|
956
|
+
* `index_exists?` with `:name` option does verify specified columns.
|
1539
957
|
|
1540
|
-
|
1541
|
-
Account.group(:firm_name).sum('0.01 * credit_limit')
|
1542
|
-
# => { '37signals' => 0.5 }
|
958
|
+
Example:
|
1543
959
|
|
1544
|
-
|
960
|
+
add_index :articles, :title, name: "idx_title"
|
1545
961
|
|
1546
|
-
|
1547
|
-
|
962
|
+
# Before:
|
963
|
+
index_exists? :articles, :title, name: "idx_title" # => `true`
|
964
|
+
index_exists? :articles, :body, name: "idx_title" # => `true`
|
1548
965
|
|
1549
|
-
|
966
|
+
# After:
|
967
|
+
index_exists? :articles, :title, name: "idx_title" # => `true`
|
968
|
+
index_exists? :articles, :body, name: "idx_title" # => `false`
|
1550
969
|
|
1551
|
-
|
1552
|
-
belongs_to :rateable, polymorphic: true, touch: true
|
1553
|
-
end
|
970
|
+
*Yves Senn*, *Matthew Draper*
|
1554
971
|
|
1555
|
-
|
1556
|
-
|
972
|
+
* `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
|
973
|
+
Not passing the option is deprecated but the default is still `null: true`.
|
974
|
+
With Rails 5 this will change to `null: false`.
|
1557
975
|
|
1558
|
-
*
|
976
|
+
*Sean Griffin*
|
1559
977
|
|
1560
|
-
*
|
1561
|
-
|
978
|
+
* When calling `update_columns` on a record that is not persisted, the error
|
979
|
+
message now reflects whether that object is a new record or has been
|
980
|
+
destroyed.
|
1562
981
|
|
1563
|
-
*
|
982
|
+
*Lachlan Sylvester*
|
1564
983
|
|
1565
|
-
*
|
984
|
+
* Define `id_was` to get the previous value of the primary key.
|
1566
985
|
|
1567
|
-
|
986
|
+
Currently when we call `id_was` and we have a custom primary key name,
|
987
|
+
Active Record will return the current value of the primary key. This
|
988
|
+
makes it impossible to correctly do an update operation if you change the
|
989
|
+
id.
|
1568
990
|
|
1569
|
-
|
1570
|
-
# => returns the 4th record from the end.
|
991
|
+
Fixes #16413.
|
1571
992
|
|
1572
|
-
|
993
|
+
*Rafael Mendonça França*
|
1573
994
|
|
1574
|
-
|
995
|
+
* Deprecate `DatabaseTasks.load_schema` to act on the current connection.
|
996
|
+
Use `.load_schema_current` instead. In the future `load_schema` will
|
997
|
+
require the `configuration` to act on as an argument.
|
1575
998
|
|
1576
|
-
*
|
1577
|
-
when using unmapped PostgreSQL array types.
|
999
|
+
*Yves Senn*
|
1578
1000
|
|
1579
|
-
|
1001
|
+
* Fix automatic maintaining test schema to properly handle sql structure
|
1002
|
+
schema format.
|
1580
1003
|
|
1581
|
-
|
1004
|
+
Fixes #15394.
|
1582
1005
|
|
1583
|
-
|
1006
|
+
*Wojciech Wnętrzak*
|
1584
1007
|
|
1585
|
-
|
1008
|
+
* Fix type casting to Decimal from Float with large precision.
|
1586
1009
|
|
1587
|
-
*
|
1588
|
-
after leaving the outer block instead of clearing it right after the inner block is finished.
|
1010
|
+
*Tomohiro Hashidate*
|
1589
1011
|
|
1590
|
-
|
1012
|
+
* Deprecate `Reflection#source_macro`
|
1591
1013
|
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1014
|
+
`Reflection#source_macro` is no longer needed in Active Record
|
1015
|
+
source so it has been deprecated. Code that used `source_macro`
|
1016
|
+
was removed in #16353.
|
1595
1017
|
|
1596
|
-
*
|
1018
|
+
*Eileen M. Uchtitelle*, *Aaron Patterson*
|
1597
1019
|
|
1598
|
-
*
|
1599
|
-
option, but never actually supported it. Now it will raise an `ArgumentError`
|
1600
|
-
when using `has_one` with `counter_cache`.
|
1020
|
+
* No verbose backtrace by `db:drop` when database does not exist.
|
1601
1021
|
|
1602
|
-
|
1022
|
+
Fixes #16295.
|
1603
1023
|
|
1604
|
-
*
|
1024
|
+
*Kenn Ejima*
|
1605
1025
|
|
1606
|
-
|
1026
|
+
* Add support for PostgreSQL JSONB.
|
1607
1027
|
|
1608
|
-
|
1028
|
+
Example:
|
1609
1029
|
|
1610
|
-
|
1030
|
+
create_table :posts do |t|
|
1031
|
+
t.jsonb :meta_data
|
1032
|
+
end
|
1611
1033
|
|
1612
|
-
*
|
1034
|
+
*Philippe Creux*, *Chris Teague*
|
1613
1035
|
|
1614
|
-
*
|
1036
|
+
* `db:purge` with MySQL respects `Rails.env`.
|
1615
1037
|
|
1616
|
-
|
1038
|
+
*Yves Senn*
|
1617
1039
|
|
1618
|
-
|
1040
|
+
* `change_column_default :table, :column, nil` with PostgreSQL will issue a
|
1041
|
+
`DROP DEFAULT` instead of a `DEFAULT NULL` query.
|
1619
1042
|
|
1620
|
-
|
1621
|
-
rename indexes on columns with a foreign key and prevents the following error:
|
1043
|
+
Fixes #16261.
|
1622
1044
|
|
1623
|
-
|
1045
|
+
*Matthew Draper*, *Yves Senn*
|
1624
1046
|
|
1625
|
-
|
1047
|
+
* Allow to specify a type for the foreign key column in `references`
|
1048
|
+
and `add_reference`.
|
1626
1049
|
|
1627
|
-
|
1628
|
-
marked with `dependent: destroy` fails to be destroyed.
|
1050
|
+
Example:
|
1629
1051
|
|
1630
|
-
|
1052
|
+
change_table :vehicle do |t|
|
1053
|
+
t.references :station, type: :uuid
|
1054
|
+
end
|
1631
1055
|
|
1632
|
-
*
|
1056
|
+
*Andrey Novikov*, *Łukasz Sarnacki*
|
1633
1057
|
|
1634
|
-
*
|
1058
|
+
* `create_join_table` removes a common prefix when generating the join table.
|
1059
|
+
This matches the existing behavior of HABTM associations.
|
1635
1060
|
|
1636
|
-
|
1061
|
+
Fixes #13683.
|
1637
1062
|
|
1638
|
-
*
|
1063
|
+
*Stefan Kanev*
|
1639
1064
|
|
1640
|
-
|
1065
|
+
* Do not swallow errors on `compute_type` when having a bad `alias_method` on
|
1066
|
+
a class.
|
1641
1067
|
|
1642
|
-
*
|
1068
|
+
*arthurnn*
|
1643
1069
|
|
1644
|
-
|
1070
|
+
* PostgreSQL invalid `uuid` are convert to nil.
|
1645
1071
|
|
1646
|
-
*
|
1072
|
+
*Abdelkader Boudih*
|
1647
1073
|
|
1648
|
-
|
1074
|
+
* Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
|
1649
1075
|
|
1650
|
-
|
1076
|
+
With 4.1.x, `serialize` started returning a string when `JSON` was passed as
|
1077
|
+
the second attribute. It will now return a hash as per previous versions.
|
1651
1078
|
|
1652
1079
|
Example:
|
1653
1080
|
|
1654
|
-
class
|
1655
|
-
|
1081
|
+
class Post < ActiveRecord::Base
|
1082
|
+
serialize :comment, JSON
|
1656
1083
|
end
|
1657
1084
|
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
*Javan Makhmali*
|
1663
|
-
|
1664
|
-
* Added `ActiveRecord::Base.no_touching`, which allows ignoring touch on models.
|
1665
|
-
|
1666
|
-
Example:
|
1667
|
-
|
1668
|
-
Post.no_touching do
|
1669
|
-
Post.first.touch
|
1085
|
+
class Comment
|
1086
|
+
include ActiveModel::Model
|
1087
|
+
attr_accessor :category, :text
|
1670
1088
|
end
|
1671
1089
|
|
1672
|
-
|
1090
|
+
post = Post.create!
|
1091
|
+
post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
|
1092
|
+
post.save!
|
1673
1093
|
|
1674
|
-
|
1675
|
-
|
1094
|
+
# 4.0
|
1095
|
+
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1676
1096
|
|
1677
|
-
|
1097
|
+
# 4.1 before
|
1098
|
+
post.comment # => "#<Comment:0x007f80ab48ff98>"
|
1678
1099
|
|
1679
|
-
|
1100
|
+
# 4.1 after
|
1101
|
+
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1680
1102
|
|
1681
|
-
|
1682
|
-
`
|
1103
|
+
When using `JSON` as the coder in `serialize`, Active Record will use the
|
1104
|
+
new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
|
1105
|
+
`ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
|
1106
|
+
correctly using the `#as_json` hook.
|
1683
1107
|
|
1684
|
-
|
1108
|
+
To keep the previous behaviour, supply a custom coder instead
|
1109
|
+
([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
|
1685
1110
|
|
1686
|
-
|
1111
|
+
Fixes #15594.
|
1687
1112
|
|
1688
|
-
*
|
1113
|
+
*Jenn Cooper*
|
1689
1114
|
|
1690
|
-
|
1115
|
+
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
1691
1116
|
|
1692
|
-
|
1117
|
+
Fixes #15931.
|
1693
1118
|
|
1694
|
-
*
|
1695
|
-
transparent what values are actually sent to the database.
|
1119
|
+
*Jeff Browning*
|
1696
1120
|
|
1697
|
-
|
1698
|
-
|
1699
|
-
# After: ... WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
|
1121
|
+
* Calling `#empty?` on a `has_many` association would use the value from the
|
1122
|
+
counter cache if one exists.
|
1700
1123
|
|
1701
|
-
*
|
1124
|
+
*David Verhasselt*
|
1702
1125
|
|
1703
|
-
* Fix
|
1126
|
+
* Fix the schema dump generated for tables without constraints and with
|
1127
|
+
primary key with default value of custom PostgreSQL function result.
|
1704
1128
|
|
1705
|
-
Fixes #
|
1129
|
+
Fixes #16111.
|
1706
1130
|
|
1707
|
-
*
|
1131
|
+
*Andrey Novikov*
|
1708
1132
|
|
1709
|
-
*
|
1133
|
+
* Fix the SQL generated when a `delete_all` is run on an association to not
|
1134
|
+
produce an `IN` statements.
|
1710
1135
|
|
1711
|
-
|
1136
|
+
Before:
|
1712
1137
|
|
1713
|
-
|
1138
|
+
UPDATE "categorizations" SET "category_id" = NULL WHERE
|
1139
|
+
"categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
|
1714
1140
|
|
1715
|
-
|
1141
|
+
After:
|
1716
1142
|
|
1717
|
-
|
1718
|
-
|
1719
|
-
Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
|
1143
|
+
UPDATE "categorizations" SET "category_id" = NULL WHERE
|
1144
|
+
"categorizations"."category_id" = 1
|
1720
1145
|
|
1721
|
-
*
|
1146
|
+
*Eileen M. Uchitelle, Aaron Patterson*
|
1722
1147
|
|
1723
|
-
*
|
1148
|
+
* Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
|
1149
|
+
values for string columns. Otherwise, in some database, the string column
|
1150
|
+
values will be coerced to a numeric allowing false or 0.seconds match any
|
1151
|
+
string starting with a non-digit.
|
1724
1152
|
|
1725
1153
|
Example:
|
1726
1154
|
|
1727
|
-
|
1728
|
-
Person.find(5).cache_key(:updated_at, :last_reviewed_at)
|
1155
|
+
App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
|
1729
1156
|
|
1730
|
-
*
|
1157
|
+
*Dylan Thacker-Smith*
|
1731
1158
|
|
1732
|
-
*
|
1159
|
+
* Add a `:required` option to singular associations, providing a nicer
|
1160
|
+
API for presence validations on associations.
|
1733
1161
|
|
1734
|
-
|
1162
|
+
*Sean Griffin*
|
1735
1163
|
|
1736
|
-
|
1737
|
-
|
1738
|
-
end
|
1164
|
+
* Fix an error in `reset_counters` when associations have `select` scope.
|
1165
|
+
(Call to `count` generated invalid SQL.)
|
1739
1166
|
|
1740
|
-
|
1167
|
+
*Cade Truitt*
|
1741
1168
|
|
1742
|
-
|
1743
|
-
conversation.active!
|
1744
|
-
conversation.active? # => true
|
1745
|
-
conversation.status # => "active"
|
1169
|
+
* After a successful `reload`, `new_record?` is always false.
|
1746
1170
|
|
1747
|
-
|
1748
|
-
conversation.archived!
|
1749
|
-
conversation.archived? # => true
|
1750
|
-
conversation.status # => "archived"
|
1171
|
+
Fixes #12101.
|
1751
1172
|
|
1752
|
-
|
1753
|
-
conversation.status = :archived
|
1173
|
+
*Matthew Draper*
|
1754
1174
|
|
1755
|
-
|
1175
|
+
* PostgreSQL renaming table doesn't attempt to rename non existent sequences.
|
1756
1176
|
|
1757
|
-
*
|
1177
|
+
*Abdelkader Boudih*
|
1758
1178
|
|
1759
|
-
|
1179
|
+
* Move 'dependent: :destroy' handling for `belongs_to`
|
1180
|
+
from `before_destroy` to `after_destroy` callback chain
|
1760
1181
|
|
1761
|
-
|
1182
|
+
Fixes #12380.
|
1762
1183
|
|
1763
|
-
*
|
1184
|
+
*Ivan Antropov*
|
1764
1185
|
|
1765
|
-
*
|
1766
|
-
Fixed bug when providing `includes` in through association scope, and fetching targets.
|
1186
|
+
* Detect in-place modifications on String attributes.
|
1767
1187
|
|
1768
|
-
|
1188
|
+
Before this change, an attribute modified in-place had to be marked as
|
1189
|
+
changed in order for it to be persisted in the database. Now it is no longer
|
1190
|
+
required.
|
1769
1191
|
|
1770
|
-
|
1771
|
-
has_many :relationships, -> { includes(:user) }
|
1772
|
-
has_many :users, through: :relationships
|
1773
|
-
end
|
1192
|
+
Before:
|
1774
1193
|
|
1775
|
-
|
1194
|
+
user = User.first
|
1195
|
+
user.name << ' Griffin'
|
1196
|
+
user.name_will_change!
|
1197
|
+
user.save
|
1198
|
+
user.reload.name # => "Sean Griffin"
|
1776
1199
|
|
1777
|
-
|
1200
|
+
After:
|
1778
1201
|
|
1779
|
-
|
1202
|
+
user = User.first
|
1203
|
+
user.name << ' Griffin'
|
1204
|
+
user.save
|
1205
|
+
user.reload.name # => "Sean Griffin"
|
1780
1206
|
|
1781
|
-
|
1207
|
+
*Sean Griffin*
|
1782
1208
|
|
1783
|
-
|
1209
|
+
* Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
|
1210
|
+
is invalid.
|
1784
1211
|
|
1785
|
-
|
1212
|
+
*Bogdan Gusiev*, *Marc Schütz*
|
1786
1213
|
|
1787
|
-
|
1214
|
+
* Support for adding and removing foreign keys. Foreign keys are now
|
1215
|
+
a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
|
1216
|
+
and PostgreSQLAdapter.
|
1788
1217
|
|
1789
|
-
|
1790
|
-
|
1218
|
+
Many thanks to *Matthew Higgins* for laying the foundation with his work on
|
1219
|
+
[foreigner](https://github.com/matthuhiggins/foreigner).
|
1791
1220
|
|
1792
1221
|
Example:
|
1793
1222
|
|
1794
|
-
|
1223
|
+
# within your migrations:
|
1224
|
+
add_foreign_key :articles, :authors
|
1225
|
+
remove_foreign_key :articles, :authors
|
1795
1226
|
|
1796
|
-
|
1797
|
-
x.tags # => {"string" => "foo", :symbol => :bar}
|
1227
|
+
*Yves Senn*
|
1798
1228
|
|
1799
|
-
|
1800
|
-
|
1229
|
+
* Fix subtle bugs regarding attribute assignment on models with no primary
|
1230
|
+
key. `'id'` will no longer be part of the attributes hash.
|
1801
1231
|
|
1802
|
-
*
|
1232
|
+
*Sean Griffin*
|
1803
1233
|
|
1804
|
-
*
|
1234
|
+
* Deprecate automatic counter caches on `has_many :through`. The behavior was
|
1235
|
+
broken and inconsistent.
|
1805
1236
|
|
1806
|
-
|
1237
|
+
*Sean Griffin*
|
1807
1238
|
|
1808
|
-
|
1239
|
+
* `preload` preserves readonly flag for associations.
|
1809
1240
|
|
1810
|
-
|
1811
|
-
all registered `stored_attributes`. Now every subclass of
|
1812
|
-
`ActiveRecord::Base` has it's own `Hash`.
|
1241
|
+
See #15853.
|
1813
1242
|
|
1814
1243
|
*Yves Senn*
|
1815
1244
|
|
1816
|
-
*
|
1245
|
+
* Assume numeric types have changed if they were assigned to a value that
|
1246
|
+
would fail numericality validation, regardless of the old value. Previously
|
1247
|
+
this would only occur if the old value was 0.
|
1817
1248
|
|
1818
|
-
|
1249
|
+
Example:
|
1819
1250
|
|
1820
|
-
|
1251
|
+
model = Model.create!(number: 5)
|
1252
|
+
model.number = '5wibble'
|
1253
|
+
model.number_changed? # => true
|
1821
1254
|
|
1822
|
-
|
1255
|
+
Fixes #14731.
|
1823
1256
|
|
1824
|
-
|
1257
|
+
*Sean Griffin*
|
1825
1258
|
|
1826
|
-
*
|
1827
|
-
|
1259
|
+
* `reload` no longer merges with the existing attributes.
|
1260
|
+
The attribute hash is fully replaced. The record is put into the same state
|
1261
|
+
as it would be with `Model.find(model.id)`.
|
1828
1262
|
|
1829
|
-
|
1263
|
+
*Sean Griffin*
|
1830
1264
|
|
1831
|
-
|
1265
|
+
* The object returned from `select_all` must respond to `column_types`.
|
1266
|
+
If this is not the case a `NoMethodError` is raised.
|
1832
1267
|
|
1833
|
-
|
1268
|
+
*Sean Griffin*
|
1834
1269
|
|
1835
|
-
*
|
1836
|
-
spaces.
|
1270
|
+
* Detect in-place modifications of PG array types
|
1837
1271
|
|
1838
|
-
*
|
1272
|
+
*Sean Griffin*
|
1839
1273
|
|
1840
|
-
* `
|
1274
|
+
* Add `bin/rake db:purge` task to empty the current database.
|
1841
1275
|
|
1842
|
-
|
1843
|
-
operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
|
1844
|
-
been generated through the use of `where.not`.
|
1276
|
+
*Yves Senn*
|
1845
1277
|
|
1846
|
-
|
1278
|
+
* Deprecate `serialized_attributes` without replacement.
|
1847
1279
|
|
1848
|
-
*
|
1280
|
+
*Sean Griffin*
|
1849
1281
|
|
1850
|
-
|
1282
|
+
* Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
|
1283
|
+
are part of the URI structure, not the actual host.
|
1851
1284
|
|
1852
|
-
|
1285
|
+
Fixes #15705.
|
1853
1286
|
|
1854
|
-
*
|
1287
|
+
*Andy Bakun*, *Aaron Stone*
|
1855
1288
|
|
1856
|
-
*
|
1289
|
+
* Ensure both parent IDs are set on join records when both sides of a
|
1290
|
+
through association are new.
|
1857
1291
|
|
1858
|
-
*
|
1292
|
+
*Sean Griffin*
|
1859
1293
|
|
1860
|
-
* `
|
1294
|
+
* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
|
1295
|
+
Serialized attributes on ActiveRecord models will no longer save when
|
1296
|
+
unchanged.
|
1861
1297
|
|
1862
|
-
|
1863
|
-
`Calculations`.
|
1298
|
+
Fixes #8328.
|
1864
1299
|
|
1865
|
-
*
|
1300
|
+
*Sean Griffin*
|
1866
1301
|
|
1867
|
-
* `
|
1302
|
+
* `Pluck` now works when selecting columns from different tables with the same
|
1303
|
+
name.
|
1868
1304
|
|
1869
|
-
|
1870
|
-
`scope_chain` for different associations. During processing
|
1871
|
-
these arrays are sometimes mutated and because of in-place
|
1872
|
-
mutation the changed `scope_chain` impacts other reflections.
|
1305
|
+
Fixes #15649.
|
1873
1306
|
|
1874
|
-
|
1307
|
+
*Sean Griffin*
|
1875
1308
|
|
1876
|
-
|
1309
|
+
* Remove `cache_attributes` and friends. All attributes are cached.
|
1877
1310
|
|
1878
|
-
*
|
1311
|
+
*Sean Griffin*
|
1879
1312
|
|
1880
|
-
*
|
1313
|
+
* Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
|
1881
1314
|
|
1882
|
-
|
1315
|
+
*Akshay Vishnoi*
|
1883
1316
|
|
1884
|
-
|
1317
|
+
* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
|
1318
|
+
`Enumerable#find` does.
|
1885
1319
|
|
1886
|
-
|
1887
|
-
method.
|
1320
|
+
Fixes #15382.
|
1888
1321
|
|
1889
|
-
|
1322
|
+
*James Yang*
|
1890
1323
|
|
1891
|
-
|
1892
|
-
Blog.where('id in (?)', Blog.where(id: 1))
|
1893
|
-
# => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1
|
1894
|
-
# => SELECT "blogs".* FROM "blogs" WHERE (id IN (1))
|
1324
|
+
* Make timezone aware attributes work with PostgreSQL array columns.
|
1895
1325
|
|
1896
|
-
|
1897
|
-
Blog.where('id in (?)', Blog.where(id: 1).select(:id))
|
1898
|
-
# => SELECT "blogs".* FROM "blogs"
|
1899
|
-
# WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1)
|
1326
|
+
Fixes #13402.
|
1900
1327
|
|
1901
|
-
|
1328
|
+
*Kuldeep Aggarwal*, *Sean Griffin*
|
1902
1329
|
|
1903
|
-
|
1330
|
+
* `ActiveRecord::SchemaMigration` has no primary key regardless of the
|
1331
|
+
`primary_key_prefix_type` configuration.
|
1904
1332
|
|
1905
|
-
|
1906
|
-
which is raised in `ActiveRecord::Associations::Preloader` class
|
1907
|
-
added owner record class name in order to simplify to find problem code.
|
1333
|
+
Fixes #15051.
|
1908
1334
|
|
1909
|
-
*
|
1335
|
+
*JoseLuis Torres*, *Yves Senn*
|
1910
1336
|
|
1911
|
-
* `
|
1912
|
-
`has_many :through`. Behavior should remain the same, if not, it is a bug.
|
1337
|
+
* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
|
1913
1338
|
|
1914
|
-
|
1915
|
-
a savepoint name.
|
1339
|
+
Fixes #15538.
|
1916
1340
|
|
1917
1341
|
*Yves Senn*
|
1918
1342
|
|
1919
|
-
*
|
1343
|
+
* Baseclass becomes! subclass.
|
1920
1344
|
|
1921
|
-
|
1345
|
+
Before this change, a record which changed its STI type, could not be
|
1346
|
+
updated.
|
1922
1347
|
|
1923
|
-
|
1924
|
-
attributes of the where clause.
|
1348
|
+
Fixes #14785.
|
1925
1349
|
|
1926
|
-
|
1350
|
+
*Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
|
1927
1351
|
|
1928
|
-
|
1352
|
+
* Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
|
1353
|
+
`proper_table_name` instance method on `ActiveRecord::Migration` instead.
|
1929
1354
|
|
1930
|
-
*
|
1931
|
-
when using `has_many` association with `:inverse_of` and finding an array of one element,
|
1932
|
-
it should return an array of one element too.
|
1355
|
+
*Akshay Vishnoi*
|
1933
1356
|
|
1934
|
-
|
1357
|
+
* Fix regression on eager loading association based on SQL query rather than
|
1358
|
+
existing column.
|
1935
1359
|
|
1936
|
-
|
1360
|
+
Fixes #15480.
|
1937
1361
|
|
1938
|
-
*
|
1362
|
+
*Lauro Caetano*, *Carlos Antonio da Silva*
|
1939
1363
|
|
1940
|
-
* `
|
1941
|
-
|
1364
|
+
* Deprecate returning `nil` from `column_for_attribute` when no column exists.
|
1365
|
+
It will return a null object in Rails 5.0
|
1942
1366
|
|
1943
|
-
|
1367
|
+
*Sean Griffin*
|
1944
1368
|
|
1945
|
-
|
1369
|
+
* Implemented `ActiveRecord::Base#pretty_print` to work with PP.
|
1946
1370
|
|
1947
|
-
*
|
1948
|
-
gets a `nil` argument. More specifically, it will throw an error if the
|
1949
|
-
argument that it gets passed does not respond to to `stringify_keys`.
|
1371
|
+
*Ethan*
|
1950
1372
|
|
1951
|
-
|
1373
|
+
* Preserve type when dumping PostgreSQL point, bit, bit varying and money
|
1374
|
+
columns.
|
1952
1375
|
|
1953
|
-
|
1376
|
+
*Yves Senn*
|
1954
1377
|
|
1955
|
-
|
1378
|
+
* New records remain new after YAML serialization.
|
1956
1379
|
|
1957
|
-
*
|
1380
|
+
*Sean Griffin*
|
1958
1381
|
|
1959
|
-
|
1382
|
+
* PostgreSQL support default values for enum types. Fixes #7814.
|
1960
1383
|
|
1961
|
-
*
|
1384
|
+
*Yves Senn*
|
1962
1385
|
|
1963
|
-
|
1386
|
+
* PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
|
1964
1387
|
|
1965
|
-
*
|
1388
|
+
*Yves Senn*
|
1966
1389
|
|
1967
|
-
*
|
1968
|
-
|
1390
|
+
* Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
|
1391
|
+
with orders without sort direction modifiers.
|
1969
1392
|
|
1970
|
-
|
1393
|
+
*Nikolay Kondratyev*
|
1971
1394
|
|
1972
|
-
|
1395
|
+
* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
|
1973
1396
|
|
1974
|
-
*
|
1975
|
-
where constraints and at least of them is not `Arel::Nodes::Equality`,
|
1976
|
-
generates invalid SQL expression.
|
1397
|
+
*Yves Senn*
|
1977
1398
|
|
1978
|
-
|
1399
|
+
* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
|
1400
|
+
Fixes duplication in combination with `store_accessor`.
|
1979
1401
|
|
1980
|
-
|
1402
|
+
Fixes #15369.
|
1981
1403
|
|
1982
|
-
*
|
1983
|
-
query to fetch results rather than loading the entire collection.
|
1404
|
+
*Yves Senn*
|
1984
1405
|
|
1985
|
-
|
1406
|
+
* `rake railties:install:migrations` respects the order of railties.
|
1986
1407
|
|
1987
|
-
*
|
1408
|
+
*Arun Agrawal*
|
1988
1409
|
|
1989
|
-
|
1410
|
+
* Fix redefine a `has_and_belongs_to_many` inside inherited class
|
1411
|
+
Fixing regression case, where redefining the same `has_and_belongs_to_many`
|
1412
|
+
definition into a subclass would raise.
|
1990
1413
|
|
1991
|
-
|
1414
|
+
Fixes #14983.
|
1992
1415
|
|
1993
|
-
*
|
1416
|
+
*arthurnn*
|
1994
1417
|
|
1995
|
-
* Fix
|
1418
|
+
* Fix `has_and_belongs_to_many` public reflection.
|
1419
|
+
When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
|
1420
|
+
But as `reflections` is a public API, people expect to see the right macro.
|
1996
1421
|
|
1997
|
-
Fixes #
|
1422
|
+
Fixes #14682.
|
1998
1423
|
|
1999
|
-
*
|
1424
|
+
*arthurnn*
|
2000
1425
|
|
2001
|
-
*
|
2002
|
-
transaction.
|
1426
|
+
* Fix serialization for records with an attribute named `format`.
|
2003
1427
|
|
2004
|
-
|
1428
|
+
Fixes #15188.
|
2005
1429
|
|
2006
|
-
*
|
1430
|
+
*Godfrey Chan*
|
2007
1431
|
|
2008
|
-
|
1432
|
+
* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
|
1433
|
+
on a NullRelation should return a Hash.
|
2009
1434
|
|
2010
|
-
*
|
1435
|
+
*Kuldeep Aggarwal*
|
2011
1436
|
|
2012
|
-
|
1437
|
+
* Fix serialized fields returning serialized data after being updated with
|
1438
|
+
`update_column`.
|
2013
1439
|
|
2014
|
-
*
|
2015
|
-
accept objects other than direct descendants of `ActiveRecord::Base` (decorated
|
2016
|
-
models, for example).
|
1440
|
+
*Simon Hørup Eskildsen*
|
2017
1441
|
|
2018
|
-
|
1442
|
+
* Fix polymorphic eager loading when using a String as foreign key.
|
2019
1443
|
|
2020
|
-
|
2021
|
-
parentheses (eg. `($1.25) # => -1.25`)).
|
2022
|
-
Fixes #11899.
|
1444
|
+
Fixes #14734.
|
2023
1445
|
|
2024
|
-
*
|
1446
|
+
*Lauro Caetano*
|
2025
1447
|
|
2026
|
-
*
|
2027
|
-
common STRING datatype in SQL.
|
1448
|
+
* Change belongs_to touch to be consistent with timestamp updates
|
2028
1449
|
|
2029
|
-
|
1450
|
+
If a model is set up with a belongs_to: touch relationship the parent
|
1451
|
+
record will only be touched if the record was modified. This makes it
|
1452
|
+
consistent with timestamp updating on the record itself.
|
2030
1453
|
|
2031
|
-
*
|
1454
|
+
*Brock Trappitt*
|
2032
1455
|
|
2033
|
-
|
1456
|
+
* Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
|
1457
|
+
table inside a schema.
|
2034
1458
|
|
2035
|
-
|
1459
|
+
Fixes #14824.
|
2036
1460
|
|
2037
|
-
|
1461
|
+
*Eric Chahin*
|
2038
1462
|
|
2039
|
-
|
2040
|
-
|
1463
|
+
* Remove unused `:timestamp` type. Transparently alias it to `:datetime`
|
1464
|
+
in all cases. Fixes inconsistencies when column types are sent outside of
|
1465
|
+
`ActiveRecord`, such as for XML Serialization.
|
2041
1466
|
|
2042
|
-
|
2043
|
-
record.logged_in_from_ip = 'bad ip address' # raise exception
|
1467
|
+
*Sean Griffin*
|
2044
1468
|
|
2045
|
-
|
2046
|
-
|
2047
|
-
record.logged_in_from_ip # => nil
|
2048
|
-
record.logged_in_from_ip_before_type_cast # => 'bad ip address'
|
1469
|
+
* Fix bug that added `table_name_prefix` and `table_name_suffix` to
|
1470
|
+
extension names in PostgreSQL when migrating.
|
2049
1471
|
|
2050
|
-
*
|
1472
|
+
*Joao Carlos*
|
2051
1473
|
|
2052
|
-
* `
|
1474
|
+
* The `:index` option in migrations, which previously was only available for
|
1475
|
+
`references`, now works with any column types.
|
2053
1476
|
|
2054
|
-
|
1477
|
+
*Marc Schütz*
|
2055
1478
|
|
2056
|
-
|
1479
|
+
* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
|
2057
1480
|
|
2058
|
-
*
|
2059
|
-
assignment of `has_many` associations, when the association was not
|
2060
|
-
yet loaded:
|
1481
|
+
*jnormore*
|
2061
1482
|
|
2062
|
-
|
2063
|
-
|
1483
|
+
* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
|
1484
|
+
or `offset`.
|
2064
1485
|
|
2065
|
-
|
2066
|
-
|
2067
|
-
loading of the association
|
1486
|
+
In these cases the generated query ignored them and that caused unintended
|
1487
|
+
records to be deleted.
|
2068
1488
|
|
2069
|
-
|
1489
|
+
Fixes #11985.
|
2070
1490
|
|
2071
|
-
*
|
1491
|
+
*Leandro Facchinetti*
|
2072
1492
|
|
2073
|
-
|
1493
|
+
* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
|
1494
|
+
their limit dropped from the schema.
|
2074
1495
|
|
2075
|
-
|
2076
|
-
with reading from the database.
|
1496
|
+
Fixes #14135.
|
2077
1497
|
|
2078
|
-
|
1498
|
+
*Aaron Nelson*
|
2079
1499
|
|
2080
|
-
|
1500
|
+
* Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
|
1501
|
+
association.
|
2081
1502
|
|
2082
|
-
|
2083
|
-
x.tags # => {"bool" => true, "number" => 5}
|
1503
|
+
Fixes #14709.
|
2084
1504
|
|
2085
|
-
|
2086
|
-
x.tags # => {"bool" => "true", "number" => "5"}
|
1505
|
+
*Kassio Borges*
|
2087
1506
|
|
2088
|
-
|
1507
|
+
* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
|
1508
|
+
strings in column names as equal.
|
2089
1509
|
|
2090
|
-
|
1510
|
+
This fixes a rare case in which more bind values are passed than there are
|
1511
|
+
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
1512
|
+
throw a `StatementInvalid` exception.
|
2091
1513
|
|
2092
|
-
*
|
1514
|
+
*Nat Budin*
|
2093
1515
|
|
2094
|
-
*
|
1516
|
+
* Fix `stored_attributes` to correctly merge the details of stored
|
1517
|
+
attributes defined in parent classes.
|
2095
1518
|
|
2096
|
-
Fixes #
|
1519
|
+
Fixes #14672.
|
2097
1520
|
|
2098
|
-
*
|
1521
|
+
*Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
|
2099
1522
|
|
2100
|
-
*
|
1523
|
+
* `change_column_default` allows `[]` as argument to `change_column_default`.
|
2101
1524
|
|
2102
|
-
|
1525
|
+
Fixes #11586.
|
2103
1526
|
|
2104
|
-
*
|
1527
|
+
*Yves Senn*
|
2105
1528
|
|
2106
|
-
|
1529
|
+
* Handle `name` and `"char"` column types in the PostgreSQL adapter.
|
2107
1530
|
|
2108
|
-
|
2109
|
-
|
1531
|
+
`name` and `"char"` are special character types used internally by
|
1532
|
+
PostgreSQL and are used by internal system catalogs. These field types
|
1533
|
+
can sometimes show up in structure-sniffing queries that feature internal system
|
1534
|
+
structures or with certain PostgreSQL extensions.
|
2110
1535
|
|
2111
|
-
*
|
1536
|
+
*J Smith*, *Yves Senn*
|
2112
1537
|
|
2113
|
-
*
|
2114
|
-
|
1538
|
+
* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
|
1539
|
+
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
2115
1540
|
|
2116
1541
|
Before:
|
2117
1542
|
|
2118
|
-
|
2119
|
-
#
|
1543
|
+
Point.create(value: 1.0/0)
|
1544
|
+
Point.last.value # => 0.0
|
2120
1545
|
|
2121
1546
|
After:
|
2122
1547
|
|
2123
|
-
|
2124
|
-
#
|
1548
|
+
Point.create(value: 1.0/0)
|
1549
|
+
Point.last.value # => Infinity
|
2125
1550
|
|
2126
|
-
|
1551
|
+
*Innokenty Mikhailov*
|
2127
1552
|
|
2128
|
-
*
|
2129
|
-
For example, adding a very vendor specific regex implementation:
|
1553
|
+
* Allow the PostgreSQL adapter to handle bigserial primary key types again.
|
2130
1554
|
|
2131
|
-
|
2132
|
-
Arel::Nodes::InfixOperation.new('~', column, value.source)
|
2133
|
-
end
|
2134
|
-
ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
|
1555
|
+
Fixes #10410.
|
2135
1556
|
|
2136
|
-
*
|
1557
|
+
*Patrick Robertson*
|
2137
1558
|
|
2138
|
-
*
|
1559
|
+
* Deprecate joining, eager loading and preloading of instance dependent
|
1560
|
+
associations without replacement. These operations happen before instances
|
1561
|
+
are created. The current behavior is unexpected and can result in broken
|
1562
|
+
behavior.
|
2139
1563
|
|
2140
|
-
|
2141
|
-
By enforcing the provision of the column for this internal method
|
2142
|
-
we ensure that those using adapters that require column information
|
2143
|
-
will always get the proper behavior.
|
1564
|
+
Fixes #15024.
|
2144
1565
|
|
2145
|
-
*
|
1566
|
+
*Yves Senn*
|
2146
1567
|
|
2147
|
-
*
|
2148
|
-
to allow the connection adapter to properly determine how to quote the value. This was
|
2149
|
-
affecting certain databases that use specific column types.
|
1568
|
+
* Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
|
2150
1569
|
|
2151
|
-
|
1570
|
+
`has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
|
1571
|
+
size calculation if the collection is not cached or loaded.
|
2152
1572
|
|
2153
|
-
|
1573
|
+
Fixes #14913, #14914.
|
2154
1574
|
|
2155
|
-
*
|
1575
|
+
*Fred Wu*
|
2156
1576
|
|
2157
|
-
|
1577
|
+
* Return a non zero status when running `rake db:migrate:status` and migration table does
|
1578
|
+
not exist.
|
2158
1579
|
|
2159
|
-
|
2160
|
-
not rescue from Exception (but only from StandardError), the Connection
|
2161
|
-
Pool quickly runs out of connections when multiple erroneous Requests come
|
2162
|
-
in right after each other.
|
1580
|
+
*Paul B.*
|
2163
1581
|
|
2164
|
-
|
2165
|
-
behaviour.
|
1582
|
+
* Add support for module-level `table_name_suffix` in models.
|
2166
1583
|
|
2167
|
-
|
1584
|
+
This makes `table_name_suffix` work the same way as `table_name_prefix` when
|
1585
|
+
using namespaced models.
|
2168
1586
|
|
2169
|
-
*
|
1587
|
+
*Jenner LaFave*
|
2170
1588
|
|
2171
|
-
|
1589
|
+
* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
|
2172
1590
|
|
2173
|
-
|
1591
|
+
In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
|
1592
|
+
In 4.0 series it is delegated to `Array#join`.
|
2174
1593
|
|
2175
|
-
*
|
1594
|
+
*Bogdan Gusiev*
|
2176
1595
|
|
2177
|
-
*
|
1596
|
+
* Log nil binary column values correctly.
|
2178
1597
|
|
2179
|
-
|
1598
|
+
When an object with a binary column is updated with a nil value
|
1599
|
+
in that column, the SQL logger would throw an exception when trying
|
1600
|
+
to log that nil value. This only occurs when updating a record
|
1601
|
+
that already has a non-nil value in that column since an initial nil
|
1602
|
+
value isn't included in the SQL anyway (at least, when dirty checking
|
1603
|
+
is enabled.) The column's new value will now be logged as `<NULL binary data>`
|
1604
|
+
to parallel the existing `<N bytes of binary data>` for non-nil values.
|
2180
1605
|
|
2181
|
-
*
|
1606
|
+
*James Coleman*
|
2182
1607
|
|
2183
|
-
*
|
2184
|
-
|
1608
|
+
* Rails will now pass a custom validation context through to autosave associations
|
1609
|
+
in order to validate child associations with the same context.
|
2185
1610
|
|
2186
|
-
|
2187
|
-
self.column_defaults # if we call this unintentionally before setting locking_column ...
|
2188
|
-
self.locking_column = 'my_locking_column'
|
2189
|
-
end
|
1611
|
+
Fixes #13854.
|
2190
1612
|
|
2191
|
-
|
2192
|
-
=> nil # expected value is 0 !
|
1613
|
+
*Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
|
2193
1614
|
|
2194
|
-
|
1615
|
+
* Stringify all variables keys of MySQL connection configuration.
|
2195
1616
|
|
2196
|
-
|
2197
|
-
|
1617
|
+
When `sql_mode` variable for MySQL adapters set in configuration as `String`
|
1618
|
+
was ignored and overwritten by strict mode option.
|
2198
1619
|
|
2199
|
-
Fixes #
|
1620
|
+
Fixes #14895.
|
2200
1621
|
|
2201
1622
|
*Paul Nikitochkin*
|
2202
1623
|
|
2203
|
-
*
|
2204
|
-
`primary_keys`, `tables`, `columns` and `columns_hash`.
|
1624
|
+
* Ensure SQLite3 statements are closed on errors.
|
2205
1625
|
|
2206
|
-
|
1626
|
+
Fixes #13631.
|
2207
1627
|
|
2208
|
-
*
|
1628
|
+
*Timur Alperovich*
|
2209
1629
|
|
2210
|
-
|
1630
|
+
* Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
|
2211
1631
|
|
2212
|
-
*
|
1632
|
+
*Hector Satre*
|
2213
1633
|
|
2214
|
-
|
1634
|
+
* When using a custom `join_table` name on a `habtm`, rails was not saving it
|
1635
|
+
on Reflections. This causes a problem when rails loads fixtures, because it
|
1636
|
+
uses the reflections to set database with fixtures.
|
2215
1637
|
|
2216
|
-
|
1638
|
+
Fixes #14845.
|
2217
1639
|
|
2218
|
-
*
|
1640
|
+
*Kassio Borges*
|
2219
1641
|
|
2220
|
-
*
|
2221
|
-
|
1642
|
+
* Reset the cache when modifying a Relation with cached Arel.
|
1643
|
+
Additionally display a warning message to make the user aware.
|
2222
1644
|
|
2223
|
-
*
|
1645
|
+
*Yves Senn*
|
2224
1646
|
|
2225
|
-
*
|
1647
|
+
* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
|
1648
|
+
different spellings of timestamps are treated the same.
|
2226
1649
|
|
2227
|
-
|
1650
|
+
Example:
|
2228
1651
|
|
2229
|
-
|
1652
|
+
mytimestamp.simplified_type('timestamp without time zone')
|
1653
|
+
# => :datetime
|
1654
|
+
mytimestamp.simplified_type('timestamp(6) without time zone')
|
1655
|
+
# => also :datetime (previously would be :timestamp)
|
2230
1656
|
|
2231
|
-
|
1657
|
+
See #14513.
|
2232
1658
|
|
2233
|
-
*
|
2234
|
-
method. You can use `#transaction_open?` instead.
|
1659
|
+
*Jefferson Lai*
|
2235
1660
|
|
2236
|
-
|
1661
|
+
* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
|
2237
1662
|
|
2238
|
-
|
2239
|
-
|
1663
|
+
Fixes #14841.
|
1664
|
+
|
1665
|
+
*Lucas Mazza*
|
2240
1666
|
|
2241
|
-
|
1667
|
+
* Fix name collision with `Array#select!` with `Relation#select!`.
|
2242
1668
|
|
2243
|
-
|
1669
|
+
Fixes #14752.
|
2244
1670
|
|
2245
|
-
*
|
1671
|
+
*Earl St Sauver*
|
2246
1672
|
|
2247
|
-
*
|
1673
|
+
* Fix unexpected behavior for `has_many :through` associations going through
|
1674
|
+
a scoped `has_many`.
|
2248
1675
|
|
2249
|
-
|
1676
|
+
If a `has_many` association is adjusted using a scope, and another
|
1677
|
+
`has_many :through` uses this association, then the scope adjustment is
|
1678
|
+
unexpectedly neglected.
|
2250
1679
|
|
2251
|
-
|
2252
|
-
suite. The class is no longer public and is only used for internal
|
2253
|
-
Rails tests.
|
1680
|
+
Fixes #14537.
|
2254
1681
|
|
2255
|
-
*
|
1682
|
+
*Jan Habermann*
|
2256
1683
|
|
2257
|
-
*
|
2258
|
-
in associations.
|
1684
|
+
* `@destroyed` should always be set to `false` when an object is duped.
|
2259
1685
|
|
2260
|
-
*
|
1686
|
+
*Kuldeep Aggarwal*
|
2261
1687
|
|
2262
|
-
*
|
1688
|
+
* Enable `has_many` associations to support irregular inflections.
|
2263
1689
|
|
2264
|
-
|
1690
|
+
Fixes #8928.
|
2265
1691
|
|
2266
|
-
*
|
1692
|
+
*arthurnn*, *Javier Goizueta*
|
2267
1693
|
|
2268
|
-
|
1694
|
+
* Fix `count` used with a grouping not returning a Hash.
|
2269
1695
|
|
2270
|
-
|
1696
|
+
Fixes #14721.
|
2271
1697
|
|
2272
|
-
*
|
1698
|
+
*Eric Chahin*
|
2273
1699
|
|
2274
|
-
*
|
1700
|
+
* `sanitize_sql_like` helper method to escape a string for safe use in an SQL
|
1701
|
+
LIKE statement.
|
2275
1702
|
|
2276
|
-
|
1703
|
+
Example:
|
2277
1704
|
|
2278
|
-
|
1705
|
+
class Article
|
1706
|
+
def self.search(term)
|
1707
|
+
where("title LIKE ?", sanitize_sql_like(term))
|
1708
|
+
end
|
1709
|
+
end
|
2279
1710
|
|
2280
|
-
|
1711
|
+
Article.search("20% _reduction_")
|
1712
|
+
# => Query looks like "... title LIKE '20\% \_reduction\_' ..."
|
2281
1713
|
|
2282
|
-
*
|
1714
|
+
*Rob Gilson*, *Yves Senn*
|
2283
1715
|
|
2284
|
-
|
2285
|
-
feature was deprecated in Rails 4.0. This is being removed.
|
2286
|
-
`delete_all` will continue to honor the `:dependent` option. However
|
2287
|
-
if `:dependent` value is `:destroy` then the `:delete_all` deletion
|
2288
|
-
strategy for that collection will be applied.
|
1716
|
+
* Do not quote uuid default value on `change_column`.
|
2289
1717
|
|
2290
|
-
|
2291
|
-
`delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
|
1718
|
+
Fixes #14604.
|
2292
1719
|
|
2293
|
-
*
|
1720
|
+
*Eric Chahin*
|
2294
1721
|
|
2295
|
-
*
|
1722
|
+
* The comparison between `Relation` and `CollectionProxy` should be consistent.
|
2296
1723
|
|
2297
|
-
|
1724
|
+
Example:
|
2298
1725
|
|
2299
|
-
|
1726
|
+
author.posts == Post.where(author_id: author.id)
|
1727
|
+
# => true
|
1728
|
+
Post.where(author_id: author.id) == author.posts
|
1729
|
+
# => true
|
2300
1730
|
|
2301
|
-
|
1731
|
+
Fixes #13506.
|
2302
1732
|
|
2303
|
-
*
|
2304
|
-
association.
|
1733
|
+
*Lauro Caetano*
|
2305
1734
|
|
2306
|
-
|
2307
|
-
collection
|
1735
|
+
* Calling `delete_all` on an unloaded `CollectionProxy` no longer
|
1736
|
+
generates an SQL statement containing each id of the collection:
|
2308
1737
|
|
2309
|
-
|
1738
|
+
Before:
|
2310
1739
|
|
2311
|
-
|
2312
|
-
|
1740
|
+
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
1741
|
+
AND `model`.`id` IN (1, 2, 3...)
|
2313
1742
|
|
2314
|
-
|
1743
|
+
After:
|
2315
1744
|
|
2316
|
-
|
1745
|
+
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
2317
1746
|
|
2318
|
-
*
|
1747
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
2319
1748
|
|
2320
|
-
*
|
1749
|
+
* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
|
1750
|
+
with `select`.
|
2321
1751
|
|
2322
|
-
|
1752
|
+
Fixes #13648.
|
2323
1753
|
|
2324
|
-
*
|
2325
|
-
`partial_updates=`.
|
1754
|
+
*Simon Woker*
|
2326
1755
|
|
2327
|
-
|
1756
|
+
* PostgreSQL adapter only warns once for every missing OID per connection.
|
2328
1757
|
|
2329
|
-
|
1758
|
+
Fixes #14275.
|
2330
1759
|
|
2331
|
-
*
|
1760
|
+
*Matthew Draper*, *Yves Senn*
|
2332
1761
|
|
2333
|
-
*
|
1762
|
+
* PostgreSQL adapter automatically reloads it's type map when encountering
|
1763
|
+
unknown OIDs.
|
2334
1764
|
|
2335
|
-
|
1765
|
+
Fixes #14678.
|
2336
1766
|
|
2337
|
-
*
|
1767
|
+
*Matthew Draper*, *Yves Senn*
|
2338
1768
|
|
2339
|
-
|
1769
|
+
* Fix insertion of records via `has_many :through` association with scope.
|
2340
1770
|
|
2341
|
-
|
2342
|
-
Comment.where('posts.author_id' => 7)
|
1771
|
+
Fixes #3548.
|
2343
1772
|
|
2344
|
-
|
2345
|
-
Comment.references(:posts).where('posts.author_id' => 7)
|
1773
|
+
*Ivan Antropov*
|
2346
1774
|
|
2347
|
-
|
1775
|
+
* Auto-generate stable fixture UUIDs on PostgreSQL.
|
2348
1776
|
|
2349
|
-
|
1777
|
+
Fixes #11524.
|
2350
1778
|
|
2351
|
-
|
2352
|
-
default_scope -> { where published: true }
|
2353
|
-
end
|
1779
|
+
*Roderick van Domburg*
|
2354
1780
|
|
2355
|
-
|
2356
|
-
|
2357
|
-
end
|
1781
|
+
* Fix a problem where an enum would overwrite values of another enum with the
|
1782
|
+
same name in an unrelated class.
|
2358
1783
|
|
2359
|
-
|
2360
|
-
comments on published posts, since that is the default scope for
|
2361
|
-
posts.
|
1784
|
+
Fixes #14607.
|
2362
1785
|
|
2363
|
-
|
2364
|
-
so we'd get comments on unpublished posts.
|
1786
|
+
*Evan Whalen*
|
2365
1787
|
|
2366
|
-
|
1788
|
+
* PostgreSQL and SQLite string columns no longer have a default limit of 255.
|
2367
1789
|
|
2368
|
-
|
1790
|
+
Fixes #13435, #9153.
|
2369
1791
|
|
2370
|
-
|
1792
|
+
*Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
|
2371
1793
|
|
2372
|
-
*
|
1794
|
+
* Make possible to have an association called `records`.
|
2373
1795
|
|
2374
|
-
|
1796
|
+
Fixes #11645.
|
2375
1797
|
|
2376
|
-
*
|
2377
|
-
can be chained with other `Enumerable` methods.
|
1798
|
+
*prathamesh-sonpatki*
|
2378
1799
|
|
2379
|
-
|
1800
|
+
* `to_sql` on an association now matches the query that is actually executed, where it
|
1801
|
+
could previously have incorrectly accrued additional conditions (e.g. as a result of
|
1802
|
+
a previous query). `CollectionProxy` now always defers to the association scope's
|
1803
|
+
`arel` method so the (incorrect) inherited one should be entirely concealed.
|
2380
1804
|
|
2381
|
-
|
2382
|
-
a block, so that it can be chained with other `Enumerable` methods.
|
1805
|
+
Fixes #14003.
|
2383
1806
|
|
2384
|
-
*
|
1807
|
+
*Jefferson Lai*
|
2385
1808
|
|
2386
|
-
*
|
1809
|
+
* Block a few default Class methods as scope name.
|
2387
1810
|
|
2388
|
-
|
2389
|
-
By flattening the array it ensures that string values are detected
|
2390
|
-
as strings and not arrays.
|
1811
|
+
For instance, this will raise:
|
2391
1812
|
|
2392
|
-
|
1813
|
+
scope :public, -> { where(status: 1) }
|
2393
1814
|
|
2394
|
-
*
|
1815
|
+
*arthurnn*
|
2395
1816
|
|
2396
|
-
*
|
1817
|
+
* Fix error when using `with_options` with lambda.
|
2397
1818
|
|
2398
|
-
|
2399
|
-
comments for the given post to set the inverse association.
|
1819
|
+
Fixes #9805.
|
2400
1820
|
|
2401
|
-
|
2402
|
-
records and all these 100k records would be loaded in memory
|
2403
|
-
even though the comment id was supplied.
|
1821
|
+
*Lauro Caetano*
|
2404
1822
|
|
2405
|
-
|
2406
|
-
|
1823
|
+
* Switch `sqlite3:///` URLs (which were temporarily
|
1824
|
+
deprecated in 4.1) from relative to absolute.
|
2407
1825
|
|
2408
|
-
|
1826
|
+
If you still want the previous interpretation, you should replace
|
1827
|
+
`sqlite3:///my/path` with `sqlite3:my/path`.
|
2409
1828
|
|
2410
|
-
*
|
1829
|
+
*Matthew Draper*
|
2411
1830
|
|
2412
|
-
*
|
2413
|
-
new connection. This means that calling `inspect`, when the
|
2414
|
-
database is missing, will no longer raise an exception.
|
2415
|
-
Fixes #10936.
|
1831
|
+
* Treat blank UUID values as `nil`.
|
2416
1832
|
|
2417
1833
|
Example:
|
2418
1834
|
|
2419
|
-
|
2420
|
-
|
2421
|
-
*Yves Senn*
|
1835
|
+
Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
|
2422
1836
|
|
2423
|
-
*
|
2424
|
-
Fixes #10881.
|
1837
|
+
*Dmitry Lavrov*
|
2425
1838
|
|
2426
|
-
|
1839
|
+
* Enable support for materialized views on PostgreSQL >= 9.3.
|
2427
1840
|
|
2428
|
-
*
|
1841
|
+
*Dave Lee*
|
2429
1842
|
|
2430
|
-
|
2431
|
-
`WHERE "users"."name" = 'a b'` then in the log all the
|
2432
|
-
whitespace is being squeezed. So the sql that is printed in the
|
2433
|
-
log is `WHERE "users"."name" = 'a b'`.
|
1843
|
+
* The PostgreSQL adapter supports custom domains. Fixes #14305.
|
2434
1844
|
|
2435
|
-
|
1845
|
+
*Yves Senn*
|
2436
1846
|
|
2437
|
-
|
1847
|
+
* PostgreSQL `Column#type` is now determined through the corresponding OID.
|
1848
|
+
The column types stay the same except for enum columns. They no longer have
|
1849
|
+
`nil` as type but `enum`.
|
2438
1850
|
|
2439
|
-
|
2440
|
-
This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
|
1851
|
+
See #7814.
|
2441
1852
|
|
2442
1853
|
*Yves Senn*
|
2443
1854
|
|
2444
|
-
* Fix
|
2445
|
-
|
1855
|
+
* Fix error when specifying a non-empty default value on a PostgreSQL array
|
1856
|
+
column.
|
2446
1857
|
|
2447
|
-
|
1858
|
+
Fixes #10613.
|
2448
1859
|
|
2449
|
-
*
|
2450
|
-
For example, you need to change this:
|
1860
|
+
*Luke Steensen*
|
2451
1861
|
|
2452
|
-
|
2453
|
-
|
2454
|
-
has_many :taggings, through: :posts
|
2455
|
-
end
|
1862
|
+
* Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
|
1863
|
+
custom primary key that did not save due to validation error.
|
2456
1864
|
|
2457
|
-
|
2458
|
-
has_one :tagging
|
2459
|
-
has_many :taggings
|
2460
|
-
end
|
1865
|
+
Fixes #14393.
|
2461
1866
|
|
2462
|
-
|
2463
|
-
end
|
1867
|
+
*Chris Finne*
|
2464
1868
|
|
2465
|
-
|
1869
|
+
* Introduce `validate` as an alias for `valid?`.
|
2466
1870
|
|
2467
|
-
|
2468
|
-
has_many :posts
|
2469
|
-
has_many :taggings, through: :posts, source: :tagging
|
2470
|
-
end
|
1871
|
+
This is more intuitive when you want to run validations but don't care about the return value.
|
2471
1872
|
|
2472
|
-
|
2473
|
-
has_one :tagging
|
2474
|
-
has_many :taggings
|
2475
|
-
end
|
1873
|
+
*Henrik Nyh*
|
2476
1874
|
|
2477
|
-
|
2478
|
-
end
|
1875
|
+
* Create indexes inline in CREATE TABLE for MySQL.
|
2479
1876
|
|
2480
|
-
|
1877
|
+
This is important, because adding an index on a temporary table after it has been created
|
1878
|
+
would commit the transaction.
|
2481
1879
|
|
2482
|
-
|
2483
|
-
|
2484
|
-
Fixes #5554.
|
1880
|
+
It also allows creating and dropping indexed tables with fewer queries and fewer permissions
|
1881
|
+
required.
|
2485
1882
|
|
2486
1883
|
Example:
|
2487
1884
|
|
2488
|
-
|
2489
|
-
|
2490
|
-
# After => ActiveRecord::StatementInvalid
|
2491
|
-
|
2492
|
-
# you can still use `count(:all)` to perform a query unrelated to the
|
2493
|
-
# selected columns
|
2494
|
-
User.select("name, username").count(:all) # => SELECT count(*) FROM users
|
2495
|
-
|
2496
|
-
*Yves Senn*
|
2497
|
-
|
2498
|
-
* Rails now automatically detects inverse associations. If you do not set the
|
2499
|
-
`:inverse_of` option on the association, then Active Record will guess the
|
2500
|
-
inverse association based on heuristics.
|
2501
|
-
|
2502
|
-
Note that automatic inverse detection only works on `has_many`, `has_one`,
|
2503
|
-
and `belongs_to` associations. Extra options on the associations will
|
2504
|
-
also prevent the association's inverse from being found automatically.
|
2505
|
-
|
2506
|
-
The automatic guessing of the inverse association uses a heuristic based
|
2507
|
-
on the name of the class, so it may not work for all associations,
|
2508
|
-
especially the ones with non-standard names.
|
2509
|
-
|
2510
|
-
You can turn off the automatic detection of inverse associations by setting
|
2511
|
-
the `:inverse_of` option to `false` like so:
|
2512
|
-
|
2513
|
-
class Taggable < ActiveRecord::Base
|
2514
|
-
belongs_to :tag, inverse_of: false
|
1885
|
+
create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
|
1886
|
+
t.index :zip
|
2515
1887
|
end
|
1888
|
+
# => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
|
2516
1889
|
|
2517
|
-
*
|
1890
|
+
*Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
|
2518
1891
|
|
2519
|
-
*
|
1892
|
+
* Use singular table name in generated migrations when
|
1893
|
+
`ActiveRecord::Base.pluralize_table_names` is `false`.
|
2520
1894
|
|
2521
|
-
|
1895
|
+
Fixes #13426.
|
1896
|
+
|
1897
|
+
*Kuldeep Aggarwal*
|
2522
1898
|
|
2523
|
-
*
|
2524
|
-
explicitly to mark records as `readonly.
|
2525
|
-
Fixes #10615.
|
1899
|
+
* `touch` accepts many attributes to be touched at once.
|
2526
1900
|
|
2527
1901
|
Example:
|
2528
1902
|
|
2529
|
-
|
2530
|
-
|
2531
|
-
user.save! # will raise error
|
1903
|
+
# touches :signed_at, :sealed_at, and :updated_at/on attributes.
|
1904
|
+
Photo.last.touch(:signed_at, :sealed_at)
|
2532
1905
|
|
2533
|
-
*
|
1906
|
+
*James Pinto*
|
2534
1907
|
|
2535
|
-
*
|
1908
|
+
* `rake db:structure:dump` only dumps schema information if the schema
|
1909
|
+
migration table exists.
|
2536
1910
|
|
2537
|
-
Fixes #
|
1911
|
+
Fixes #14217.
|
2538
1912
|
|
2539
1913
|
*Yves Senn*
|
2540
1914
|
|
2541
|
-
*
|
1915
|
+
* Reap connections that were checked out by now-dead threads, instead
|
1916
|
+
of waiting until they disconnect by themselves. Before this change,
|
1917
|
+
a suitably constructed series of short-lived threads could starve
|
1918
|
+
the connection pool, without ever having more than a couple alive at
|
1919
|
+
the same time.
|
2542
1920
|
|
2543
|
-
|
2544
|
-
|
2545
|
-
*Aaron Patterson*
|
1921
|
+
*Matthew Draper*
|
2546
1922
|
|
2547
|
-
*
|
1923
|
+
* `pk_and_sequence_for` now ensures that only the pg_depend entries
|
1924
|
+
pointing to pg_class, and thus only sequence objects, are considered.
|
2548
1925
|
|
2549
|
-
*
|
1926
|
+
*Josh Williams*
|
2550
1927
|
|
2551
|
-
*
|
2552
|
-
as it is no longer used by internals.
|
1928
|
+
* `where.not` adds `references` for `includes` like normal `where` calls do.
|
2553
1929
|
|
2554
|
-
|
1930
|
+
Fixes #14406.
|
2555
1931
|
|
2556
|
-
*
|
2557
|
-
is not blank.
|
1932
|
+
*Yves Senn*
|
2558
1933
|
|
2559
|
-
|
2560
|
-
being picked up in `method_missing`.
|
1934
|
+
* Extend fixture `$LABEL` replacement to allow string interpolation.
|
2561
1935
|
|
2562
|
-
|
2563
|
-
table name, and calls `proper_table_name` on the arguments before sending to
|
2564
|
-
`connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
|
2565
|
-
version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
|
1936
|
+
Example:
|
2566
1937
|
|
2567
|
-
|
1938
|
+
martin:
|
1939
|
+
email: $LABEL@email.com
|
2568
1940
|
|
2569
|
-
|
1941
|
+
users(:martin).email # => martin@email.com
|
2570
1942
|
|
2571
|
-
*
|
1943
|
+
*Eric Steele*
|
2572
1944
|
|
2573
|
-
|
1945
|
+
* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
|
2574
1946
|
|
2575
|
-
|
1947
|
+
Fixes #14361.
|
2576
1948
|
|
2577
|
-
*
|
1949
|
+
*arthurnn*
|
2578
1950
|
|
2579
|
-
*
|
2580
|
-
`
|
2581
|
-
causing `PredicateBuilder` to call non-existent method
|
2582
|
-
`Class#reflect_on_association`.
|
1951
|
+
* Passing an Active Record object to `find` or `exists?` is now deprecated.
|
1952
|
+
Call `.id` on the object first.
|
2583
1953
|
|
2584
|
-
*
|
1954
|
+
*Aaron Patterson*
|
2585
1955
|
|
2586
|
-
*
|
1956
|
+
* Only use BINARY for MySQL case sensitive uniqueness check when column
|
1957
|
+
has a case insensitive collation.
|
2587
1958
|
|
2588
|
-
|
2589
|
-
failing since options is an array and not a hash.
|
1959
|
+
*Ryuta Kamizono*
|
2590
1960
|
|
2591
|
-
|
2592
|
-
change_table :users do |t|
|
2593
|
-
t.remove_index [:name, :email]
|
2594
|
-
end
|
2595
|
-
end
|
1961
|
+
* Support for MySQL 5.6 fractional seconds.
|
2596
1962
|
|
2597
|
-
|
1963
|
+
*arthurnn*, *Tatsuhiko Miyagawa*
|
2598
1964
|
|
2599
|
-
|
1965
|
+
* Support for PostgreSQL `citext` data type enabling case-insensitive
|
1966
|
+
`where` values without needing to wrap in UPPER/LOWER sql functions.
|
2600
1967
|
|
2601
|
-
*
|
1968
|
+
*Troy Kruthoff*, *Lachlan Sylvester*
|
2602
1969
|
|
2603
|
-
*
|
1970
|
+
* Only save has_one associations if record has changes.
|
1971
|
+
Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
|
1972
|
+
object did not get saved to the db.
|
2604
1973
|
|
2605
|
-
|
2606
|
-
child object yourself before assignment, then the NestedAttributes
|
2607
|
-
module will not overwrite it, e.g.:
|
1974
|
+
*Alan Kennedy*
|
2608
1975
|
|
2609
|
-
|
2610
|
-
has_one :avatar
|
2611
|
-
accepts_nested_attributes_for :avatar
|
1976
|
+
* Allow strings to specify the `#order` value.
|
2612
1977
|
|
2613
|
-
|
2614
|
-
super || build_avatar(width: 200)
|
2615
|
-
end
|
2616
|
-
end
|
1978
|
+
Example:
|
2617
1979
|
|
2618
|
-
|
2619
|
-
member.avatar_attributes = {icon: 'sad'}
|
2620
|
-
member.avatar.width # => 200
|
1980
|
+
Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
|
2621
1981
|
|
2622
|
-
*
|
1982
|
+
*Marcelo Casiraghi*, *Robin Dupret*
|
2623
1983
|
|
2624
|
-
*
|
2625
|
-
|
2626
|
-
unique value' database error that would occur if a record being created had
|
2627
|
-
the same value on a unique indexed field as that of a record being destroyed.
|
1984
|
+
* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
|
1985
|
+
warnings on enum columns.
|
2628
1986
|
|
2629
|
-
*
|
1987
|
+
*Dieter Komendera*
|
2630
1988
|
|
2631
|
-
*
|
1989
|
+
* `includes` is able to detect the right preloading strategy when string
|
1990
|
+
joins are involved.
|
2632
1991
|
|
2633
|
-
|
1992
|
+
Fixes #14109.
|
2634
1993
|
|
2635
|
-
|
1994
|
+
*Aaron Patterson*, *Yves Senn*
|
2636
1995
|
|
2637
|
-
|
2638
|
-
|
2639
|
-
end
|
1996
|
+
* Fix error with validation with enum fields for records where the value for
|
1997
|
+
any enum attribute is always evaluated as 0 during uniqueness validation.
|
2640
1998
|
|
2641
|
-
|
1999
|
+
Fixes #14172.
|
2642
2000
|
|
2643
|
-
|
2001
|
+
*Vilius Luneckas* *Ahmed AbouElhamayed*
|
2644
2002
|
|
2645
|
-
|
2003
|
+
* `before_add` callbacks are fired before the record is saved on
|
2004
|
+
`has_and_belongs_to_many` associations *and* on `has_many :through`
|
2005
|
+
associations. Before this change, `before_add` callbacks would be fired
|
2006
|
+
before the record was saved on `has_and_belongs_to_many` associations, but
|
2007
|
+
*not* on `has_many :through` associations.
|
2646
2008
|
|
2647
|
-
|
2009
|
+
Fixes #14144.
|
2648
2010
|
|
2649
|
-
|
2011
|
+
* Fix STI classes not defining an attribute method if there is a conflicting
|
2012
|
+
private method defined on its ancestors.
|
2650
2013
|
|
2651
|
-
|
2014
|
+
Fixes #11569.
|
2652
2015
|
|
2653
2016
|
*Godfrey Chan*
|
2654
2017
|
|
2655
|
-
*
|
2018
|
+
* Coerce strings when reading attributes. Fixes #10485.
|
2656
2019
|
|
2657
|
-
|
2020
|
+
Example:
|
2658
2021
|
|
2659
|
-
|
2022
|
+
book = Book.new(title: 12345)
|
2023
|
+
book.save!
|
2024
|
+
book.title # => "12345"
|
2660
2025
|
|
2661
|
-
|
2026
|
+
*Yves Senn*
|
2662
2027
|
|
2663
|
-
|
2028
|
+
* Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
|
2029
|
+
We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
|
2030
|
+
possible because the Ruby range does not support excluded beginnings.
|
2664
2031
|
|
2665
|
-
|
2032
|
+
The current solution of incrementing the beginning is not correct and is now
|
2033
|
+
deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
|
2034
|
+
is not defined) it will raise an `ArgumentException` for ranges with excluding
|
2035
|
+
beginnings.
|
2666
2036
|
|
2667
|
-
*
|
2037
|
+
*Yves Senn*
|
2668
2038
|
|
2669
|
-
*
|
2039
|
+
* Support for user created range types in PostgreSQL.
|
2670
2040
|
|
2671
|
-
*
|
2041
|
+
*Yves Senn*
|
2672
2042
|
|
2673
|
-
Please check [4-
|
2043
|
+
Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.
|