activerecord 3.2.22.5 → 4.2.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (236) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1632 -609
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +37 -41
  5. data/examples/performance.rb +31 -19
  6. data/examples/simple.rb +4 -4
  7. data/lib/active_record/aggregations.rb +56 -42
  8. data/lib/active_record/association_relation.rb +35 -0
  9. data/lib/active_record/associations/alias_tracker.rb +47 -36
  10. data/lib/active_record/associations/association.rb +73 -55
  11. data/lib/active_record/associations/association_scope.rb +143 -82
  12. data/lib/active_record/associations/belongs_to_association.rb +65 -25
  13. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +7 -2
  14. data/lib/active_record/associations/builder/association.rb +125 -31
  15. data/lib/active_record/associations/builder/belongs_to.rb +89 -61
  16. data/lib/active_record/associations/builder/collection_association.rb +69 -49
  17. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +113 -42
  18. data/lib/active_record/associations/builder/has_many.rb +8 -64
  19. data/lib/active_record/associations/builder/has_one.rb +12 -51
  20. data/lib/active_record/associations/builder/singular_association.rb +23 -17
  21. data/lib/active_record/associations/collection_association.rb +251 -177
  22. data/lib/active_record/associations/collection_proxy.rb +963 -63
  23. data/lib/active_record/associations/foreign_association.rb +11 -0
  24. data/lib/active_record/associations/has_many_association.rb +113 -22
  25. data/lib/active_record/associations/has_many_through_association.rb +99 -39
  26. data/lib/active_record/associations/has_one_association.rb +43 -20
  27. data/lib/active_record/associations/has_one_through_association.rb +1 -1
  28. data/lib/active_record/associations/join_dependency/join_association.rb +76 -107
  29. data/lib/active_record/associations/join_dependency/join_base.rb +7 -9
  30. data/lib/active_record/associations/join_dependency/join_part.rb +30 -37
  31. data/lib/active_record/associations/join_dependency.rb +230 -156
  32. data/lib/active_record/associations/preloader/association.rb +96 -55
  33. data/lib/active_record/associations/preloader/collection_association.rb +3 -3
  34. data/lib/active_record/associations/preloader/has_many_through.rb +7 -3
  35. data/lib/active_record/associations/preloader/has_one.rb +1 -1
  36. data/lib/active_record/associations/preloader/singular_association.rb +3 -3
  37. data/lib/active_record/associations/preloader/through_association.rb +62 -33
  38. data/lib/active_record/associations/preloader.rb +101 -79
  39. data/lib/active_record/associations/singular_association.rb +29 -13
  40. data/lib/active_record/associations/through_association.rb +30 -16
  41. data/lib/active_record/associations.rb +463 -345
  42. data/lib/active_record/attribute.rb +163 -0
  43. data/lib/active_record/attribute_assignment.rb +142 -151
  44. data/lib/active_record/attribute_decorators.rb +66 -0
  45. data/lib/active_record/attribute_methods/before_type_cast.rb +52 -7
  46. data/lib/active_record/attribute_methods/dirty.rb +137 -57
  47. data/lib/active_record/attribute_methods/primary_key.rb +50 -36
  48. data/lib/active_record/attribute_methods/query.rb +5 -4
  49. data/lib/active_record/attribute_methods/read.rb +73 -106
  50. data/lib/active_record/attribute_methods/serialization.rb +44 -94
  51. data/lib/active_record/attribute_methods/time_zone_conversion.rb +49 -45
  52. data/lib/active_record/attribute_methods/write.rb +57 -44
  53. data/lib/active_record/attribute_methods.rb +301 -141
  54. data/lib/active_record/attribute_set/builder.rb +106 -0
  55. data/lib/active_record/attribute_set.rb +81 -0
  56. data/lib/active_record/attributes.rb +147 -0
  57. data/lib/active_record/autosave_association.rb +246 -217
  58. data/lib/active_record/base.rb +70 -474
  59. data/lib/active_record/callbacks.rb +66 -28
  60. data/lib/active_record/coders/json.rb +13 -0
  61. data/lib/active_record/coders/yaml_column.rb +18 -21
  62. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +396 -219
  63. data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
  64. data/lib/active_record/connection_adapters/abstract/database_statements.rb +167 -164
  65. data/lib/active_record/connection_adapters/abstract/query_cache.rb +29 -24
  66. data/lib/active_record/connection_adapters/abstract/quoting.rb +74 -55
  67. data/lib/active_record/connection_adapters/abstract/savepoints.rb +21 -0
  68. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +125 -0
  69. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +261 -169
  70. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +50 -0
  71. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +707 -259
  72. data/lib/active_record/connection_adapters/abstract/transaction.rb +215 -0
  73. data/lib/active_record/connection_adapters/abstract_adapter.rb +298 -89
  74. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +466 -196
  75. data/lib/active_record/connection_adapters/column.rb +31 -245
  76. data/lib/active_record/connection_adapters/connection_specification.rb +275 -0
  77. data/lib/active_record/connection_adapters/mysql2_adapter.rb +45 -57
  78. data/lib/active_record/connection_adapters/mysql_adapter.rb +180 -123
  79. data/lib/active_record/connection_adapters/postgresql/array_parser.rb +93 -0
  80. data/lib/active_record/connection_adapters/postgresql/column.rb +20 -0
  81. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +232 -0
  82. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +100 -0
  83. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +52 -0
  84. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +13 -0
  85. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +15 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +46 -0
  87. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +11 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +36 -0
  89. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +13 -0
  90. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +19 -0
  91. data/lib/active_record/connection_adapters/postgresql/oid/float.rb +21 -0
  92. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +59 -0
  93. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +13 -0
  94. data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +13 -0
  95. data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +11 -0
  96. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +35 -0
  97. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +23 -0
  98. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +43 -0
  99. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +43 -0
  100. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +79 -0
  101. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +19 -0
  102. data/lib/active_record/connection_adapters/postgresql/oid/time.rb +11 -0
  103. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +109 -0
  104. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +21 -0
  105. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +26 -0
  106. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +28 -0
  107. data/lib/active_record/connection_adapters/postgresql/oid.rb +36 -0
  108. data/lib/active_record/connection_adapters/postgresql/quoting.rb +108 -0
  109. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +30 -0
  110. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +152 -0
  111. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +596 -0
  112. data/lib/active_record/connection_adapters/postgresql/utils.rb +77 -0
  113. data/lib/active_record/connection_adapters/postgresql_adapter.rb +430 -999
  114. data/lib/active_record/connection_adapters/schema_cache.rb +52 -27
  115. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +579 -22
  116. data/lib/active_record/connection_handling.rb +132 -0
  117. data/lib/active_record/core.rb +579 -0
  118. data/lib/active_record/counter_cache.rb +157 -105
  119. data/lib/active_record/dynamic_matchers.rb +119 -63
  120. data/lib/active_record/enum.rb +197 -0
  121. data/lib/active_record/errors.rb +94 -36
  122. data/lib/active_record/explain.rb +15 -63
  123. data/lib/active_record/explain_registry.rb +30 -0
  124. data/lib/active_record/explain_subscriber.rb +9 -5
  125. data/lib/active_record/fixture_set/file.rb +56 -0
  126. data/lib/active_record/fixtures.rb +302 -215
  127. data/lib/active_record/gem_version.rb +15 -0
  128. data/lib/active_record/inheritance.rb +143 -70
  129. data/lib/active_record/integration.rb +65 -12
  130. data/lib/active_record/legacy_yaml_adapter.rb +30 -0
  131. data/lib/active_record/locale/en.yml +8 -1
  132. data/lib/active_record/locking/optimistic.rb +73 -52
  133. data/lib/active_record/locking/pessimistic.rb +5 -5
  134. data/lib/active_record/log_subscriber.rb +24 -21
  135. data/lib/active_record/migration/command_recorder.rb +124 -32
  136. data/lib/active_record/migration/join_table.rb +15 -0
  137. data/lib/active_record/migration.rb +511 -213
  138. data/lib/active_record/model_schema.rb +91 -117
  139. data/lib/active_record/nested_attributes.rb +184 -130
  140. data/lib/active_record/no_touching.rb +52 -0
  141. data/lib/active_record/null_relation.rb +81 -0
  142. data/lib/active_record/persistence.rb +276 -117
  143. data/lib/active_record/query_cache.rb +19 -37
  144. data/lib/active_record/querying.rb +28 -18
  145. data/lib/active_record/railtie.rb +73 -40
  146. data/lib/active_record/railties/console_sandbox.rb +3 -4
  147. data/lib/active_record/railties/controller_runtime.rb +4 -3
  148. data/lib/active_record/railties/databases.rake +141 -416
  149. data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
  150. data/lib/active_record/readonly_attributes.rb +1 -4
  151. data/lib/active_record/reflection.rb +513 -154
  152. data/lib/active_record/relation/batches.rb +91 -43
  153. data/lib/active_record/relation/calculations.rb +199 -161
  154. data/lib/active_record/relation/delegation.rb +116 -25
  155. data/lib/active_record/relation/finder_methods.rb +362 -248
  156. data/lib/active_record/relation/merger.rb +193 -0
  157. data/lib/active_record/relation/predicate_builder/array_handler.rb +48 -0
  158. data/lib/active_record/relation/predicate_builder/relation_handler.rb +13 -0
  159. data/lib/active_record/relation/predicate_builder.rb +135 -43
  160. data/lib/active_record/relation/query_methods.rb +928 -167
  161. data/lib/active_record/relation/spawn_methods.rb +48 -149
  162. data/lib/active_record/relation.rb +352 -207
  163. data/lib/active_record/result.rb +101 -10
  164. data/lib/active_record/runtime_registry.rb +22 -0
  165. data/lib/active_record/sanitization.rb +56 -59
  166. data/lib/active_record/schema.rb +19 -13
  167. data/lib/active_record/schema_dumper.rb +106 -63
  168. data/lib/active_record/schema_migration.rb +53 -0
  169. data/lib/active_record/scoping/default.rb +50 -57
  170. data/lib/active_record/scoping/named.rb +73 -109
  171. data/lib/active_record/scoping.rb +58 -123
  172. data/lib/active_record/serialization.rb +6 -2
  173. data/lib/active_record/serializers/xml_serializer.rb +12 -22
  174. data/lib/active_record/statement_cache.rb +111 -0
  175. data/lib/active_record/store.rb +168 -15
  176. data/lib/active_record/tasks/database_tasks.rb +299 -0
  177. data/lib/active_record/tasks/mysql_database_tasks.rb +159 -0
  178. data/lib/active_record/tasks/postgresql_database_tasks.rb +101 -0
  179. data/lib/active_record/tasks/sqlite_database_tasks.rb +55 -0
  180. data/lib/active_record/timestamp.rb +23 -16
  181. data/lib/active_record/transactions.rb +125 -79
  182. data/lib/active_record/type/big_integer.rb +13 -0
  183. data/lib/active_record/type/binary.rb +50 -0
  184. data/lib/active_record/type/boolean.rb +31 -0
  185. data/lib/active_record/type/date.rb +50 -0
  186. data/lib/active_record/type/date_time.rb +54 -0
  187. data/lib/active_record/type/decimal.rb +64 -0
  188. data/lib/active_record/type/decimal_without_scale.rb +11 -0
  189. data/lib/active_record/type/decorator.rb +14 -0
  190. data/lib/active_record/type/float.rb +19 -0
  191. data/lib/active_record/type/hash_lookup_type_map.rb +23 -0
  192. data/lib/active_record/type/integer.rb +59 -0
  193. data/lib/active_record/type/mutable.rb +16 -0
  194. data/lib/active_record/type/numeric.rb +36 -0
  195. data/lib/active_record/type/serialized.rb +62 -0
  196. data/lib/active_record/type/string.rb +40 -0
  197. data/lib/active_record/type/text.rb +11 -0
  198. data/lib/active_record/type/time.rb +26 -0
  199. data/lib/active_record/type/time_value.rb +38 -0
  200. data/lib/active_record/type/type_map.rb +64 -0
  201. data/lib/active_record/type/unsigned_integer.rb +15 -0
  202. data/lib/active_record/type/value.rb +110 -0
  203. data/lib/active_record/type.rb +23 -0
  204. data/lib/active_record/validations/associated.rb +24 -16
  205. data/lib/active_record/validations/presence.rb +67 -0
  206. data/lib/active_record/validations/uniqueness.rb +123 -64
  207. data/lib/active_record/validations.rb +36 -29
  208. data/lib/active_record/version.rb +5 -7
  209. data/lib/active_record.rb +66 -46
  210. data/lib/rails/generators/active_record/migration/migration_generator.rb +53 -8
  211. data/lib/rails/generators/active_record/{model/templates/migration.rb → migration/templates/create_table_migration.rb} +5 -1
  212. data/lib/rails/generators/active_record/migration/templates/migration.rb +20 -15
  213. data/lib/rails/generators/active_record/migration.rb +11 -8
  214. data/lib/rails/generators/active_record/model/model_generator.rb +9 -4
  215. data/lib/rails/generators/active_record/model/templates/model.rb +4 -6
  216. data/lib/rails/generators/active_record/model/templates/module.rb +1 -1
  217. data/lib/rails/generators/active_record.rb +3 -11
  218. metadata +101 -45
  219. data/examples/associations.png +0 -0
  220. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +0 -63
  221. data/lib/active_record/associations/join_helper.rb +0 -55
  222. data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +0 -60
  223. data/lib/active_record/attribute_methods/deprecated_underscore_read.rb +0 -32
  224. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +0 -191
  225. data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -583
  226. data/lib/active_record/dynamic_finder_match.rb +0 -68
  227. data/lib/active_record/dynamic_scope_match.rb +0 -23
  228. data/lib/active_record/fixtures/file.rb +0 -65
  229. data/lib/active_record/identity_map.rb +0 -162
  230. data/lib/active_record/observer.rb +0 -121
  231. data/lib/active_record/session_store.rb +0 -360
  232. data/lib/active_record/test_case.rb +0 -73
  233. data/lib/rails/generators/active_record/observer/observer_generator.rb +0 -15
  234. data/lib/rails/generators/active_record/observer/templates/observer.rb +0 -4
  235. data/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +0 -25
  236. data/lib/rails/generators/active_record/session_migration/templates/migration.rb +0 -12
data/CHANGELOG.md CHANGED
@@ -1,1020 +1,2043 @@
1
- * Support Ruby 2.3 by not unexpectedly calling `.to_proc` on Hash objects
1
+ ## Rails 4.2.11.3 (May 15, 2020) ##
2
2
 
3
- Fixes #25010
3
+ * No changes.
4
+
5
+
6
+ ## Rails 4.2.11.2 (May 15, 2020) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 4.2.11.1 (March 11, 2019) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 4.2.11 (November 27, 2018) ##
17
+
18
+ * No changes.
19
+
20
+
21
+ ## Rails 4.2.10 (September 27, 2017) ##
22
+
23
+ * `Relation#joins` is no longer affected by the target model's
24
+ `current_scope`, with the exception of `unscoped`.
25
+
26
+ Fixes #29338.
27
+
28
+ *Sean Griffin*
29
+
30
+ ## Rails 4.2.9 (June 26, 2017) ##
31
+
32
+ * Fix regression caused by `collection_singular_ids=` ignoring different primary key on relationship.
33
+
34
+ *Nick Pezza*
35
+
36
+ * Fix `rake db:schema:load` with subdirectories.
37
+
38
+ *Ryuta Kamizono*
39
+
40
+ * Fix `rake db:migrate:status` with subdirectories.
41
+
42
+ *Ryuta Kamizono*
43
+
44
+ * Fix regression of #1969 with SELECT aliases in HAVING clause.
45
+
46
+ *Eugene Kenny*
47
+
48
+ * Fix `wait_timeout` to configurable for mysql2 adapter.
49
+
50
+ Fixes #26556.
51
+
52
+ *Ryuta Kamizono*
53
+
54
+ * Make `table_name=` reset current statement cache,
55
+ so queries are not run against the previous table name.
56
+
57
+ *namusyaka*
58
+
59
+
60
+ ## Rails 4.2.8 (February 21, 2017) ##
61
+
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.
64
+
65
+ *Dylan Thacker-Smith*
66
+
67
+ * Bust Model.attribute_names cache when resetting column information
68
+
69
+ *James Coleman*
70
+
71
+ * Fix query caching when type information is reset
72
+
73
+ Backports ancillary fix in 5.0.
74
+
75
+ *James Coleman*
76
+
77
+ * Allow `joins` to be unscoped.
78
+
79
+ Fixes #13775.
80
+
81
+ *Takashi Kokubun*
82
+
83
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
84
+ mapping methods are methods implemented on `Hash`.
85
+
86
+ Fixes #25978.
87
+
88
+ *Sean Griffin*
89
+
90
+
91
+ ## Rails 4.2.7 (July 12, 2016) ##
92
+
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.
96
+
97
+ *Kevin McPhillips*
98
+
99
+ * Ensure hashes can be assigned to attributes created using `composed_of`.
100
+ Fixes #25210.
101
+
102
+ *Sean Griffin*
103
+
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.
108
+
109
+ *Rafael Sales*
110
+
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).
114
+
115
+ Fixes #20434
116
+
117
+ *Konstantinos Rousis*
118
+
119
+ * Correctly pass MySQL options when using structure_dump or structure_load
120
+
121
+ Specifically, it fixes an issue when using SSL authentication.
122
+
123
+ *Alex Coomans*
124
+
125
+
126
+ ## Rails 4.2.6 (March 07, 2016) ##
127
+
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.
130
+
131
+ *George Millo*
132
+
133
+ * Fix regression in dirty attribute tracking after #dup. Changes to the
134
+ clone no longer show as changed attributes in the original object.
135
+
136
+ *Dominic Cleal*
137
+
138
+ * Fix regression when loading fixture files with symbol keys.
139
+
140
+ Closes #22584.
141
+
142
+ *Yves Senn*
143
+
144
+ * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
145
+
146
+ Fixes #22346.
147
+
148
+ *Nick Muerdter*, *ckoenig*
149
+
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).
153
+
154
+ *Yves Senn*, *Matthew Draper*
155
+
156
+
157
+ ## Rails 4.2.5.2 (February 26, 2016) ##
158
+
159
+ * No changes.
160
+
161
+
162
+ ## Rails 4.2.5.1 (January 25, 2015) ##
163
+
164
+ * No changes.
165
+
166
+
167
+ ## Rails 4.2.5 (November 12, 2015) ##
168
+
169
+ * No longer pass deprecated option `-i` to `pg_dump`.
170
+
171
+ *Paul Sadauskas*
172
+
173
+ * Set `scope.reordering_value` to `true` if :reordering values are specified.
174
+
175
+ Fixes #21886.
176
+
177
+ *Hiroaki Izu*
178
+
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.
187
+
188
+ Fixes #22101.
189
+
190
+ *Harry Marr*
191
+
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.
194
+
195
+ Fixes #16032.
196
+
197
+ Examples:
198
+
199
+ before:
200
+
201
+ Project.first.salaried_developers.size # => 3
202
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 1
203
+
204
+ after:
205
+
206
+ Project.first.salaried_developers.size # => 3
207
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 3
208
+
209
+ *Bigxiang*
210
+
211
+ * Descriptive error message when fixtures contain a missing column.
212
+
213
+ Closes #21201.
214
+
215
+ *Yves Senn*
216
+
217
+ * `bin/rake db:migrate` uses
218
+ `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
219
+ `Migrator.migrations_paths`.
220
+
221
+ *Tobias Bielohlawek*
222
+
223
+ * Fix `rewhere` in a `has_many` association.
224
+
225
+ Fixes #21955.
226
+
227
+ *Josh Branchaud*, *Kal*
228
+
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.
234
+
235
+ *Bryan Paxton*
236
+
237
+ * Avoid leaking the first relation we call `first` on, per model.
238
+
239
+ Fixes #21921.
240
+
241
+ *Matthew Draper*, *Jean Boussier*
242
+
243
+ * Allow deserialization of Active Record models that were YAML encoded prior
244
+ to Rails 4.2
245
+
246
+ *Sean Griffin*
247
+
248
+ * Correctly apply `unscope` when preloading through associations.
249
+
250
+ *Jimmy Bourassa*
251
+
252
+ * Ensure `select` quotes aliased attributes, even when using `from`.
253
+
254
+ Fixes #21488
255
+
256
+ *Sean Griffin & @johanlunds*
257
+
258
+ * Correct query for PostgreSQL 8.2 compatibility.
259
+
260
+ *Ben Murphy*, *Matthew Draper*
261
+
262
+ * Uniqueness validator raises descriptive error when running on a persisted
263
+ record without primary key.
264
+
265
+ Closes #21304.
266
+
267
+ *Yves Senn*
268
+
269
+
270
+ ## Rails 4.2.4 (August 24, 2015) ##
271
+
272
+ * Skip statement cache on through association reader.
273
+
274
+ If the through class has default scopes we should skip the statement
275
+ cache.
276
+
277
+ Closes #20745.
278
+
279
+ *Rafael Mendonça França*
280
+
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.
284
+
285
+ *Jake Waller*
286
+
287
+ * Fix state being carried over from previous transaction.
288
+
289
+ Considering the following example where `name` is a required attribute.
290
+ Before we had `new_record?` returning `true` for a persisted record:
291
+
292
+ author = Author.create! name: 'foo'
293
+ author.name = nil
294
+ author.save # => false
295
+ author.new_record? # => true
296
+
297
+ Fixes #20824.
298
+
299
+ *Roque Pinel*
300
+
301
+ * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
302
+ when validating associations.
303
+
304
+ Fixes #20882.
305
+
306
+ *Sean Griffin*
307
+
308
+ * Fix through associations using scopes having the scope merged multiple
309
+ times.
310
+
311
+ Fixes #20721.
312
+ Fixes #20727.
313
+
314
+ *Sean Griffin*
315
+
316
+ * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
317
+ other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
318
+
319
+ Fixes #20743.
320
+
321
+ *Yves Senn*
322
+
323
+ * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
324
+ a wrong type to a namespaced association.
325
+
326
+ Fixes #20545.
327
+
328
+ *Diego Carrion*
329
+
330
+ * Prevent error when using `force_reload: true` on an unassigned polymorphic
331
+ belongs_to association.
332
+
333
+ Fixes #20426.
334
+
335
+ *James Dabbs*
336
+
337
+
338
+ ## Rails 4.2.3 (June 25, 2015) ##
339
+
340
+ * Let `WITH` queries (Common Table Expressions) be explainable.
341
+
342
+ *Vladimir Kochnev*
343
+
344
+ * Fix n+1 query problem when eager loading nil associations (fixes #18312)
345
+
346
+ *Sammy Larbi*
347
+
348
+ * Fixed an error which would occur in dirty checking when calling
349
+ `update_attributes` from a getter.
350
+
351
+ Fixes #20531.
352
+
353
+ *Sean Griffin*
354
+
355
+ * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
356
+ as columns.
357
+
358
+ Fixes #20360.
359
+
360
+ *Sean Griffin*
361
+
362
+ * Clear query cache when `ActiveRecord::Base#reload` is called.
363
+
364
+ *Shane Hender*
365
+
366
+ * Pass `:extend` option for `has_and_belongs_to_many` associations to the
367
+ underlying `has_many :through`.
368
+
369
+ *Jaehyun Shin*
370
+
371
+ * Make `unscope` aware of "less than" and "greater than" conditions.
372
+
373
+ *TAKAHASHI Kazuaki*
374
+
375
+ * Revert behavior of `db:schema:load` back to loading the full
376
+ environment. This ensures that initializers are run.
377
+
378
+ Fixes #19545.
379
+
380
+ *Yves Senn*
381
+
382
+ * Fix missing index when using `timestamps` with the `index` option.
383
+
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.
387
+
388
+ *Paul Mucur*
389
+
390
+ * Rename `:class` to `:anonymous_class` in association options.
391
+
392
+ Fixes #19659.
393
+
394
+ *Andrew White*
395
+
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.
398
+
399
+ *Andrey Voronkov*
400
+
401
+ * Foreign key related methods in the migration DSL respect
402
+ `ActiveRecord::Base.pluralize_table_names = false`.
403
+
404
+ Fixes #19643.
405
+
406
+ *Mehmet Emin İNAÇ*
407
+
408
+ * Reduce memory usage from loading types on pg.
409
+
410
+ Fixes #19578.
411
+
412
+ *Sean Griffin*
413
+
414
+ * Fix referencing wrong table aliases while joining tables of has many through
415
+ association (only when calling calculation methods).
416
+
417
+ Fixes #19276.
418
+
419
+ *pinglamb*
420
+
421
+ * Don't attempt to update counter caches, when the column wasn't selected.
422
+
423
+ Fixes #19437.
424
+
425
+ *Sean Griffin*
426
+
427
+ * Correctly persist a serialized attribute that has been returned to
428
+ its default value by an in-place modification.
429
+
430
+ Fixes #19467.
431
+
432
+ *Matthew Draper*
433
+
434
+ * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
435
+
436
+ *James Cox*
437
+
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.
440
+
441
+ Fixes #15549.
442
+
443
+ *Will Bryant*, *Aaron Patterson*
444
+
445
+ * Correctly create through records when created on a has many through
446
+ association when using `where`.
447
+
448
+ Fixes #19073.
449
+
450
+ *Sean Griffin*
451
+
452
+
453
+ ## Rails 4.2.2 (June 16, 2015) ##
454
+
455
+ * No Changes *
456
+
457
+
458
+ ## Rails 4.2.1 (March 19, 2015) ##
459
+
460
+ * Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
461
+
462
+ Fixes #17139.
463
+
464
+ *Miklos Fazekas*
465
+
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.
469
+
470
+ Fixes #18664.
471
+
472
+ *Yves Senn*
473
+
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.
477
+
478
+ *Sean Griffin*
479
+
480
+ * Fix rounding problem for PostgreSQL timestamp column.
481
+
482
+ If timestamp column have the precision, it need to format according to
483
+ the precision of timestamp column.
484
+
485
+ *Ryuta Kamizono*
486
+
487
+ * Respect the database default charset for `schema_migrations` table.
488
+
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.
492
+
493
+ *Ryuta Kamizono*
494
+
495
+ * Respect custom primary keys for associations when calling `Relation#where`
496
+
497
+ Fixes #18813.
498
+
499
+ *Sean Griffin*
500
+
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`.
503
+
504
+ Fixes #10865.
505
+
506
+ *Sean Griffin*
507
+
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.
511
+
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.
514
+
515
+ *Chris Sinjakli*
516
+
517
+ * Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
518
+
519
+ SplitTest.group(:key).count
520
+ Property.group(:value).count
521
+
522
+ *Bogdan Gusiev*
523
+
524
+ * Don't define autosave association callbacks twice from
525
+ `accepts_nested_attributes_for`.
526
+
527
+ Fixes #18704.
528
+
529
+ *Sean Griffin*
530
+
531
+ * Integer types will no longer raise a `RangeError` when assigning an
532
+ attribute, but will instead raise when going to the database.
533
+
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.
536
+
537
+ *Sean Griffin*
538
+
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.
543
+
544
+ Fixes #18580.
545
+
546
+ *Sean Griffin*
547
+
548
+ * Don't remove join dependencies in `Relation#exists?`
549
+
550
+ Fixes #18632.
551
+
552
+ *Sean Griffin*
553
+
554
+ * Invalid values assigned to a JSON column are assumed to be `nil`.
555
+
556
+ Fixes #18629.
557
+
558
+ *Sean Griffin*
559
+
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.
564
+
565
+ Fixes #18467.
566
+
567
+ *Yves Senn*
568
+
569
+ * Correctly use the type provided by `serialize` when updating records using
570
+ optimistic locking.
571
+
572
+ Fixes #18385.
573
+
574
+ *Sean Griffin*
575
+
576
+ * `attribute_will_change!` will no longer cause non-persistable attributes to
577
+ be sent to the database.
578
+
579
+ Fixes #18407.
580
+
581
+ *Sean Griffin*
582
+
583
+ * Format the datetime string according to the precision of the datetime field.
584
+
585
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
586
+
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`:
589
+
590
+ http://bugs.mysql.com/bug.php?id=68760
591
+
592
+ *Ryuta Kamizono*
593
+
594
+ * Allow precision option for MySQL datetimes.
595
+
596
+ *Ryuta Kamizono*
597
+
598
+ * Clear query cache on rollback.
599
+
600
+ *Florian Weingarten*
601
+
602
+ * Fixed setting of foreign_key for through associations while building of new record.
603
+
604
+ Fixes #12698.
605
+
606
+ *Ivan Antropov*
607
+
608
+ * Fixed automatic inverse_of for models nested in module.
609
+
610
+ *Andrew McCloud*
611
+
612
+ * Fix `reaping_frequency` option when the value is a string.
613
+
614
+ This usually happens when it is configured using `DATABASE_URL`.
615
+
616
+ *korbin*
617
+
618
+ * Fix error message when trying to create an associated record and the foreign
619
+ key is missing.
620
+
621
+ Before this fix the following exception was being raised:
622
+
623
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
624
+
625
+ Now the message is:
626
+
627
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
628
+
629
+ *Rafael Mendonça França*
630
+
631
+ * Fix change detection problem for PostgreSQL bytea type and
632
+ `ArgumentError: string contains null byte` exception with pg-0.18.
633
+
634
+ Fixes #17680.
635
+
636
+ *Lars Kanis*
637
+
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.
642
+
643
+ Fixes #18070.
644
+
645
+ *arthurnn*
646
+
647
+ * Ensure `first!` and friends work on loaded associations.
648
+
649
+ Fixes #18237.
650
+
651
+ *Sean Griffin*
652
+
653
+ * Dump the default `nil` for PostgreSQL UUID primary key.
654
+
655
+ *Ryuta Kamizono*
656
+
657
+ * Don't raise when writing an attribute with an out-of-range datetime passed
658
+ by the user.
659
+
660
+ *Grey Baker*
661
+
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.
664
+
665
+ Fixes #18161.
666
+
667
+ *Daniel Fox*
668
+
669
+
670
+ ## Rails 4.2.0 (December 20, 2014) ##
671
+
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.
676
+
677
+ *Matthew Draper*, *Yves Senn*
678
+
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.
682
+
683
+ Fixes #17945.
684
+
685
+ *Yves Senn*
686
+
687
+ * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
688
+
689
+ *Ryuta Kamizono*
690
+
691
+ * Add `foreign_type` option to `has_one` and `has_many` association macros.
692
+
693
+ This option enables to define the column name of associated object's type for polymorphic associations.
694
+
695
+ *Ulisses Almeida, Kassio Borges*
696
+
697
+ * `add_timestamps` and `remove_timestamps` now properly reversible with
698
+ options.
699
+
700
+ *Noam Gagliardi-Rabinovich*
701
+
702
+ * Bring back `db:test:prepare` to synchronize the test database schema.
703
+
704
+ Manual synchronization using `bin/rake db:test:prepare` is required
705
+ when a migration is rolled-back, edited and reapplied.
706
+
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.
710
+
711
+ NOTE: `test:prepare` runs before the schema is synchronized.
712
+
713
+ Fixes #17171, #15787.
714
+
715
+ *Yves Senn*
716
+
717
+ * Change `reflections` public api to return the keys as String objects.
718
+
719
+ Fixes #16928.
720
+
721
+ *arthurnn*
722
+
723
+ * Renaming a table in pg also renames the primary key index.
724
+
725
+ Fixes #12856
726
+
727
+ *Sean Griffin*
728
+
729
+ * Make it possible to access fixtures excluded by a `default_scope`.
730
+
731
+ *Yves Senn*
4
732
 
5
- *tlrdstd*
733
+ * Fix preloading of associations with a scope containing joins along with
734
+ conditions on the joined association.
6
735
 
7
- ## Rails 3.2.22 (Jun 16, 2015) ##
736
+ *Siddharth Sharma*
8
737
 
9
- * No changes.
738
+ * Add `Table#name` to match `TableDefinition#name`.
10
739
 
740
+ *Cody Cutrer*
11
741
 
12
- ## Rails 3.2.19 (Jul 2, 2014) ##
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.
13
745
 
14
- * Fix SQL Injection Vulnerability in 'bitstring' quoting.
746
+ *Ben Woosley*
15
747
 
16
- Fixes CVE-2014-3482.
748
+ * `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
17
749
 
18
- *Rafael Mendonça França*
750
+ *Franky W.*
19
751
 
752
+ * Fix preloading of associations which unscope a default scope.
20
753
 
21
- ## Rails 3.2.18 (May 6, 2014) ##
754
+ Fixes #11036.
22
755
 
23
- * No changes.
756
+ *Byron Bischoff*
24
757
 
758
+ * Added SchemaDumper support for tables with jsonb columns.
25
759
 
26
- ## Rails 3.2.17 (Feb 18, 2014) ##
760
+ *Ted O'Meara*
27
761
 
28
- * No changes.
762
+ * Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
763
+ `Relation` for performing queries and updates is the prefered API.
29
764
 
765
+ *Sean Griffin*
30
766
 
31
- ## Rails 3.2.16 (Dec 3, 2013) ##
767
+ * Queries now properly type cast values that are part of a join statement,
768
+ even when using type decorators such as `serialize`.
32
769
 
33
- * No changes.
770
+ *Melanie Gilman & Sean Griffin*
34
771
 
772
+ * MySQL enum type lookups, with values matching another type, no longer result
773
+ in an endless loop.
35
774
 
36
- ## Rails 3.2.15 (Oct 16, 2013) ##
775
+ Fixes #17402.
37
776
 
38
- * When calling the method .find_or_initialize_by_* from a collection_proxy
39
- it should set the inverse_of relation even when the entry was found on the db.
777
+ *Yves Senn*
40
778
 
41
- *arthurnn*
779
+ * Raise `ArgumentError` when the body of a scope is not callable.
42
780
 
43
- * Callbacks on has_many should access the in memory parent if a inverse_of is set.
781
+ *Mauro George*
44
782
 
45
- *arthurnn*
783
+ * Use type column first in multi-column indexes created with `add-reference`.
46
784
 
47
- * Fix `FinderMethods#last` unscoped primary key.
785
+ *Derek Prior*
48
786
 
49
- Fixes #11917.
787
+ * Fix `Relation.rewhere` to work with Range values.
50
788
 
51
- *Eugene Kalenkovich*
789
+ *Dan Olson*
52
790
 
53
- * Load fixtures from linked folders.
791
+ * `AR::UnknownAttributeError` now includes the class name of a record.
54
792
 
55
- *Kassio Borges*
793
+ User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
794
+ # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
56
795
 
57
- * When using optimistic locking, `update` was not passing the column to `quote_value`
58
- to allow the connection adapter to properly determine how to quote the value. This was
59
- affecting certain databases that use specific colmn types.
796
+ *Yuki Nishijima*
60
797
 
61
- Fixes: #6763
798
+ * Fix a regression causing `after_create` callbacks to run before associated
799
+ records are autosaved.
62
800
 
63
- *Alfred Wong*
801
+ Fixes #17209.
64
802
 
803
+ *Agis Anastasopoulos*
65
804
 
66
- ## Rails 3.2.14 (Jul 22, 2013) ##
805
+ * Honor overridden `rack.test` in Rack environment for the connection
806
+ management middleware.
67
807
 
68
- * Fix merge error when Equality LHS is non-attribute.
69
- Backport of #7380.
808
+ *Simon Eskildsen*
70
809
 
71
- *Karmes Alexander*
810
+ * Add a truncate method to the connection.
72
811
 
73
- * Do not re-create destroyed association when saving the parent object.
812
+ *Aaron Patterson*
74
813
 
75
- Fixes #11450.
814
+ * Don't autosave unchanged has_one through records.
76
815
 
77
- *Paul Nikitochkin*
816
+ *Alan Kennedy*, *Steve Parrington*
78
817
 
79
- * Do not shallow the original exception in `exec_cache` on PostgreSQL adapter.
818
+ * Do not dump foreign keys for ignored tables.
80
819
 
81
- Fixes #11260.
820
+ *Yves Senn*
82
821
 
83
- *Rafael Mendonça França*
822
+ * PostgreSQL adapter correctly dumps foreign keys targeting tables
823
+ outside the schema search path.
824
+
825
+ Fixes #16907.
826
+
827
+ *Matthew Draper*, *Yves Senn*
828
+
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.
834
+
835
+ *Chris Hanks*
836
+
837
+ * A `NullRelation` should represent nothing. This fixes a bug where
838
+ `Comment.where(post_id: Post.none)` returned a non-empty result.
839
+
840
+ Fixes #15176.
84
841
 
85
- * Fix `ActiveRecord::Store` incorrectly tracking changes of its attributes.
86
- Fixes #10373.
842
+ *Matthew Draper*, *Yves Senn*
87
843
 
88
- *Janko Marohnić*
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.
89
846
 
90
- * Fix a bug that prevented the use of the default STI inheritance column
91
- (ActiveRecord::Base.inheritance_column = 'some_column'.)
847
+ *Jeremy Kemper*
848
+
849
+ * MySQL: schema.rb now includes TEXT and BLOB column limits.
850
+
851
+ *Jeremy Kemper*
852
+
853
+ * MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
854
+
855
+ *Jeremy Kemper*
856
+
857
+ * SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
92
858
 
93
- *chapmajs + Takehiro Adachi*
859
+ *Girish Sonawane*
94
860
 
95
- * Fix mysql2 adapter raises the correct exception when executing a query on a
96
- closed connection.
861
+ * Introduce `connection.supports_views?` to check whether the current adapter
862
+ has support for SQL views. Connection adapters should define this method.
97
863
 
98
864
  *Yves Senn*
99
865
 
100
- * Fixes bug where `Company.new.contract_ids` would incorrectly load
101
- all non-associated contracts.
866
+ * Allow included modules to override association methods.
102
867
 
103
- Example:
868
+ Fixes #16684.
869
+
870
+ *Yves Senn*
871
+
872
+ * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
873
+ the database connection to the current environment.
104
874
 
105
- company = Company.new # Company has many :contracts
875
+ Fixes #16757.
106
876
 
107
- # before
108
- company.contract_ids # => SELECT ... WHERE `contracts`.`company_id` IS NULL
877
+ *Joshua Cody*, *Yves Senn*
109
878
 
110
- # after
111
- company.contract_ids # => []
879
+ * MySQL: set the connection collation along with the charset.
112
880
 
113
- *Jared Armstrong*
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.
114
885
 
115
- * Fix the `:primary_key` option for `has_many` associations.
116
- Fixes #10693.
886
+ This only applies to literal string comparisons, not column values, so it
887
+ is unlikely to affect you.
888
+
889
+ *Jeremy Kemper*
890
+
891
+ * `default_sequence_name` from the PostgreSQL adapter returns a `String`.
117
892
 
118
893
  *Yves Senn*
119
894
 
120
- * fixes bug introduced by #3329. Now, when autosaving associations,
121
- deletions happen before inserts and saves. This prevents a 'duplicate
122
- unique value' database error that would occur if a record being created had
123
- the same value on a unique indexed field as that of a record being destroyed.
895
+ * Fix a regression where whitespaces were stripped from DISTINCT queries in
896
+ PostgreSQL.
897
+
898
+ *Agis Anastasopoulos*
124
899
 
125
- Backport of #10417
900
+ Fixes #16623.
126
901
 
127
- *Johnny Holton*
902
+ * Fix has_many :through relation merging failing when dynamic conditions are
903
+ passed as a lambda with an arity of one.
128
904
 
129
- * Fix that under some conditions, Active Record could produce invalid SQL of the sort:
130
- "SELECT DISTINCT DISTINCT".
905
+ Fixes #16128.
131
906
 
132
- Backport of #6792.
907
+ *Agis Anastasopoulos*
133
908
 
134
- *Ben Woosley*
909
+ * Fix `Relation#exists?` to work with polymorphic associations.
135
910
 
136
- * Require `ActiveRecord::Base` in railtie hooks for rake_tasks, console and runner to
137
- avoid circular constant loading issues.
911
+ Fixes #15821.
138
912
 
139
- Backport #7695.
913
+ *Kassio Borges*
140
914
 
141
- Fixes #7683 and #882
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.
142
919
 
143
- *Ben Holley*
920
+ This commit adds an opt-in flag to enable not rescuing the errors.
144
921
 
145
- * Maintain context for joins within ActiveRecord::Relation merges.
146
- Backport #10164.
922
+ Example:
147
923
 
148
- *Neeraj Singh + Andrew Horner*
924
+ # Do not swallow errors in after_commit/after_rollback callbacks.
925
+ config.active_record.raise_in_transactional_callbacks = true
149
926
 
150
- * Make sure the `EXPLAIN` command is never triggered by a `select_db` call.
927
+ Fixes #13460.
151
928
 
152
- *Daniel Schierbeck*
929
+ *arthurnn*
153
930
 
154
- * Revert changes on `pluck` that was ignoring the select clause when the relation already
155
- has one. This caused a regression since it changed the behavior in a stable release.
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.
156
934
 
157
- Fixes #9777.
935
+ Fixes #16288.
158
936
 
159
- *Rafael Mendonça França*
937
+ *Godfrey Chan*
160
938
 
161
- * Confirm a record has not already been destroyed before decrementing counter cache.
939
+ * `*_was` and `changes` now work correctly for in-place attribute changes as
940
+ well.
162
941
 
163
- *Ben Tucker*
942
+ *Sean Griffin*
164
943
 
165
- * Default values for PostgreSQL bigint types now get parsed and dumped to the
166
- schema correctly.
167
- Backport #10098.
944
+ * Fix regression on `after_commit` that did not fire with nested transactions.
168
945
 
169
- *Erik Peterson*
946
+ Fixes #16425.
170
947
 
171
- * Removed warning when `auto_explain_threshold_in_seconds` is set and the
172
- connection adapter doesn't support explain.
173
- This is causing a regression since the Active Record Railtie is trying to
174
- connect to the development database in the application boot.
948
+ *arthurnn*
175
949
 
176
- *Rafael Mendonça França*
950
+ * Do not try to write timestamps when a table has no timestamps columns.
951
+
952
+ Fixes #8813.
953
+
954
+ *Sergey Potapov*
955
+
956
+ * `index_exists?` with `:name` option does verify specified columns.
957
+
958
+ Example:
959
+
960
+ add_index :articles, :title, name: "idx_title"
961
+
962
+ # Before:
963
+ index_exists? :articles, :title, name: "idx_title" # => `true`
964
+ index_exists? :articles, :body, name: "idx_title" # => `true`
965
+
966
+ # After:
967
+ index_exists? :articles, :title, name: "idx_title" # => `true`
968
+ index_exists? :articles, :body, name: "idx_title" # => `false`
177
969
 
178
- * Do not reset `inheritance_column` when it's set explicitly.
179
- Backport of #5327.
970
+ *Yves Senn*, *Matthew Draper*
180
971
 
181
- *kennyj + Fred Wu*
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`.
182
975
 
183
- * Fix a problem wrong exception is occured
184
- when raising no translatable exception in PostgreSQL.
976
+ *Sean Griffin*
185
977
 
186
- *kennyj*
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.
187
981
 
188
- * Resets the postgres search path in the structure.sql after the structure
189
- is dumped in order to find schema_migrations table when multiples schemas
190
- are used.
191
- Fixes #9796.
982
+ *Lachlan Sylvester*
192
983
 
193
- *Juan M. Cuello + Dembskiy Alexander*
984
+ * Define `id_was` to get the previous value of the primary key.
194
985
 
195
- * Reload the association target if it's stale. `@stale_state` should be nil
196
- when a model isn't saved.
197
- Fixes #7526.
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.
198
990
 
199
- *Larry Lv*
991
+ Fixes #16413.
200
992
 
201
- * Don't read CSV files during execution of `db:fixtures:load`. CSV support for
202
- fixtures was removed some time ago but the task was still loading them, even
203
- though later the code was looking for the related yaml file instead.
993
+ *Rafael Mendonça França*
204
994
 
205
- *kennyj*
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.
206
998
 
999
+ *Yves Senn*
207
1000
 
208
- ## Rails 3.2.13 (Mar 18, 2013) ##
1001
+ * Fix automatic maintaining test schema to properly handle sql structure
1002
+ schema format.
209
1003
 
210
- * Chaining multiple preloaded scopes will correctly preload all the scopes
211
- at the same time.
1004
+ Fixes #15394.
212
1005
 
213
- *Chris Geihsler*
1006
+ *Wojciech Wnętrzak*
214
1007
 
215
- * Reverted 921a296a3390192a71abeec6d9a035cc6d1865c8, 'Quote numeric values
216
- compared to string columns.' This caused several regressions.
1008
+ * Fix type casting to Decimal from Float with large precision.
217
1009
 
218
- *Steve Klabnik*
1010
+ *Tomohiro Hashidate*
219
1011
 
220
- * Fix overriding of attributes by `default_scope` on `ActiveRecord::Base#dup`.
1012
+ * Deprecate `Reflection#source_macro`
221
1013
 
222
- *Hiroshige UMINO*
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.
223
1017
 
224
- * Fix issue with overriding Active Record reader methods with a composed object
225
- and using that attribute as the scope of a `uniqueness_of` validation.
226
- Backport #7072.
1018
+ *Eileen M. Uchtitelle*, *Aaron Patterson*
227
1019
 
228
- *Peter Brown*
1020
+ * No verbose backtrace by `db:drop` when database does not exist.
229
1021
 
230
- * Sqlite now preserves custom primary keys when copying or altering tables.
231
- Fixes #9367.
232
- Backport #2312.
1022
+ Fixes #16295.
233
1023
 
234
- *Sean Scally + Yves Senn*
1024
+ *Kenn Ejima*
235
1025
 
236
- * Preloading `has_many :through` associations with conditions won't
237
- cache the `:through` association. This will prevent invalid
238
- subsets to be cached.
239
- Fixes #8423.
240
- Backport #9252.
1026
+ * Add support for PostgreSQL JSONB.
241
1027
 
242
1028
  Example:
243
1029
 
244
- class User
245
- has_many :posts
246
- has_many :recent_comments, -> { where('created_at > ?', 1.week.ago) }, :through => :posts
1030
+ create_table :posts do |t|
1031
+ t.jsonb :meta_data
247
1032
  end
248
1033
 
249
- a_user = User.includes(:recent_comments).first
1034
+ *Philippe Creux*, *Chris Teague*
250
1035
 
251
- # this is preloaded
252
- a_user.recent_comments
253
-
254
- # fetching the recent_comments through the posts association won't preload it.
255
- a_user.posts
1036
+ * `db:purge` with MySQL respects `Rails.env`.
256
1037
 
257
1038
  *Yves Senn*
258
1039
 
259
- * Fix handling of dirty time zone aware attributes
1040
+ * `change_column_default :table, :column, nil` with PostgreSQL will issue a
1041
+ `DROP DEFAULT` instead of a `DEFAULT NULL` query.
1042
+
1043
+ Fixes #16261.
260
1044
 
261
- Previously, when `time_zone_aware_attributes` were enabled, after
262
- changing a datetime or timestamp attribute and then changing it back
263
- to the original value, `changed_attributes` still tracked the
264
- attribute as changed. This caused `[attribute]_changed?` and
265
- `changed?` methods to return true incorrectly.
1045
+ *Matthew Draper*, *Yves Senn*
1046
+
1047
+ * Allow to specify a type for the foreign key column in `references`
1048
+ and `add_reference`.
266
1049
 
267
1050
  Example:
268
1051
 
269
- in_time_zone 'Paris' do
270
- order = Order.new
271
- original_time = Time.local(2012, 10, 10)
272
- order.shipped_at = original_time
273
- order.save
274
- order.changed? # => false
1052
+ change_table :vehicle do |t|
1053
+ t.references :station, type: :uuid
1054
+ end
1055
+
1056
+ *Andrey Novikov*, *Łukasz Sarnacki*
1057
+
1058
+ * `create_join_table` removes a common prefix when generating the join table.
1059
+ This matches the existing behavior of HABTM associations.
1060
+
1061
+ Fixes #13683.
1062
+
1063
+ *Stefan Kanev*
1064
+
1065
+ * Do not swallow errors on `compute_type` when having a bad `alias_method` on
1066
+ a class.
1067
+
1068
+ *arthurnn*
1069
+
1070
+ * PostgreSQL invalid `uuid` are convert to nil.
1071
+
1072
+ *Abdelkader Boudih*
1073
+
1074
+ * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
275
1075
 
276
- # changing value
277
- order.shipped_at = Time.local(2013, 1, 1)
278
- order.changed? # => true
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.
279
1078
 
280
- # reverting to original value
281
- order.shipped_at = original_time
282
- order.changed? # => false, used to return true
1079
+ Example:
1080
+
1081
+ class Post < ActiveRecord::Base
1082
+ serialize :comment, JSON
1083
+ end
1084
+
1085
+ class Comment
1086
+ include ActiveModel::Model
1087
+ attr_accessor :category, :text
283
1088
  end
284
1089
 
285
- Backport of #9073
286
- Fixes #8898
1090
+ post = Post.create!
1091
+ post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
1092
+ post.save!
1093
+
1094
+ # 4.0
1095
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1096
+
1097
+ # 4.1 before
1098
+ post.comment # => "#<Comment:0x007f80ab48ff98>"
1099
+
1100
+ # 4.1 after
1101
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1102
+
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.
1107
+
1108
+ To keep the previous behaviour, supply a custom coder instead
1109
+ ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
1110
+
1111
+ Fixes #15594.
1112
+
1113
+ *Jenn Cooper*
1114
+
1115
+ * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
1116
+
1117
+ Fixes #15931.
1118
+
1119
+ *Jeff Browning*
1120
+
1121
+ * Calling `#empty?` on a `has_many` association would use the value from the
1122
+ counter cache if one exists.
1123
+
1124
+ *David Verhasselt*
287
1125
 
288
- *Lilibeth De La Cruz*
1126
+ * Fix the schema dump generated for tables without constraints and with
1127
+ primary key with default value of custom PostgreSQL function result.
289
1128
 
290
- * Fix counter cache columns not updated when replacing `has_many :through`
291
- associations.
292
- Backport #8400.
293
- Fix #7630.
1129
+ Fixes #16111.
294
1130
 
295
- *Matthew Robertson*
1131
+ *Andrey Novikov*
296
1132
 
297
- * Don't update `column_defaults` when calling destructive methods on column with default value.
298
- Backport c517602.
299
- Fix #6115.
1133
+ * Fix the SQL generated when a `delete_all` is run on an association to not
1134
+ produce an `IN` statements.
300
1135
 
301
- *Piotr Sarnacki + Aleksey Magusev + Alan Daud*
1136
+ Before:
1137
+
1138
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1139
+ "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
1140
+
1141
+ After:
302
1142
 
303
- * When `#count` is used in conjunction with `#uniq` we perform `count(:distinct => true)`.
304
- Fix #6865.
1143
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1144
+ "categorizations"."category_id" = 1
1145
+
1146
+ *Eileen M. Uchitelle, Aaron Patterson*
1147
+
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.
305
1152
 
306
1153
  Example:
307
1154
 
308
- relation.uniq.count # => SELECT COUNT(DISTINCT *)
1155
+ App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
309
1156
 
310
- *Yves Senn + Kaspar Schiess*
1157
+ *Dylan Thacker-Smith*
311
1158
 
312
- * Fix `ActiveRecord::Relation#pluck` when columns or tables are reserved words.
313
- Backport #7536.
314
- Fix #8968.
1159
+ * Add a `:required` option to singular associations, providing a nicer
1160
+ API for presence validations on associations.
315
1161
 
316
- *Ian Lesperance + Yves Senn + Kaspar Schiess*
1162
+ *Sean Griffin*
317
1163
 
318
- * Don't run explain on slow queries for database adapters that don't support it.
319
- Backport #6197.
1164
+ * Fix an error in `reset_counters` when associations have `select` scope.
1165
+ (Call to `count` generated invalid SQL.)
320
1166
 
321
- *Blake Smith*
1167
+ *Cade Truitt*
322
1168
 
323
- * Revert round usec when comparing timestamp attributes in the dirty tracking.
324
- Fixes #8460.
1169
+ * After a successful `reload`, `new_record?` is always false.
325
1170
 
326
- *Andrew White*
1171
+ Fixes #12101.
327
1172
 
328
- * Revert creation of through association models when using `collection=[]`
329
- on a `has_many :through` association from an unsaved model.
330
- Fix #7661, #8269.
1173
+ *Matthew Draper*
331
1174
 
332
- *Ernie Miller*
1175
+ * PostgreSQL renaming table doesn't attempt to rename non existent sequences.
333
1176
 
334
- * Fix undefined method `to_i` when calling `new` on a scope that uses an
335
- Array; Fix FloatDomainError when setting integer column to NaN.
336
- Fixes #8718, #8734, #8757.
1177
+ *Abdelkader Boudih*
337
1178
 
338
- *Jason Stirk + Tristan Harward*
1179
+ * Move 'dependent: :destroy' handling for `belongs_to`
1180
+ from `before_destroy` to `after_destroy` callback chain
339
1181
 
340
- * Serialized attributes can be serialized in integer columns.
341
- Fix #8575.
1182
+ Fixes #12380.
342
1183
 
343
- *Rafael Mendonça França*
1184
+ *Ivan Antropov*
344
1185
 
345
- * Keep index names when using `alter_table` with sqlite3.
346
- Fix #3489.
347
- Backport #8522.
1186
+ * Detect in-place modifications on String attributes.
348
1187
 
349
- *Yves Senn*
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.
1191
+
1192
+ Before:
1193
+
1194
+ user = User.first
1195
+ user.name << ' Griffin'
1196
+ user.name_will_change!
1197
+ user.save
1198
+ user.reload.name # => "Sean Griffin"
1199
+
1200
+ After:
1201
+
1202
+ user = User.first
1203
+ user.name << ' Griffin'
1204
+ user.save
1205
+ user.reload.name # => "Sean Griffin"
1206
+
1207
+ *Sean Griffin*
1208
+
1209
+ * Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
1210
+ is invalid.
1211
+
1212
+ *Bogdan Gusiev*, *Marc Schütz*
1213
+
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.
1217
+
1218
+ Many thanks to *Matthew Higgins* for laying the foundation with his work on
1219
+ [foreigner](https://github.com/matthuhiggins/foreigner).
1220
+
1221
+ Example:
350
1222
 
351
- * Recognize migrations placed in directories containing numbers and 'rb'.
352
- Fix #8492.
353
- Backport of #8500.
1223
+ # within your migrations:
1224
+ add_foreign_key :articles, :authors
1225
+ remove_foreign_key :articles, :authors
354
1226
 
355
1227
  *Yves Senn*
356
1228
 
357
- * Add `ActiveRecord::Base.cache_timestamp_format` class attribute to control
358
- the format of the timestamp value in the cache key.
359
- This allows users to improve the precision of the cache key.
360
- Fixes #8195.
1229
+ * Fix subtle bugs regarding attribute assignment on models with no primary
1230
+ key. `'id'` will no longer be part of the attributes hash.
361
1231
 
362
- *Rafael Mendonça França*
1232
+ *Sean Griffin*
363
1233
 
364
- * Add `:nsec` date format. This can be used to improve the precision of cache key.
365
- Please note that this format only works with Ruby 1.9, Ruby 1.8 will ignore it completely.
1234
+ * Deprecate automatic counter caches on `has_many :through`. The behavior was
1235
+ broken and inconsistent.
366
1236
 
367
- *Jamie Gaskins*
1237
+ *Sean Griffin*
368
1238
 
369
- * Unscope `update_column(s)` query to ignore default scope.
1239
+ * `preload` preserves readonly flag for associations.
370
1240
 
371
- When applying `default_scope` to a class with a where clause, using
372
- `update_column(s)` could generate a query that would not properly update
373
- the record due to the where clause from the `default_scope` being applied
374
- to the update query.
1241
+ See #15853.
375
1242
 
376
- class User < ActiveRecord::Base
377
- default_scope where(active: true)
378
- end
1243
+ *Yves Senn*
379
1244
 
380
- user = User.first
381
- user.active = false
382
- user.save!
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.
1248
+
1249
+ Example:
1250
+
1251
+ model = Model.create!(number: 5)
1252
+ model.number = '5wibble'
1253
+ model.number_changed? # => true
1254
+
1255
+ Fixes #14731.
383
1256
 
384
- user.update_column(:active, true) # => false
1257
+ *Sean Griffin*
385
1258
 
386
- In this situation we want to skip the default_scope clause and just
387
- update the record based on the primary key. With this change:
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)`.
388
1262
 
389
- user.update_column(:active, true) # => true
1263
+ *Sean Griffin*
390
1264
 
391
- Backport of #8436 fix.
1265
+ * The object returned from `select_all` must respond to `column_types`.
1266
+ If this is not the case a `NoMethodError` is raised.
392
1267
 
393
- *Carlos Antonio da Silva*
1268
+ *Sean Griffin*
394
1269
 
395
- * Fix performance problem with primary_key method in PostgreSQL adapter when having many schemas.
396
- Uses pg_constraint table instead of pg_depend table which has many records in general.
397
- Fix #8414
1270
+ * Detect in-place modifications of PG array types
398
1271
 
399
- *kennyj*
1272
+ *Sean Griffin*
400
1273
 
401
- * Do not instantiate intermediate Active Record objects when eager loading.
402
- These records caused `after_find` to run more than expected.
403
- Fix #3313
404
- Backport of #8403
1274
+ * Add `bin/rake db:purge` task to empty the current database.
405
1275
 
406
1276
  *Yves Senn*
407
1277
 
408
- * Fix `pluck` to work with joins. Backport of #4942.
1278
+ * Deprecate `serialized_attributes` without replacement.
1279
+
1280
+ *Sean Griffin*
1281
+
1282
+ * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
1283
+ are part of the URI structure, not the actual host.
1284
+
1285
+ Fixes #15705.
1286
+
1287
+ *Andy Bakun*, *Aaron Stone*
1288
+
1289
+ * Ensure both parent IDs are set on join records when both sides of a
1290
+ through association are new.
1291
+
1292
+ *Sean Griffin*
1293
+
1294
+ * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
1295
+ Serialized attributes on ActiveRecord models will no longer save when
1296
+ unchanged.
1297
+
1298
+ Fixes #8328.
1299
+
1300
+ *Sean Griffin*
1301
+
1302
+ * `Pluck` now works when selecting columns from different tables with the same
1303
+ name.
1304
+
1305
+ Fixes #15649.
1306
+
1307
+ *Sean Griffin*
1308
+
1309
+ * Remove `cache_attributes` and friends. All attributes are cached.
1310
+
1311
+ *Sean Griffin*
1312
+
1313
+ * Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
1314
+
1315
+ *Akshay Vishnoi*
409
1316
 
410
- *Carlos Antonio da Silva*
1317
+ * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
1318
+ `Enumerable#find` does.
411
1319
 
412
- * Fix a problem with `translate_exception` method in a non English environment.
413
- Backport of #6397.
1320
+ Fixes #15382.
414
1321
 
415
- *kennyj*
1322
+ *James Yang*
416
1323
 
417
- * Fix dirty attribute checks for TimeZoneConversion with nil and blank
418
- datetime attributes. Setting a nil datetime to a blank string should not
419
- result in a change being flagged.
420
- Fixes #8310.
421
- Backport of #8311.
1324
+ * Make timezone aware attributes work with PostgreSQL array columns.
422
1325
 
423
- *Alisdair McDiarmid*
1326
+ Fixes #13402.
424
1327
 
425
- * Prevent mass assignment to the type column of polymorphic associations when using `build`.
426
- Fixes #8265.
427
- Backport of #8291.
1328
+ *Kuldeep Aggarwal*, *Sean Griffin*
1329
+
1330
+ * `ActiveRecord::SchemaMigration` has no primary key regardless of the
1331
+ `primary_key_prefix_type` configuration.
1332
+
1333
+ Fixes #15051.
1334
+
1335
+ *JoseLuis Torres*, *Yves Senn*
1336
+
1337
+ * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
1338
+
1339
+ Fixes #15538.
428
1340
 
429
1341
  *Yves Senn*
430
1342
 
431
- * When running migrations on Postgresql, the `:limit` option for `binary` and `text` columns is
432
- silently dropped.
433
- Previously, these migrations caused sql exceptions, because Postgresql doesn't support limits
434
- on these types.
1343
+ * Baseclass becomes! subclass.
435
1344
 
436
- *Victor Costan*
1345
+ Before this change, a record which changed its STI type, could not be
1346
+ updated.
437
1347
 
438
- * `#pluck` can be used on a relation with `select` clause.
439
- Fixes #7551.
440
- Backport of #8176.
1348
+ Fixes #14785.
441
1349
 
442
- Example:
1350
+ *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
1351
+
1352
+ * Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
1353
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
1354
+
1355
+ *Akshay Vishnoi*
443
1356
 
444
- Topic.select([:approved, :id]).order(:id).pluck(:id)
1357
+ * Fix regression on eager loading association based on SQL query rather than
1358
+ existing column.
1359
+
1360
+ Fixes #15480.
1361
+
1362
+ *Lauro Caetano*, *Carlos Antonio da Silva*
1363
+
1364
+ * Deprecate returning `nil` from `column_for_attribute` when no column exists.
1365
+ It will return a null object in Rails 5.0
1366
+
1367
+ *Sean Griffin*
1368
+
1369
+ * Implemented `ActiveRecord::Base#pretty_print` to work with PP.
1370
+
1371
+ *Ethan*
1372
+
1373
+ * Preserve type when dumping PostgreSQL point, bit, bit varying and money
1374
+ columns.
445
1375
 
446
1376
  *Yves Senn*
447
1377
 
448
- * Use `nil?` instead of `blank?` to check whether dynamic finder with a bang
449
- should raise RecordNotFound.
450
- Fixes #7238.
1378
+ * New records remain new after YAML serialization.
1379
+
1380
+ *Sean Griffin*
451
1381
 
452
- *Nikita Afanasenko*
1382
+ * PostgreSQL support default values for enum types. Fixes #7814.
453
1383
 
454
- * Fix deleting from a HABTM join table upon destroying an object of a model
455
- with optimistic locking enabled.
456
- Fixes #5332.
1384
+ *Yves Senn*
457
1385
 
458
- *Nick Rogers*
1386
+ * PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
459
1387
 
460
- * Use query cache/uncache when using ENV["DATABASE_URL"].
461
- Fixes #6951.
462
- Backport of #8074.
1388
+ *Yves Senn*
463
1389
 
464
- *kennyj*
1390
+ * Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
1391
+ with orders without sort direction modifiers.
465
1392
 
466
- * Do not create useless database transaction when building `has_one` association.
1393
+ *Nikolay Kondratyev*
467
1394
 
468
- Example:
1395
+ * PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
469
1396
 
470
- User.has_one :profile
471
- User.new.build_profile
1397
+ *Yves Senn*
472
1398
 
473
- Backport of #8154.
1399
+ * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
1400
+ Fixes duplication in combination with `store_accessor`.
474
1401
 
475
- *Bogdan Gusiev*
1402
+ Fixes #15369.
476
1403
 
477
- * `AR::Base#attributes_before_type_cast` now returns unserialized values for serialized attributes.
1404
+ *Yves Senn*
478
1405
 
479
- *Nikita Afanasenko*
1406
+ * `rake railties:install:migrations` respects the order of railties.
480
1407
 
481
- * Fix issue that raises `NameError` when overriding the `accepts_nested_attributes` in child classes.
1408
+ *Arun Agrawal*
482
1409
 
483
- Before:
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.
484
1413
 
485
- class Shared::Person < ActiveRecord::Base
486
- has_one :address
1414
+ Fixes #14983.
487
1415
 
488
- accepts_nested_attributes :address, :reject_if => :all_blank
489
- end
1416
+ *arthurnn*
490
1417
 
491
- class Person < Shared::Person
492
- accepts_nested_attributes :address
493
- end
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.
494
1421
 
495
- Person
496
- #=> NameError: method `address_attributes=' not defined in Person
1422
+ Fixes #14682.
497
1423
 
498
- After:
1424
+ *arthurnn*
499
1425
 
500
- Person
501
- #=> Person(id: integer, ...)
1426
+ * Fix serialization for records with an attribute named `format`.
502
1427
 
503
- Fixes #8131.
1428
+ Fixes #15188.
504
1429
 
505
- *Gabriel Sobrinho, Ricardo Henrique*
1430
+ *Godfrey Chan*
506
1431
 
1432
+ * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
1433
+ on a NullRelation should return a Hash.
507
1434
 
508
- ## Rails 3.2.12 (Feb 11, 2013) ##
1435
+ *Kuldeep Aggarwal*
509
1436
 
510
- * Quote numeric values being compared to non-numeric columns. Otherwise,
511
- in some database, the string column values will be coerced to a numeric
512
- allowing 0, 0.0 or false to match any string starting with a non-digit.
1437
+ * Fix serialized fields returning serialized data after being updated with
1438
+ `update_column`.
513
1439
 
514
- Example:
1440
+ *Simon Hørup Eskildsen*
515
1441
 
516
- App.where(apikey: 0) # => SELECT * FROM users WHERE apikey = '0'
1442
+ * Fix polymorphic eager loading when using a String as foreign key.
517
1443
 
518
- *Dylan Smith*
1444
+ Fixes #14734.
519
1445
 
1446
+ *Lauro Caetano*
520
1447
 
521
- ## Rails 3.2.11 (Jan 8, 2013) ##
1448
+ * Change belongs_to touch to be consistent with timestamp updates
522
1449
 
523
- * Fix querying with an empty hash *Damien Mathieu* [CVE-2013-0155]
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.
524
1453
 
1454
+ *Brock Trappitt*
525
1455
 
526
- ## Rails 3.2.10 (Jan 2, 2013) ##
1456
+ * Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
1457
+ table inside a schema.
527
1458
 
528
- * CVE-2012-5664 options hashes should only be extracted if there are extra
529
- parameters
1459
+ Fixes #14824.
530
1460
 
1461
+ *Eric Chahin*
531
1462
 
532
- ## Rails 3.2.9 (Nov 12, 2012) ##
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.
533
1466
 
534
- * Fix `find_in_batches` crashing when IDs are strings and start option is not specified.
1467
+ *Sean Griffin*
535
1468
 
536
- *Alexis Bernard*
1469
+ * Fix bug that added `table_name_prefix` and `table_name_suffix` to
1470
+ extension names in PostgreSQL when migrating.
537
1471
 
538
- * Fix issue with collection associations calling first(n)/last(n) and attempting
539
- to set the inverse association when `:inverse_of` was used. Fixes #8087.
1472
+ *Joao Carlos*
540
1473
 
541
- *Carlos Antonio da Silva*
1474
+ * The `:index` option in migrations, which previously was only available for
1475
+ `references`, now works with any column types.
542
1476
 
543
- * Fix bug when Column is trying to type cast boolean values to integer.
544
- Fixes #8067.
1477
+ *Marc Schütz*
545
1478
 
546
- *Rafael Mendonça França*
1479
+ * Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
547
1480
 
548
- * Fix bug where `rake db:test:prepare` tries to load the structure.sql into development database.
549
- Fixes #8032.
1481
+ *jnormore*
550
1482
 
551
- *Grace Liu + Rafael Mendonça França*
1483
+ * Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
1484
+ or `offset`.
552
1485
 
553
- * Fixed support for `DATABASE_URL` environment variable for rake db tasks. *Grace Liu*
1486
+ In these cases the generated query ignored them and that caused unintended
1487
+ records to be deleted.
554
1488
 
555
- * Fix bug where `update_columns` and `update_column` would not let you update the primary key column.
1489
+ Fixes #11985.
556
1490
 
557
- *Henrik Nyh*
1491
+ *Leandro Facchinetti*
1492
+
1493
+ * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
1494
+ their limit dropped from the schema.
558
1495
 
559
- * Decode URI encoded attributes on database connection URLs.
1496
+ Fixes #14135.
560
1497
 
561
- *Shawn Veader*
1498
+ *Aaron Nelson*
562
1499
 
563
- * Fix AR#dup to nullify the validation errors in the dup'ed object. Previously the original
564
- and the dup'ed object shared the same errors.
1500
+ * Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
1501
+ association.
565
1502
 
566
- *Christian Seiler*
1503
+ Fixes #14709.
567
1504
 
568
- * Synchronize around deleting from the reserved connections hash.
569
- Fixes #7955
1505
+ *Kassio Borges*
1506
+
1507
+ * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
1508
+ strings in column names as equal.
1509
+
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.
1513
+
1514
+ *Nat Budin*
570
1515
 
571
- * PostgreSQL adapter correctly fetches default values when using
572
- multiple schemas and domains in a db. Fixes #7914
1516
+ * Fix `stored_attributes` to correctly merge the details of stored
1517
+ attributes defined in parent classes.
573
1518
 
574
- *Arturo Pie*
1519
+ Fixes #14672.
575
1520
 
576
- * Fix deprecation notice when loading a collection association that
577
- selects columns from other tables, if a new record was previously
578
- built using that association.
1521
+ *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
579
1522
 
580
- *Ernie Miller*
1523
+ * `change_column_default` allows `[]` as argument to `change_column_default`.
581
1524
 
582
- * The postgres adapter now supports tables with capital letters.
583
- Fix #5920
1525
+ Fixes #11586.
584
1526
 
585
1527
  *Yves Senn*
586
1528
 
587
- * `CollectionAssociation#count` returns `0` without querying if the
588
- parent record is not persisted.
1529
+ * Handle `name` and `"char"` column types in the PostgreSQL adapter.
1530
+
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.
1535
+
1536
+ *J Smith*, *Yves Senn*
1537
+
1538
+ * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
1539
+ NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
589
1540
 
590
1541
  Before:
591
1542
 
592
- person.pets.count
593
- # SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" IS NULL
594
- # => 0
1543
+ Point.create(value: 1.0/0)
1544
+ Point.last.value # => 0.0
595
1545
 
596
1546
  After:
597
1547
 
598
- person.pets.count
599
- # fires without sql query
600
- # => 0
1548
+ Point.create(value: 1.0/0)
1549
+ Point.last.value # => Infinity
1550
+
1551
+ *Innokenty Mikhailov*
1552
+
1553
+ * Allow the PostgreSQL adapter to handle bigserial primary key types again.
1554
+
1555
+ Fixes #10410.
1556
+
1557
+ *Patrick Robertson*
1558
+
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.
1563
+
1564
+ Fixes #15024.
1565
+
1566
+ *Yves Senn*
1567
+
1568
+ * Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
601
1569
 
602
- *Francesco Rodriguez*
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.
603
1572
 
604
- * Fix `reset_counters` crashing on `has_many :through` associations.
605
- Fix #7822.
1573
+ Fixes #14913, #14914.
606
1574
 
607
- *lulalala*
1575
+ *Fred Wu*
608
1576
 
609
- * ConnectionPool recognizes checkout_timeout spec key as taking
610
- precedence over legacy wait_timeout spec key, can be used to avoid
611
- conflict with mysql2 use of wait_timeout. Closes #7684.
1577
+ * Return a non zero status when running `rake db:migrate:status` and migration table does
1578
+ not exist.
612
1579
 
613
- *jrochkind*
1580
+ *Paul B.*
614
1581
 
615
- * Rename field_changed? to _field_changed? so that users can create a field named field
1582
+ * Add support for module-level `table_name_suffix` in models.
616
1583
 
617
- *Akira Matsuda*, backported by *Steve Klabnik*
1584
+ This makes `table_name_suffix` work the same way as `table_name_prefix` when
1585
+ using namespaced models.
618
1586
 
619
- * Fix creation of through association models when using `collection=[]`
620
- on a `has_many :through` association from an unsaved model.
621
- Fix #7661.
1587
+ *Jenner LaFave*
622
1588
 
623
- *Ernie Miller*
1589
+ * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
624
1590
 
625
- * Explain only normal CRUD sql (select / update / insert / delete).
626
- Fix problem that explains unexplainable sql. Closes #7544 #6458.
1591
+ In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
1592
+ In 4.0 series it is delegated to `Array#join`.
627
1593
 
628
- *kennyj*
1594
+ *Bogdan Gusiev*
1595
+
1596
+ * Log nil binary column values correctly.
1597
+
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.
1605
+
1606
+ *James Coleman*
1607
+
1608
+ * Rails will now pass a custom validation context through to autosave associations
1609
+ in order to validate child associations with the same context.
1610
+
1611
+ Fixes #13854.
1612
+
1613
+ *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
1614
+
1615
+ * Stringify all variables keys of MySQL connection configuration.
629
1616
 
630
- * Backport test coverage to ensure that PostgreSQL auto-reconnect functionality
631
- remains healthy.
1617
+ When `sql_mode` variable for MySQL adapters set in configuration as `String`
1618
+ was ignored and overwritten by strict mode option.
632
1619
 
633
- *Steve Jorgensen*
1620
+ Fixes #14895.
634
1621
 
635
- * Use config['encoding'] instead of config['charset'] when executing
636
- databases.rake in the mysql/mysql2. A correct option for a database.yml
637
- is 'encoding'.
1622
+ *Paul Nikitochkin*
1623
+
1624
+ * Ensure SQLite3 statements are closed on errors.
1625
+
1626
+ Fixes #13631.
1627
+
1628
+ *Timur Alperovich*
638
1629
 
639
- *kennyj*
1630
+ * Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
640
1631
 
641
- * Fix ConnectionAdapters::Column.type_cast_code integer conversion,
642
- to always convert values to integer calling #to_i. Fixes #7509.
1632
+ *Hector Satre*
643
1633
 
644
- *Thiago Pradi*
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.
645
1637
 
646
- * Fix time column type casting for invalid time string values to correctly return nil.
1638
+ Fixes #14845.
647
1639
 
648
- *Adam Meehan*
1640
+ *Kassio Borges*
649
1641
 
650
- * Fix `becomes` when using a configured `inheritance_column`.
1642
+ * Reset the cache when modifying a Relation with cached Arel.
1643
+ Additionally display a warning message to make the user aware.
651
1644
 
652
1645
  *Yves Senn*
653
1646
 
654
- * Fix `reset_counters` when there are multiple `belongs_to` association with the
655
- same foreign key and one of them have a counter cache.
656
- Fixes #5200.
1647
+ * PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
1648
+ different spellings of timestamps are treated the same.
657
1649
 
658
- *Dave Desrochers*
1650
+ Example:
659
1651
 
660
- * Round usec when comparing timestamp attributes in the dirty tracking.
661
- Fixes #6975.
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)
662
1656
 
663
- *kennyj*
1657
+ See #14513.
664
1658
 
665
- * Use inversed parent for first and last child of has_many association.
1659
+ *Jefferson Lai*
666
1660
 
667
- *Ravil Bayramgalin*
1661
+ * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
668
1662
 
669
- * Fix Column.microseconds and Column.fast_string_to_date to avoid converting
670
- timestamp seconds to a float, since it occasionally results in inaccuracies
671
- with microsecond-precision times. Fixes #7352.
1663
+ Fixes #14841.
672
1664
 
673
- *Ari Pollak*
1665
+ *Lucas Mazza*
674
1666
 
675
- * Fix `increment!`, `decrement!`, `toggle!` that was skipping callbacks.
676
- Fixes #7306.
1667
+ * Fix name collision with `Array#select!` with `Relation#select!`.
677
1668
 
678
- *Rafael Mendonça França*
1669
+ Fixes #14752.
679
1670
 
680
- * Fix AR#create to return an unsaved record when AR::RecordInvalid is
681
- raised. Fixes #3217.
1671
+ *Earl St Sauver*
682
1672
 
683
- *Dave Yeu*
1673
+ * Fix unexpected behavior for `has_many :through` associations going through
1674
+ a scoped `has_many`.
684
1675
 
685
- * Remove unnecessary transaction when assigning has_one associations with a nil or equal value.
686
- Fix #7191.
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.
687
1679
 
688
- *kennyj*
1680
+ Fixes #14537.
689
1681
 
690
- * Allow store to work with an empty column.
691
- Fix #4840.
1682
+ *Jan Habermann*
692
1683
 
693
- *Jeremy Walker*
1684
+ * `@destroyed` should always be set to `false` when an object is duped.
694
1685
 
695
- * Remove prepared statement from system query in postgresql adapter.
696
- Fix #5872.
1686
+ *Kuldeep Aggarwal*
697
1687
 
698
- *Ivan Evtuhovich*
1688
+ * Enable `has_many` associations to support irregular inflections.
699
1689
 
700
- * Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load`
701
- Fixes #4772.
1690
+ Fixes #8928.
702
1691
 
703
- *Seamus Abshere*
1692
+ *arthurnn*, *Javier Goizueta*
704
1693
 
1694
+ * Fix `count` used with a grouping not returning a Hash.
705
1695
 
706
- ## Rails 3.2.8 (Aug 9, 2012) ##
1696
+ Fixes #14721.
707
1697
 
708
- * Do not consider the numeric attribute as changed if the old value is zero and the new value
709
- is not a string.
710
- Fixes #7237.
1698
+ *Eric Chahin*
711
1699
 
712
- *Rafael Mendonça França*
1700
+ * `sanitize_sql_like` helper method to escape a string for safe use in an SQL
1701
+ LIKE statement.
713
1702
 
714
- * Removes the deprecation of `update_attribute`. *fxn*
1703
+ Example:
715
1704
 
716
- * Reverted the deprecation of `composed_of`. *Rafael Mendonça França*
1705
+ class Article
1706
+ def self.search(term)
1707
+ where("title LIKE ?", sanitize_sql_like(term))
1708
+ end
1709
+ end
717
1710
 
718
- * Reverted the deprecation of `*_sql` association options. They will
719
- be deprecated in 4.0 instead. *Jon Leighton*
1711
+ Article.search("20% _reduction_")
1712
+ # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
720
1713
 
721
- * Do not eager load AR session store. ActiveRecord::SessionStore depends on the abstract store
722
- in Action Pack. Eager loading this class would break client code that eager loads Active Record
723
- standalone.
724
- Fixes #7160
1714
+ *Rob Gilson*, *Yves Senn*
725
1715
 
726
- *Xavier Noria*
1716
+ * Do not quote uuid default value on `change_column`.
727
1717
 
728
- * Do not set RAILS_ENV to "development" when using `db:test:prepare` and related rake tasks.
729
- This was causing the truncation of the development database data when using RSpec.
730
- Fixes #7175.
1718
+ Fixes #14604.
731
1719
 
732
- *Rafael Mendonça França*
1720
+ *Eric Chahin*
733
1721
 
734
- ## Rails 3.2.7 (Jul 26, 2012) ##
1722
+ * The comparison between `Relation` and `CollectionProxy` should be consistent.
735
1723
 
736
- * `:finder_sql` and `:counter_sql` options on collection associations
737
- are deprecated. Please transition to using scopes.
1724
+ Example:
738
1725
 
739
- *Jon Leighton*
1726
+ author.posts == Post.where(author_id: author.id)
1727
+ # => true
1728
+ Post.where(author_id: author.id) == author.posts
1729
+ # => true
740
1730
 
741
- * `:insert_sql` and `:delete_sql` options on `has_and_belongs_to_many`
742
- associations are deprecated. Please transition to using `has_many
743
- :through`
1731
+ Fixes #13506.
744
1732
 
745
- *Jon Leighton*
1733
+ *Lauro Caetano*
746
1734
 
747
- * `composed_of` has been deprecated. You'll have to write your own accessor
748
- and mutator methods if you'd like to use value objects to represent some
749
- portion of your models.
1735
+ * Calling `delete_all` on an unloaded `CollectionProxy` no longer
1736
+ generates an SQL statement containing each id of the collection:
750
1737
 
751
- *Steve Klabnik*
1738
+ Before:
752
1739
 
753
- * `update_attribute` has been deprecated. Use `update_column` if
754
- you want to bypass mass-assignment protection, validations, callbacks,
755
- and touching of updated_at. Otherwise please use `update_attributes`.
1740
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1741
+ AND `model`.`id` IN (1, 2, 3...)
756
1742
 
757
- *Steve Klabnik*
1743
+ After:
758
1744
 
759
- ## Rails 3.2.6 (Jun 12, 2012) ##
1745
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
760
1746
 
761
- * protect against the nesting of hashes changing the
762
- table context in the next call to build_from_hash. This fix
763
- covers this case as well.
1747
+ *Eileen M. Uchitelle*, *Aaron Patterson*
764
1748
 
765
- CVE-2012-2695
1749
+ * Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
1750
+ with `select`.
766
1751
 
767
- * Revert earlier 'perf fix' (see 3.2.4 changelog / GH #6289). This
768
- change introduced a regression (GH #6609). assoc.clear and
769
- assoc.delete_all have loaded the association before doing the delete
770
- since at least Rails 2.3. Doing the delete without loading the
771
- records means that the `before_remove` and `after_remove` callbacks do
772
- not get invoked. Therefore, this change was less a fix a more an
773
- optimisation, which should only have gone into master.
1752
+ Fixes #13648.
774
1753
 
775
- *Jon Leighton*
1754
+ *Simon Woker*
776
1755
 
777
- ## Rails 3.2.5 (Jun 1, 2012) ##
1756
+ * PostgreSQL adapter only warns once for every missing OID per connection.
778
1757
 
779
- * Restore behavior of Active Record 3.2.3 scopes.
780
- A series of commits relating to preloading and scopes caused a regression.
1758
+ Fixes #14275.
781
1759
 
782
- *Andrew White*
1760
+ *Matthew Draper*, *Yves Senn*
783
1761
 
1762
+ * PostgreSQL adapter automatically reloads it's type map when encountering
1763
+ unknown OIDs.
784
1764
 
785
- ## Rails 3.2.4 (May 31, 2012) ##
1765
+ Fixes #14678.
786
1766
 
787
- * Perf fix: Don't load the records when doing assoc.delete_all.
788
- GH #6289. *Jon Leighton*
1767
+ *Matthew Draper*, *Yves Senn*
789
1768
 
790
- * Association preloading shouldn't be affected by the current scoping.
791
- This could cause infinite recursion and potentially other problems.
792
- See GH #5667. *Jon Leighton*
1769
+ * Fix insertion of records via `has_many :through` association with scope.
793
1770
 
794
- * Datetime attributes are forced to be changed. GH #3965
1771
+ Fixes #3548.
795
1772
 
796
- * Fix attribute casting. GH #5549
1773
+ *Ivan Antropov*
797
1774
 
798
- * Fix #5667. Preloading should ignore scoping.
1775
+ * Auto-generate stable fixture UUIDs on PostgreSQL.
799
1776
 
800
- * Predicate builder should not recurse for determining where columns.
801
- Thanks to Ben Murphy for reporting this! CVE-2012-2661
1777
+ Fixes #11524.
802
1778
 
1779
+ *Roderick van Domburg*
803
1780
 
804
- ## Rails 3.2.3 (March 30, 2012) ##
1781
+ * Fix a problem where an enum would overwrite values of another enum with the
1782
+ same name in an unrelated class.
805
1783
 
806
- * Added find_or_create_by_{attribute}! dynamic method. *Andrew White*
1784
+ Fixes #14607.
807
1785
 
808
- * Whitelist all attribute assignment by default. Change the default for newly generated applications to whitelist all attribute assignment. Also update the generated model classes so users are reminded of the importance of attr_accessible. *NZKoz*
1786
+ *Evan Whalen*
809
1787
 
810
- * Update ActiveRecord::AttributeMethods#attribute_present? to return false for empty strings. *Jacobkg*
1788
+ * PostgreSQL and SQLite string columns no longer have a default limit of 255.
811
1789
 
812
- * Fix associations when using per class databases. *larskanis*
1790
+ Fixes #13435, #9153.
813
1791
 
814
- * Revert setting NOT NULL constraints in add_timestamps *fxn*
1792
+ *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
815
1793
 
816
- * Fix mysql to use proper text types. Fixes #3931. *kennyj*
1794
+ * Make possible to have an association called `records`.
817
1795
 
818
- * Fix #5069 - Protect foreign key from mass assignment through association builder. *byroot*
1796
+ Fixes #11645.
819
1797
 
1798
+ *prathamesh-sonpatki*
820
1799
 
821
- ## Rails 3.2.2 (March 1, 2012) ##
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.
822
1804
 
823
- * No changes.
1805
+ Fixes #14003.
824
1806
 
1807
+ *Jefferson Lai*
825
1808
 
826
- ## Rails 3.2.1 (January 26, 2012) ##
1809
+ * Block a few default Class methods as scope name.
827
1810
 
828
- * The threshold for auto EXPLAIN is ignored if there's no logger. *fxn*
1811
+ For instance, this will raise:
829
1812
 
830
- * Call `to_s` on the value passed to `table_name=`, in particular symbols
831
- are supported (regression). *Sergey Nartimov*
1813
+ scope :public, -> { where(status: 1) }
832
1814
 
833
- * Fix possible race condition when two threads try to define attribute
834
- methods for the same class. *Jon Leighton*
1815
+ *arthurnn*
835
1816
 
1817
+ * Fix error when using `with_options` with lambda.
836
1818
 
837
- ## Rails 3.2.0 (January 20, 2012) ##
1819
+ Fixes #9805.
838
1820
 
839
- * Added a `with_lock` method to ActiveRecord objects, which starts
840
- a transaction, locks the object (pessimistically) and yields to the block.
841
- The method takes one (optional) parameter and passes it to `lock!`.
1821
+ *Lauro Caetano*
842
1822
 
843
- Before:
1823
+ * Switch `sqlite3:///` URLs (which were temporarily
1824
+ deprecated in 4.1) from relative to absolute.
844
1825
 
845
- class Order < ActiveRecord::Base
846
- def cancel!
847
- transaction do
848
- lock!
849
- # ... cancelling logic
850
- end
851
- end
852
- end
1826
+ If you still want the previous interpretation, you should replace
1827
+ `sqlite3:///my/path` with `sqlite3:my/path`.
853
1828
 
854
- After:
1829
+ *Matthew Draper*
855
1830
 
856
- class Order < ActiveRecord::Base
857
- def cancel!
858
- with_lock do
859
- # ... cancelling logic
860
- end
861
- end
1831
+ * Treat blank UUID values as `nil`.
1832
+
1833
+ Example:
1834
+
1835
+ Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
1836
+
1837
+ *Dmitry Lavrov*
1838
+
1839
+ * Enable support for materialized views on PostgreSQL >= 9.3.
1840
+
1841
+ *Dave Lee*
1842
+
1843
+ * The PostgreSQL adapter supports custom domains. Fixes #14305.
1844
+
1845
+ *Yves Senn*
1846
+
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`.
1850
+
1851
+ See #7814.
1852
+
1853
+ *Yves Senn*
1854
+
1855
+ * Fix error when specifying a non-empty default value on a PostgreSQL array
1856
+ column.
1857
+
1858
+ Fixes #10613.
1859
+
1860
+ *Luke Steensen*
1861
+
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.
1864
+
1865
+ Fixes #14393.
1866
+
1867
+ *Chris Finne*
1868
+
1869
+ * Introduce `validate` as an alias for `valid?`.
1870
+
1871
+ This is more intuitive when you want to run validations but don't care about the return value.
1872
+
1873
+ *Henrik Nyh*
1874
+
1875
+ * Create indexes inline in CREATE TABLE for MySQL.
1876
+
1877
+ This is important, because adding an index on a temporary table after it has been created
1878
+ would commit the transaction.
1879
+
1880
+ It also allows creating and dropping indexed tables with fewer queries and fewer permissions
1881
+ required.
1882
+
1883
+ Example:
1884
+
1885
+ create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
1886
+ t.index :zip
862
1887
  end
1888
+ # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
863
1889
 
864
- *Olek Janiszewski*
1890
+ *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
865
1891
 
866
- * 'on' and 'ON' boolean columns values are type casted to true
867
- *Santiago Pastorino*
1892
+ * Use singular table name in generated migrations when
1893
+ `ActiveRecord::Base.pluralize_table_names` is `false`.
868
1894
 
869
- * Added ability to run migrations only for given scope, which allows
870
- to run migrations only from one engine (for example to revert changes
871
- from engine that you want to remove).
1895
+ Fixes #13426.
1896
+
1897
+ *Kuldeep Aggarwal*
1898
+
1899
+ * `touch` accepts many attributes to be touched at once.
872
1900
 
873
1901
  Example:
874
- rake db:migrate SCOPE=blog
875
1902
 
876
- *Piotr Sarnacki*
1903
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
1904
+ Photo.last.touch(:signed_at, :sealed_at)
877
1905
 
878
- * Migrations copied from engines are now scoped with engine's name,
879
- for example 01_create_posts.blog.rb. *Piotr Sarnacki*
1906
+ *James Pinto*
880
1907
 
881
- * Implements `AR::Base.silence_auto_explain`. This method allows the user to
882
- selectively disable automatic EXPLAINs within a block. *fxn*
1908
+ * `rake db:structure:dump` only dumps schema information if the schema
1909
+ migration table exists.
883
1910
 
884
- * Implements automatic EXPLAIN logging for slow queries.
1911
+ Fixes #14217.
885
1912
 
886
- A new configuration parameter `config.active_record.auto_explain_threshold_in_seconds`
887
- determines what's to be considered a slow query. Setting that to `nil` disables
888
- this feature. Defaults are 0.5 in development mode, and `nil` in test and production
889
- modes.
1913
+ *Yves Senn*
890
1914
 
891
- As of this writing there's support for SQLite, MySQL (mysql2 adapter), and
892
- PostgreSQL.
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.
893
1920
 
894
- *fxn*
1921
+ *Matthew Draper*
895
1922
 
896
- * Implemented ActiveRecord::Relation#pluck method
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.
897
1925
 
898
- Method returns Array of column value from table under ActiveRecord model
1926
+ *Josh Williams*
899
1927
 
900
- Client.pluck(:id)
1928
+ * `where.not` adds `references` for `includes` like normal `where` calls do.
901
1929
 
902
- *Bogdan Gusiev*
1930
+ Fixes #14406.
903
1931
 
904
- * Automatic closure of connections in threads is deprecated. For example
905
- the following code is deprecated:
1932
+ *Yves Senn*
906
1933
 
907
- Thread.new { Post.find(1) }.join
1934
+ * Extend fixture `$LABEL` replacement to allow string interpolation.
908
1935
 
909
- It should be changed to close the database connection at the end of
910
- the thread:
1936
+ Example:
911
1937
 
912
- Thread.new {
913
- Post.find(1)
914
- Post.connection.close
915
- }.join
1938
+ martin:
1939
+ email: $LABEL@email.com
916
1940
 
917
- Only people who spawn threads in their application code need to worry
918
- about this change.
1941
+ users(:martin).email # => martin@email.com
919
1942
 
920
- * Deprecated:
1943
+ *Eric Steele*
921
1944
 
922
- * `set_table_name`
923
- * `set_inheritance_column`
924
- * `set_sequence_name`
925
- * `set_primary_key`
926
- * `set_locking_column`
1945
+ * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
927
1946
 
928
- Use an assignment method instead. For example, instead of `set_table_name`, use `self.table_name=`:
1947
+ Fixes #14361.
929
1948
 
930
- class Project < ActiveRecord::Base
931
- self.table_name = "project"
932
- end
1949
+ *arthurnn*
933
1950
 
934
- Or define your own `self.table_name` method:
1951
+ * Passing an Active Record object to `find` or `exists?` is now deprecated.
1952
+ Call `.id` on the object first.
935
1953
 
936
- class Post < ActiveRecord::Base
937
- def self.table_name
938
- "special_" + super
939
- end
940
- end
941
- Post.table_name # => "special_posts"
1954
+ *Aaron Patterson*
942
1955
 
943
- *Jon Leighton*
1956
+ * Only use BINARY for MySQL case sensitive uniqueness check when column
1957
+ has a case insensitive collation.
944
1958
 
945
- * Generated association methods are created within a separate module to allow overriding and
946
- composition using `super`. For a class named `MyModel`, the module is named
947
- `MyModel::GeneratedFeatureMethods`. It is included into the model class immediately after
948
- the `generated_attributes_methods` module defined in ActiveModel, so association methods
949
- override attribute methods of the same name. *Josh Susser*
1959
+ *Ryuta Kamizono*
950
1960
 
951
- * Implemented ActiveRecord::Relation#explain. *fxn*
1961
+ * Support for MySQL 5.6 fractional seconds.
952
1962
 
953
- * Add ActiveRecord::Relation#uniq for generating unique queries.
1963
+ *arthurnn*, *Tatsuhiko Miyagawa*
954
1964
 
955
- Before:
1965
+ * Support for PostgreSQL `citext` data type enabling case-insensitive
1966
+ `where` values without needing to wrap in UPPER/LOWER sql functions.
956
1967
 
957
- Client.select('DISTINCT name')
1968
+ *Troy Kruthoff*, *Lachlan Sylvester*
958
1969
 
959
- After:
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.
960
1973
 
961
- Client.select(:name).uniq
1974
+ *Alan Kennedy*
962
1975
 
963
- This also allows you to revert the unqueness in a relation:
1976
+ * Allow strings to specify the `#order` value.
964
1977
 
965
- Client.select(:name).uniq.uniq(false)
1978
+ Example:
966
1979
 
967
- *Jon Leighton*
1980
+ Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
968
1981
 
969
- * Support index sort order in sqlite, mysql and postgres adapters. *Vlad Jebelev*
1982
+ *Marcelo Casiraghi*, *Robin Dupret*
970
1983
 
971
- * Allow the :class_name option for associations to take a symbol (:Client) in addition to
972
- a string ('Client').
1984
+ * Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
1985
+ warnings on enum columns.
973
1986
 
974
- This is to avoid confusing newbies, and to be consistent with the fact that other options
975
- like :foreign_key already allow a symbol or a string.
1987
+ *Dieter Komendera*
976
1988
 
977
- *Jon Leighton*
1989
+ * `includes` is able to detect the right preloading strategy when string
1990
+ joins are involved.
978
1991
 
979
- * In development mode the db:drop task also drops the test database. For symmetry with
980
- the db:create task. *Dmitriy Kiriyenko*
1992
+ Fixes #14109.
981
1993
 
982
- * Added ActiveRecord::Base.store for declaring simple single-column key/value stores *DHH*
1994
+ *Aaron Patterson*, *Yves Senn*
983
1995
 
984
- class User < ActiveRecord::Base
985
- store :settings, accessors: [ :color, :homepage ]
986
- 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.
987
1998
 
988
- u = User.new(color: 'black', homepage: '37signals.com')
989
- u.color # Accessor stored attribute
990
- u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
1999
+ Fixes #14172.
991
2000
 
2001
+ *Vilius Luneckas* *Ahmed AbouElhamayed*
992
2002
 
993
- * MySQL: case-insensitive uniqueness validation avoids calling LOWER when
994
- the column already uses a case-insensitive collation. Fixes #561.
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.
995
2008
 
996
- *Joseph Palermo*
2009
+ Fixes #14144.
997
2010
 
998
- * Transactional fixtures enlist all active database connections. You can test
999
- models on different connections without disabling transactional fixtures.
2011
+ * Fix STI classes not defining an attribute method if there is a conflicting
2012
+ private method defined on its ancestors.
1000
2013
 
1001
- *Jeremy Kemper*
2014
+ Fixes #11569.
2015
+
2016
+ *Godfrey Chan*
2017
+
2018
+ * Coerce strings when reading attributes. Fixes #10485.
2019
+
2020
+ Example:
1002
2021
 
1003
- * Add first_or_create, first_or_create!, first_or_initialize methods to Active Record. This is a
1004
- better approach over the old find_or_create_by dynamic methods because it's clearer which
1005
- arguments are used to find the record and which are used to create it:
2022
+ book = Book.new(title: 12345)
2023
+ book.save!
2024
+ book.title # => "12345"
1006
2025
 
1007
- User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson")
2026
+ *Yves Senn*
1008
2027
 
1009
- *Andrés Mejía*
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.
1010
2031
 
1011
- * Fix nested attributes bug where _destroy parameter is taken into account
1012
- during :reject_if => :all_blank (fixes #2937)
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.
1013
2036
 
1014
- *Aaron Christy*
2037
+ *Yves Senn*
1015
2038
 
1016
- * Add ActiveSupport::Cache::NullStore for use in development and testing.
2039
+ * Support for user created range types in PostgreSQL.
1017
2040
 
1018
- *Brian Durand*
2041
+ *Yves Senn*
1019
2042
 
1020
- Please check [3-1-stable](https://github.com/rails/rails/blob/3-1-stable/activerecord/CHANGELOG.md) for previous changes.
2043
+ Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.