activerecord 3.1.10 → 4.2.11

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 (237) hide show
  1. checksums.yaml +6 -6
  2. data/CHANGELOG.md +1837 -338
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +39 -43
  5. data/examples/performance.rb +51 -20
  6. data/examples/simple.rb +4 -4
  7. data/lib/active_record/aggregations.rb +57 -43
  8. data/lib/active_record/association_relation.rb +35 -0
  9. data/lib/active_record/associations/alias_tracker.rb +47 -39
  10. data/lib/active_record/associations/association.rb +71 -85
  11. data/lib/active_record/associations/association_scope.rb +138 -89
  12. data/lib/active_record/associations/belongs_to_association.rb +65 -25
  13. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +9 -3
  14. data/lib/active_record/associations/builder/association.rb +125 -29
  15. data/lib/active_record/associations/builder/belongs_to.rb +91 -60
  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 -52
  20. data/lib/active_record/associations/builder/singular_association.rb +22 -29
  21. data/lib/active_record/associations/collection_association.rb +294 -187
  22. data/lib/active_record/associations/collection_proxy.rb +961 -94
  23. data/lib/active_record/associations/foreign_association.rb +11 -0
  24. data/lib/active_record/associations/has_many_association.rb +118 -23
  25. data/lib/active_record/associations/has_many_through_association.rb +115 -45
  26. data/lib/active_record/associations/has_one_association.rb +57 -24
  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 -102
  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 +61 -32
  38. data/lib/active_record/associations/preloader.rb +113 -87
  39. data/lib/active_record/associations/singular_association.rb +29 -13
  40. data/lib/active_record/associations/through_association.rb +37 -19
  41. data/lib/active_record/associations.rb +505 -371
  42. data/lib/active_record/attribute.rb +163 -0
  43. data/lib/active_record/attribute_assignment.rb +212 -0
  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 +141 -51
  47. data/lib/active_record/attribute_methods/primary_key.rb +87 -36
  48. data/lib/active_record/attribute_methods/query.rb +5 -4
  49. data/lib/active_record/attribute_methods/read.rb +74 -117
  50. data/lib/active_record/attribute_methods/serialization.rb +70 -0
  51. data/lib/active_record/attribute_methods/time_zone_conversion.rb +49 -47
  52. data/lib/active_record/attribute_methods/write.rb +60 -21
  53. data/lib/active_record/attribute_methods.rb +409 -48
  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 +279 -232
  58. data/lib/active_record/base.rb +84 -1969
  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 +422 -243
  63. data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
  64. data/lib/active_record/connection_adapters/abstract/database_statements.rb +170 -194
  65. data/lib/active_record/connection_adapters/abstract/query_cache.rb +32 -19
  66. data/lib/active_record/connection_adapters/abstract/quoting.rb +79 -57
  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 +273 -170
  70. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +50 -0
  71. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +731 -254
  72. data/lib/active_record/connection_adapters/abstract/transaction.rb +215 -0
  73. data/lib/active_record/connection_adapters/abstract_adapter.rb +339 -95
  74. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +946 -0
  75. data/lib/active_record/connection_adapters/column.rb +33 -221
  76. data/lib/active_record/connection_adapters/connection_specification.rb +275 -0
  77. data/lib/active_record/connection_adapters/mysql2_adapter.rb +140 -602
  78. data/lib/active_record/connection_adapters/mysql_adapter.rb +254 -756
  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 +445 -902
  114. data/lib/active_record/connection_adapters/schema_cache.rb +94 -0
  115. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +578 -25
  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 +159 -102
  119. data/lib/active_record/dynamic_matchers.rb +140 -0
  120. data/lib/active_record/enum.rb +197 -0
  121. data/lib/active_record/errors.rb +102 -34
  122. data/lib/active_record/explain.rb +38 -0
  123. data/lib/active_record/explain_registry.rb +30 -0
  124. data/lib/active_record/explain_subscriber.rb +29 -0
  125. data/lib/active_record/fixture_set/file.rb +56 -0
  126. data/lib/active_record/fixtures.rb +318 -260
  127. data/lib/active_record/gem_version.rb +15 -0
  128. data/lib/active_record/inheritance.rb +247 -0
  129. data/lib/active_record/integration.rb +113 -0
  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 +80 -52
  133. data/lib/active_record/locking/pessimistic.rb +27 -5
  134. data/lib/active_record/log_subscriber.rb +25 -18
  135. data/lib/active_record/migration/command_recorder.rb +130 -38
  136. data/lib/active_record/migration/join_table.rb +15 -0
  137. data/lib/active_record/migration.rb +532 -201
  138. data/lib/active_record/model_schema.rb +342 -0
  139. data/lib/active_record/nested_attributes.rb +229 -139
  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 +304 -99
  143. data/lib/active_record/query_cache.rb +25 -43
  144. data/lib/active_record/querying.rb +68 -0
  145. data/lib/active_record/railtie.rb +86 -45
  146. data/lib/active_record/railties/console_sandbox.rb +3 -4
  147. data/lib/active_record/railties/controller_runtime.rb +7 -4
  148. data/lib/active_record/railties/databases.rake +198 -377
  149. data/lib/active_record/railties/jdbcmysql_error.rb +2 -2
  150. data/lib/active_record/readonly_attributes.rb +23 -0
  151. data/lib/active_record/reflection.rb +516 -165
  152. data/lib/active_record/relation/batches.rb +96 -45
  153. data/lib/active_record/relation/calculations.rb +221 -144
  154. data/lib/active_record/relation/delegation.rb +140 -0
  155. data/lib/active_record/relation/finder_methods.rb +362 -243
  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 -41
  160. data/lib/active_record/relation/query_methods.rb +982 -155
  161. data/lib/active_record/relation/spawn_methods.rb +50 -110
  162. data/lib/active_record/relation.rb +371 -180
  163. data/lib/active_record/result.rb +109 -12
  164. data/lib/active_record/runtime_registry.rb +22 -0
  165. data/lib/active_record/sanitization.rb +191 -0
  166. data/lib/active_record/schema.rb +19 -13
  167. data/lib/active_record/schema_dumper.rb +111 -61
  168. data/lib/active_record/schema_migration.rb +53 -0
  169. data/lib/active_record/scoping/default.rb +135 -0
  170. data/lib/active_record/scoping/named.rb +164 -0
  171. data/lib/active_record/scoping.rb +87 -0
  172. data/lib/active_record/serialization.rb +7 -45
  173. data/lib/active_record/serializers/xml_serializer.rb +14 -65
  174. data/lib/active_record/statement_cache.rb +111 -0
  175. data/lib/active_record/store.rb +205 -0
  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 +35 -14
  181. data/lib/active_record/transactions.rb +141 -74
  182. data/lib/active_record/translation.rb +22 -0
  183. data/lib/active_record/type/big_integer.rb +13 -0
  184. data/lib/active_record/type/binary.rb +50 -0
  185. data/lib/active_record/type/boolean.rb +31 -0
  186. data/lib/active_record/type/date.rb +50 -0
  187. data/lib/active_record/type/date_time.rb +54 -0
  188. data/lib/active_record/type/decimal.rb +64 -0
  189. data/lib/active_record/type/decimal_without_scale.rb +11 -0
  190. data/lib/active_record/type/decorator.rb +14 -0
  191. data/lib/active_record/type/float.rb +19 -0
  192. data/lib/active_record/type/hash_lookup_type_map.rb +23 -0
  193. data/lib/active_record/type/integer.rb +59 -0
  194. data/lib/active_record/type/mutable.rb +16 -0
  195. data/lib/active_record/type/numeric.rb +36 -0
  196. data/lib/active_record/type/serialized.rb +62 -0
  197. data/lib/active_record/type/string.rb +40 -0
  198. data/lib/active_record/type/text.rb +11 -0
  199. data/lib/active_record/type/time.rb +26 -0
  200. data/lib/active_record/type/time_value.rb +38 -0
  201. data/lib/active_record/type/type_map.rb +64 -0
  202. data/lib/active_record/type/unsigned_integer.rb +15 -0
  203. data/lib/active_record/type/value.rb +110 -0
  204. data/lib/active_record/type.rb +23 -0
  205. data/lib/active_record/validations/associated.rb +27 -18
  206. data/lib/active_record/validations/presence.rb +67 -0
  207. data/lib/active_record/validations/uniqueness.rb +125 -66
  208. data/lib/active_record/validations.rb +37 -30
  209. data/lib/active_record/version.rb +5 -7
  210. data/lib/active_record.rb +80 -25
  211. data/lib/rails/generators/active_record/migration/migration_generator.rb +54 -9
  212. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +19 -0
  213. data/lib/rails/generators/active_record/migration/templates/migration.rb +25 -11
  214. data/lib/rails/generators/active_record/migration.rb +11 -8
  215. data/lib/rails/generators/active_record/model/model_generator.rb +17 -4
  216. data/lib/rails/generators/active_record/model/templates/model.rb +5 -2
  217. data/lib/rails/generators/active_record/model/templates/module.rb +1 -1
  218. data/lib/rails/generators/active_record.rb +3 -11
  219. metadata +132 -53
  220. data/examples/associations.png +0 -0
  221. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +0 -62
  222. data/lib/active_record/associations/join_helper.rb +0 -55
  223. data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +0 -60
  224. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +0 -135
  225. data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -556
  226. data/lib/active_record/dynamic_finder_match.rb +0 -56
  227. data/lib/active_record/dynamic_scope_match.rb +0 -23
  228. data/lib/active_record/identity_map.rb +0 -163
  229. data/lib/active_record/named_scope.rb +0 -200
  230. data/lib/active_record/observer.rb +0 -121
  231. data/lib/active_record/session_store.rb +0 -358
  232. data/lib/active_record/test_case.rb +0 -69
  233. data/lib/rails/generators/active_record/model/templates/migration.rb +0 -17
  234. data/lib/rails/generators/active_record/observer/observer_generator.rb +0 -15
  235. data/lib/rails/generators/active_record/observer/templates/observer.rb +0 -4
  236. data/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +0 -25
  237. data/lib/rails/generators/active_record/session_migration/templates/migration.rb +0 -16
data/CHANGELOG.md CHANGED
@@ -1,529 +1,2028 @@
1
- ## Rails 3.1.10
1
+ ## Rails 4.2.11 (November 27, 2018) ##
2
2
 
3
- * Fix querying with an empty hash *Damien Mathieu* [CVE-2013-0155]
3
+ * No changes.
4
+
5
+
6
+ ## Rails 4.2.10 (September 27, 2017) ##
7
+
8
+ * `Relation#joins` is no longer affected by the target model's
9
+ `current_scope`, with the exception of `unscoped`.
10
+
11
+ Fixes #29338.
12
+
13
+ *Sean Griffin*
14
+
15
+ ## Rails 4.2.9 (June 26, 2017) ##
16
+
17
+ * Fix regression caused by `collection_singular_ids=` ignoring different primary key on relationship.
18
+
19
+ *Nick Pezza*
20
+
21
+ * Fix `rake db:schema:load` with subdirectories.
22
+
23
+ *Ryuta Kamizono*
24
+
25
+ * Fix `rake db:migrate:status` with subdirectories.
26
+
27
+ *Ryuta Kamizono*
28
+
29
+ * Fix regression of #1969 with SELECT aliases in HAVING clause.
30
+
31
+ *Eugene Kenny*
32
+
33
+ * Fix `wait_timeout` to configurable for mysql2 adapter.
34
+
35
+ Fixes #26556.
36
+
37
+ *Ryuta Kamizono*
38
+
39
+ * Make `table_name=` reset current statement cache,
40
+ so queries are not run against the previous table name.
41
+
42
+ *namusyaka*
43
+
44
+
45
+ ## Rails 4.2.8 (February 21, 2017) ##
46
+
47
+ * Using a mysql2 connection after it fails to reconnect will now have an error message
48
+ saying the connection is closed rather than an undefined method error message.
49
+
50
+ *Dylan Thacker-Smith*
51
+
52
+ * Bust Model.attribute_names cache when resetting column information
53
+
54
+ *James Coleman*
55
+
56
+ * Fix query caching when type information is reset
57
+
58
+ Backports ancillary fix in 5.0.
59
+
60
+ *James Coleman*
61
+
62
+ * Allow `joins` to be unscoped.
63
+
64
+ Fixes #13775.
65
+
66
+ *Takashi Kokubun*
67
+
68
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
69
+ mapping methods are methods implemented on `Hash`.
70
+
71
+ Fixes #25978.
72
+
73
+ *Sean Griffin*
74
+
75
+
76
+ ## Rails 4.2.7 (July 12, 2016) ##
77
+
78
+ * Inspecting an object with an associated array of over 10 elements no longer
79
+ truncates the array, preventing `inspect` from looping infinitely in some
80
+ cases.
81
+
82
+ *Kevin McPhillips*
83
+
84
+ * Ensure hashes can be assigned to attributes created using `composed_of`.
85
+ Fixes #25210.
86
+
87
+ *Sean Griffin*
88
+
89
+ * Queries such as `Computer.joins(:monitor).group(:status).count` will now be
90
+ interpreted as `Computer.joins(:monitor).group('computers.status').count`
91
+ so that when `Computer` and `Monitor` have both `status` columns we don't
92
+ have conflicts in projection.
93
+
94
+ *Rafael Sales*
95
+
96
+ * ActiveRecord::Relation#count: raise an ArgumentError when finder options
97
+ are specified or an ActiveRecord::StatementInvalid when an invalid type
98
+ is provided for a column name (e.g. a Hash).
99
+
100
+ Fixes #20434
101
+
102
+ *Konstantinos Rousis*
103
+
104
+ * Correctly pass MySQL options when using structure_dump or structure_load
105
+
106
+ Specifically, it fixes an issue when using SSL authentication.
107
+
108
+ *Alex Coomans*
109
+
110
+
111
+ ## Rails 4.2.6 (March 07, 2016) ##
112
+
113
+ * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
114
+ the same table definition would only create one foreign key.
115
+
116
+ *George Millo*
117
+
118
+ * Fix regression in dirty attribute tracking after #dup. Changes to the
119
+ clone no longer show as changed attributes in the original object.
120
+
121
+ *Dominic Cleal*
122
+
123
+ * Fix regression when loading fixture files with symbol keys.
124
+
125
+ Closes #22584.
126
+
127
+ *Yves Senn*
128
+
129
+ * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
130
+
131
+ Fixes #22346.
132
+
133
+ *Nick Muerdter*, *ckoenig*
134
+
135
+ * Introduce `connection.data_sources` and `connection.data_source_exists?`.
136
+ These methods determine what relations can be used to back Active Record
137
+ models (usually tables and views).
138
+
139
+ *Yves Senn*, *Matthew Draper*
140
+
141
+
142
+ ## Rails 4.2.5.2 (February 26, 2016) ##
143
+
144
+ * No changes.
145
+
146
+
147
+ ## Rails 4.2.5.1 (January 25, 2015) ##
148
+
149
+ * No changes.
150
+
151
+
152
+ ## Rails 4.2.5 (November 12, 2015) ##
153
+
154
+ * No longer pass deprecated option `-i` to `pg_dump`.
155
+
156
+ *Paul Sadauskas*
157
+
158
+ * Set `scope.reordering_value` to `true` if :reordering values are specified.
159
+
160
+ Fixes #21886.
161
+
162
+ *Hiroaki Izu*
163
+
164
+ * Avoid disabling errors on the PostgreSQL connection when enabling the
165
+ standard_conforming_strings setting. Errors were previously disabled because
166
+ the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
167
+ versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
168
+ setting exists. Disabling errors caused problems when using a connection
169
+ pooling tool like PgBouncer because it's not guaranteed to have the same
170
+ connection between calls to `execute` and it could leave the connection
171
+ with errors disabled.
172
+
173
+ Fixes #22101.
174
+
175
+ *Harry Marr*
176
+
177
+ * Includes HABTM returns correct size now. It's caused by the join dependency
178
+ only instantiates one HABTM object because the join table hasn't a primary key.
179
+
180
+ Fixes #16032.
181
+
182
+ Examples:
183
+
184
+ before:
185
+
186
+ Project.first.salaried_developers.size # => 3
187
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 1
188
+
189
+ after:
190
+
191
+ Project.first.salaried_developers.size # => 3
192
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 3
193
+
194
+ *Bigxiang*
195
+
196
+ * Descriptive error message when fixtures contain a missing column.
197
+
198
+ Closes #21201.
199
+
200
+ *Yves Senn*
201
+
202
+ * `bin/rake db:migrate` uses
203
+ `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
204
+ `Migrator.migrations_paths`.
205
+
206
+ *Tobias Bielohlawek*
207
+
208
+ * Fix `rewhere` in a `has_many` association.
209
+
210
+ Fixes #21955.
211
+
212
+ *Josh Branchaud*, *Kal*
213
+
214
+ * Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
215
+ drying up Kernel.system() calls within this namespace and to avoid
216
+ shell expansion by using a paramter list instead of string as arguments
217
+ for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
218
+ test units passing.
219
+
220
+ *Bryan Paxton*
221
+
222
+ * Avoid leaking the first relation we call `first` on, per model.
223
+
224
+ Fixes #21921.
225
+
226
+ *Matthew Draper*, *Jean Boussier*
227
+
228
+ * Allow deserialization of Active Record models that were YAML encoded prior
229
+ to Rails 4.2
230
+
231
+ *Sean Griffin*
232
+
233
+ * Correctly apply `unscope` when preloading through associations.
234
+
235
+ *Jimmy Bourassa*
236
+
237
+ * Ensure `select` quotes aliased attributes, even when using `from`.
238
+
239
+ Fixes #21488
240
+
241
+ *Sean Griffin & @johanlunds*
242
+
243
+ * Correct query for PostgreSQL 8.2 compatibility.
244
+
245
+ *Ben Murphy*, *Matthew Draper*
246
+
247
+ * Uniqueness validator raises descriptive error when running on a persisted
248
+ record without primary key.
249
+
250
+ Closes #21304.
251
+
252
+ *Yves Senn*
253
+
254
+
255
+ ## Rails 4.2.4 (August 24, 2015) ##
256
+
257
+ * Skip statement cache on through association reader.
258
+
259
+ If the through class has default scopes we should skip the statement
260
+ cache.
261
+
262
+ Closes #20745.
263
+
264
+ *Rafael Mendonça França*
265
+
266
+ * Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
267
+ the limit: 8 was not coming through. This caused it to become Int[] data type
268
+ after doing a rebuild off of schema.rb.
269
+
270
+ *Jake Waller*
271
+
272
+ * Fix state being carried over from previous transaction.
273
+
274
+ Considering the following example where `name` is a required attribute.
275
+ Before we had `new_record?` returning `true` for a persisted record:
276
+
277
+ author = Author.create! name: 'foo'
278
+ author.name = nil
279
+ author.save # => false
280
+ author.new_record? # => true
281
+
282
+ Fixes #20824.
283
+
284
+ *Roque Pinel*
285
+
286
+ * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
287
+ when validating associations.
288
+
289
+ Fixes #20882.
290
+
291
+ *Sean Griffin*
292
+
293
+ * Fix through associations using scopes having the scope merged multiple
294
+ times.
295
+
296
+ Fixes #20721.
297
+ Fixes #20727.
298
+
299
+ *Sean Griffin*
300
+
301
+ * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
302
+ other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
303
+
304
+ Fixes #20743.
305
+
306
+ *Yves Senn*
307
+
308
+ * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
309
+ a wrong type to a namespaced association.
310
+
311
+ Fixes #20545.
312
+
313
+ *Diego Carrion*
314
+
315
+ * Prevent error when using `force_reload: true` on an unassigned polymorphic
316
+ belongs_to association.
317
+
318
+ Fixes #20426.
319
+
320
+ *James Dabbs*
321
+
322
+
323
+ ## Rails 4.2.3 (June 25, 2015) ##
324
+
325
+ * Let `WITH` queries (Common Table Expressions) be explainable.
326
+
327
+ *Vladimir Kochnev*
328
+
329
+ * Fix n+1 query problem when eager loading nil associations (fixes #18312)
330
+
331
+ *Sammy Larbi*
332
+
333
+ * Fixed an error which would occur in dirty checking when calling
334
+ `update_attributes` from a getter.
335
+
336
+ Fixes #20531.
337
+
338
+ *Sean Griffin*
339
+
340
+ * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
341
+ as columns.
342
+
343
+ Fixes #20360.
344
+
345
+ *Sean Griffin*
346
+
347
+ * Clear query cache when `ActiveRecord::Base#reload` is called.
348
+
349
+ *Shane Hender*
350
+
351
+ * Pass `:extend` option for `has_and_belongs_to_many` associations to the
352
+ underlying `has_many :through`.
353
+
354
+ *Jaehyun Shin*
355
+
356
+ * Make `unscope` aware of "less than" and "greater than" conditions.
357
+
358
+ *TAKAHASHI Kazuaki*
359
+
360
+ * Revert behavior of `db:schema:load` back to loading the full
361
+ environment. This ensures that initializers are run.
362
+
363
+ Fixes #19545.
364
+
365
+ *Yves Senn*
366
+
367
+ * Fix missing index when using `timestamps` with the `index` option.
368
+
369
+ The `index` option used with `timestamps` should be passed to both
370
+ `column` definitions for `created_at` and `updated_at` rather than just
371
+ the first.
372
+
373
+ *Paul Mucur*
374
+
375
+ * Rename `:class` to `:anonymous_class` in association options.
376
+
377
+ Fixes #19659.
378
+
379
+ *Andrew White*
380
+
381
+ * Fixed a bug where uniqueness validations would error on out of range values,
382
+ even if an validation should have prevented it from hitting the database.
383
+
384
+ *Andrey Voronkov*
385
+
386
+ * Foreign key related methods in the migration DSL respect
387
+ `ActiveRecord::Base.pluralize_table_names = false`.
388
+
389
+ Fixes #19643.
390
+
391
+ *Mehmet Emin İNAÇ*
392
+
393
+ * Reduce memory usage from loading types on pg.
394
+
395
+ Fixes #19578.
396
+
397
+ *Sean Griffin*
398
+
399
+ * Fix referencing wrong table aliases while joining tables of has many through
400
+ association (only when calling calculation methods).
401
+
402
+ Fixes #19276.
403
+
404
+ *pinglamb*
405
+
406
+ * Don't attempt to update counter caches, when the column wasn't selected.
407
+
408
+ Fixes #19437.
409
+
410
+ *Sean Griffin*
411
+
412
+ * Correctly persist a serialized attribute that has been returned to
413
+ its default value by an in-place modification.
414
+
415
+ Fixes #19467.
416
+
417
+ *Matthew Draper*
418
+
419
+ * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
420
+
421
+ *James Cox*
422
+
423
+ * Dont enroll records in the transaction if they dont have commit callbacks.
424
+ That was causing a memory grow problem when creating a lot of records inside a transaction.
425
+
426
+ Fixes #15549.
427
+
428
+ *Will Bryant*, *Aaron Patterson*
429
+
430
+ * Correctly create through records when created on a has many through
431
+ association when using `where`.
432
+
433
+ Fixes #19073.
434
+
435
+ *Sean Griffin*
436
+
437
+
438
+ ## Rails 4.2.2 (June 16, 2015) ##
439
+
440
+ * No Changes *
441
+
442
+
443
+ ## Rails 4.2.1 (March 19, 2015) ##
444
+
445
+ * Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
446
+
447
+ Fixes #17139.
448
+
449
+ *Miklos Fazekas*
450
+
451
+ * `remove_reference` with `foreign_key: true` removes the foreign key before
452
+ removing the column. This fixes a bug where it was not possible to remove
453
+ the column on MySQL.
454
+
455
+ Fixes #18664.
456
+
457
+ *Yves Senn*
458
+
459
+ * Add a `:foreign_key` option to `references` and associated migration
460
+ methods. The model and migration generators now use this option, rather than
461
+ the `add_foreign_key` form.
462
+
463
+ *Sean Griffin*
464
+
465
+ * Fix rounding problem for PostgreSQL timestamp column.
466
+
467
+ If timestamp column have the precision, it need to format according to
468
+ the precision of timestamp column.
469
+
470
+ *Ryuta Kamizono*
471
+
472
+ * Respect the database default charset for `schema_migrations` table.
473
+
474
+ The charset of `version` column in `schema_migrations` table is depend
475
+ on the database default charset and collation rather than the encoding
476
+ of the connection.
477
+
478
+ *Ryuta Kamizono*
479
+
480
+ * Respect custom primary keys for associations when calling `Relation#where`
481
+
482
+ Fixes #18813.
483
+
484
+ *Sean Griffin*
485
+
486
+ * Fixed several edge cases which could result in a counter cache updating
487
+ twice or not updating at all for `has_many` and `has_many :through`.
488
+
489
+ Fixes #10865.
490
+
491
+ *Sean Griffin*
492
+
493
+ * Foreign keys added by migrations were given random, generated names. This
494
+ meant a different `structure.sql` would be generated every time a developer
495
+ ran migrations on their machine.
496
+
497
+ The generated part of foreign key names is now a hash of the table name and
498
+ column name, which is consistent every time you run the migration.
499
+
500
+ *Chris Sinjakli*
501
+
502
+ * Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
503
+
504
+ SplitTest.group(:key).count
505
+ Property.group(:value).count
506
+
507
+ *Bogdan Gusiev*
508
+
509
+ * Don't define autosave association callbacks twice from
510
+ `accepts_nested_attributes_for`.
511
+
512
+ Fixes #18704.
513
+
514
+ *Sean Griffin*
515
+
516
+ * Integer types will no longer raise a `RangeError` when assigning an
517
+ attribute, but will instead raise when going to the database.
518
+
519
+ Fixes several vague issues which were never reported directly. See the
520
+ commit message from the commit which added this line for some examples.
521
+
522
+ *Sean Griffin*
523
+
524
+ * Values which would error while being sent to the database (such as an
525
+ ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
526
+ assignment. They will still error when sent to the database, but you are
527
+ given the ability to re-assign it to a valid value.
528
+
529
+ Fixes #18580.
530
+
531
+ *Sean Griffin*
532
+
533
+ * Don't remove join dependencies in `Relation#exists?`
534
+
535
+ Fixes #18632.
536
+
537
+ *Sean Griffin*
538
+
539
+ * Invalid values assigned to a JSON column are assumed to be `nil`.
540
+
541
+ Fixes #18629.
542
+
543
+ *Sean Griffin*
544
+
545
+ * No longer issue deprecation warning when including a scope with extensions.
546
+ Previously every scope with extension methods was transformed into an
547
+ instance dependent scope. Including such a scope would wrongfully issue a
548
+ deprecation warning. This is no longer the case.
549
+
550
+ Fixes #18467.
551
+
552
+ *Yves Senn*
553
+
554
+ * Correctly use the type provided by `serialize` when updating records using
555
+ optimistic locking.
556
+
557
+ Fixes #18385.
558
+
559
+ *Sean Griffin*
560
+
561
+ * `attribute_will_change!` will no longer cause non-persistable attributes to
562
+ be sent to the database.
563
+
564
+ Fixes #18407.
565
+
566
+ *Sean Griffin*
567
+
568
+ * Format the datetime string according to the precision of the datetime field.
569
+
570
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
571
+
572
+ In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
573
+ is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
574
+
575
+ http://bugs.mysql.com/bug.php?id=68760
576
+
577
+ *Ryuta Kamizono*
578
+
579
+ * Allow precision option for MySQL datetimes.
580
+
581
+ *Ryuta Kamizono*
582
+
583
+ * Clear query cache on rollback.
584
+
585
+ *Florian Weingarten*
586
+
587
+ * Fixed setting of foreign_key for through associations while building of new record.
588
+
589
+ Fixes #12698.
590
+
591
+ *Ivan Antropov*
592
+
593
+ * Fixed automatic inverse_of for models nested in module.
594
+
595
+ *Andrew McCloud*
596
+
597
+ * Fix `reaping_frequency` option when the value is a string.
598
+
599
+ This usually happens when it is configured using `DATABASE_URL`.
600
+
601
+ *korbin*
602
+
603
+ * Fix error message when trying to create an associated record and the foreign
604
+ key is missing.
605
+
606
+ Before this fix the following exception was being raised:
607
+
608
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
609
+
610
+ Now the message is:
611
+
612
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
613
+
614
+ *Rafael Mendonça França*
615
+
616
+ * Fix change detection problem for PostgreSQL bytea type and
617
+ `ArgumentError: string contains null byte` exception with pg-0.18.
618
+
619
+ Fixes #17680.
620
+
621
+ *Lars Kanis*
622
+
623
+ * When a table has a composite primary key, the `primary_key` method for
624
+ SQLite3 and PostgreSQL adapters was only returning the first field of the key.
625
+ Ensures that it will return nil instead, as Active Record doesn't support
626
+ composite primary keys.
627
+
628
+ Fixes #18070.
629
+
630
+ *arthurnn*
631
+
632
+ * Ensure `first!` and friends work on loaded associations.
633
+
634
+ Fixes #18237.
635
+
636
+ *Sean Griffin*
637
+
638
+ * Dump the default `nil` for PostgreSQL UUID primary key.
639
+
640
+ *Ryuta Kamizono*
641
+
642
+ * Don't raise when writing an attribute with an out-of-range datetime passed
643
+ by the user.
644
+
645
+ *Grey Baker*
646
+
647
+ * Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
648
+ be marked as having changed when set to the same negative value.
649
+
650
+ Fixes #18161.
651
+
652
+ *Daniel Fox*
653
+
654
+
655
+ ## Rails 4.2.0 (December 20, 2014) ##
656
+
657
+ * Introduce `force: :cascade` option for `create_table`. Using this option
658
+ will recreate tables even if they have dependent objects (like foreign keys).
659
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
660
+ reload the schema when foreign keys are in place.
661
+
662
+ *Matthew Draper*, *Yves Senn*
663
+
664
+ * `db:schema:load` and `db:structure:load` no longer purge the database
665
+ before loading the schema. This is left for the user to do.
666
+ `db:test:prepare` will still purge the database.
667
+
668
+ Fixes #17945.
669
+
670
+ *Yves Senn*
671
+
672
+ * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
673
+
674
+ *Ryuta Kamizono*
675
+
676
+ * Add `foreign_type` option to `has_one` and `has_many` association macros.
677
+
678
+ This option enables to define the column name of associated object's type for polymorphic associations.
679
+
680
+ *Ulisses Almeida, Kassio Borges*
681
+
682
+ * `add_timestamps` and `remove_timestamps` now properly reversible with
683
+ options.
684
+
685
+ *Noam Gagliardi-Rabinovich*
686
+
687
+ * Bring back `db:test:prepare` to synchronize the test database schema.
688
+
689
+ Manual synchronization using `bin/rake db:test:prepare` is required
690
+ when a migration is rolled-back, edited and reapplied.
691
+
692
+ `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
693
+ to synchronize the schema. Plugins can use this task as a hook to
694
+ provide custom behavior after the schema has been loaded.
695
+
696
+ NOTE: `test:prepare` runs before the schema is synchronized.
697
+
698
+ Fixes #17171, #15787.
699
+
700
+ *Yves Senn*
701
+
702
+ * Change `reflections` public api to return the keys as String objects.
703
+
704
+ Fixes #16928.
705
+
706
+ *arthurnn*
707
+
708
+ * Renaming a table in pg also renames the primary key index.
709
+
710
+ Fixes #12856
711
+
712
+ *Sean Griffin*
713
+
714
+ * Make it possible to access fixtures excluded by a `default_scope`.
715
+
716
+ *Yves Senn*
717
+
718
+ * Fix preloading of associations with a scope containing joins along with
719
+ conditions on the joined association.
720
+
721
+ *Siddharth Sharma*
722
+
723
+ * Add `Table#name` to match `TableDefinition#name`.
724
+
725
+ *Cody Cutrer*
726
+
727
+ * Cache `CollectionAssociation#reader` proxies separately before and after
728
+ the owner has been saved so that the proxy is not cached without the
729
+ owner's id.
730
+
731
+ *Ben Woosley*
732
+
733
+ * `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
734
+
735
+ *Franky W.*
736
+
737
+ * Fix preloading of associations which unscope a default scope.
738
+
739
+ Fixes #11036.
740
+
741
+ *Byron Bischoff*
742
+
743
+ * Added SchemaDumper support for tables with jsonb columns.
744
+
745
+ *Ted O'Meara*
746
+
747
+ * Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
748
+ `Relation` for performing queries and updates is the prefered API.
749
+
750
+ *Sean Griffin*
751
+
752
+ * Queries now properly type cast values that are part of a join statement,
753
+ even when using type decorators such as `serialize`.
754
+
755
+ *Melanie Gilman & Sean Griffin*
756
+
757
+ * MySQL enum type lookups, with values matching another type, no longer result
758
+ in an endless loop.
759
+
760
+ Fixes #17402.
761
+
762
+ *Yves Senn*
763
+
764
+ * Raise `ArgumentError` when the body of a scope is not callable.
765
+
766
+ *Mauro George*
767
+
768
+ * Use type column first in multi-column indexes created with `add-reference`.
769
+
770
+ *Derek Prior*
771
+
772
+ * Fix `Relation.rewhere` to work with Range values.
773
+
774
+ *Dan Olson*
775
+
776
+ * `AR::UnknownAttributeError` now includes the class name of a record.
777
+
778
+ User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
779
+ # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
780
+
781
+ *Yuki Nishijima*
782
+
783
+ * Fix a regression causing `after_create` callbacks to run before associated
784
+ records are autosaved.
785
+
786
+ Fixes #17209.
787
+
788
+ *Agis Anastasopoulos*
789
+
790
+ * Honor overridden `rack.test` in Rack environment for the connection
791
+ management middleware.
792
+
793
+ *Simon Eskildsen*
794
+
795
+ * Add a truncate method to the connection.
796
+
797
+ *Aaron Patterson*
798
+
799
+ * Don't autosave unchanged has_one through records.
800
+
801
+ *Alan Kennedy*, *Steve Parrington*
802
+
803
+ * Do not dump foreign keys for ignored tables.
804
+
805
+ *Yves Senn*
806
+
807
+ * PostgreSQL adapter correctly dumps foreign keys targeting tables
808
+ outside the schema search path.
809
+
810
+ Fixes #16907.
811
+
812
+ *Matthew Draper*, *Yves Senn*
813
+
814
+ * When a thread is killed, rollback the active transaction, instead of
815
+ committing it during the stack unwind. Previously, we could commit half-
816
+ completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
817
+ distinguish a thread kill from an ordinary non-local (block) return, so must
818
+ default to committing.
819
+
820
+ *Chris Hanks*
821
+
822
+ * A `NullRelation` should represent nothing. This fixes a bug where
823
+ `Comment.where(post_id: Post.none)` returned a non-empty result.
824
+
825
+ Fixes #15176.
826
+
827
+ *Matthew Draper*, *Yves Senn*
828
+
829
+ * Include default column limits in schema.rb. Allows defaults to be changed
830
+ in the future without affecting old migrations that assumed old defaults.
831
+
832
+ *Jeremy Kemper*
833
+
834
+ * MySQL: schema.rb now includes TEXT and BLOB column limits.
835
+
836
+ *Jeremy Kemper*
837
+
838
+ * MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
839
+
840
+ *Jeremy Kemper*
841
+
842
+ * SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
843
+
844
+ *Girish Sonawane*
845
+
846
+ * Introduce `connection.supports_views?` to check whether the current adapter
847
+ has support for SQL views. Connection adapters should define this method.
848
+
849
+ *Yves Senn*
850
+
851
+ * Allow included modules to override association methods.
852
+
853
+ Fixes #16684.
854
+
855
+ *Yves Senn*
856
+
857
+ * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
858
+ the database connection to the current environment.
859
+
860
+ Fixes #16757.
861
+
862
+ *Joshua Cody*, *Yves Senn*
863
+
864
+ * MySQL: set the connection collation along with the charset.
865
+
866
+ Sets the connection collation to the database collation configured in
867
+ database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
868
+ collation for that charset (utf8mb4_general_ci) when you may have chosen
869
+ a different collation, like utf8mb4_unicode_ci.
870
+
871
+ This only applies to literal string comparisons, not column values, so it
872
+ is unlikely to affect you.
873
+
874
+ *Jeremy Kemper*
875
+
876
+ * `default_sequence_name` from the PostgreSQL adapter returns a `String`.
877
+
878
+ *Yves Senn*
879
+
880
+ * Fix a regression where whitespaces were stripped from DISTINCT queries in
881
+ PostgreSQL.
882
+
883
+ *Agis Anastasopoulos*
884
+
885
+ Fixes #16623.
886
+
887
+ * Fix has_many :through relation merging failing when dynamic conditions are
888
+ passed as a lambda with an arity of one.
889
+
890
+ Fixes #16128.
891
+
892
+ *Agis Anastasopoulos*
893
+
894
+ * Fix `Relation#exists?` to work with polymorphic associations.
895
+
896
+ Fixes #15821.
897
+
898
+ *Kassio Borges*
899
+
900
+ * Currently, Active Record rescues any errors raised within
901
+ `after_rollback`/`after_create` callbacks and prints them to the logs.
902
+ Future versions of Rails will not rescue these errors anymore and
903
+ just bubble them up like the other callbacks.
904
+
905
+ This commit adds an opt-in flag to enable not rescuing the errors.
906
+
907
+ Example:
908
+
909
+ # Do not swallow errors in after_commit/after_rollback callbacks.
910
+ config.active_record.raise_in_transactional_callbacks = true
911
+
912
+ Fixes #13460.
913
+
914
+ *arthurnn*
915
+
916
+ * Fix an issue where custom accessor methods (such as those generated by
917
+ `enum`) with the same name as a global method are incorrectly overridden
918
+ when subclassing.
919
+
920
+ Fixes #16288.
921
+
922
+ *Godfrey Chan*
923
+
924
+ * `*_was` and `changes` now work correctly for in-place attribute changes as
925
+ well.
926
+
927
+ *Sean Griffin*
928
+
929
+ * Fix regression on `after_commit` that did not fire with nested transactions.
930
+
931
+ Fixes #16425.
932
+
933
+ *arthurnn*
934
+
935
+ * Do not try to write timestamps when a table has no timestamps columns.
936
+
937
+ Fixes #8813.
938
+
939
+ *Sergey Potapov*
940
+
941
+ * `index_exists?` with `:name` option does verify specified columns.
942
+
943
+ Example:
944
+
945
+ add_index :articles, :title, name: "idx_title"
946
+
947
+ # Before:
948
+ index_exists? :articles, :title, name: "idx_title" # => `true`
949
+ index_exists? :articles, :body, name: "idx_title" # => `true`
950
+
951
+ # After:
952
+ index_exists? :articles, :title, name: "idx_title" # => `true`
953
+ index_exists? :articles, :body, name: "idx_title" # => `false`
954
+
955
+ *Yves Senn*, *Matthew Draper*
956
+
957
+ * `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
958
+ Not passing the option is deprecated but the default is still `null: true`.
959
+ With Rails 5 this will change to `null: false`.
960
+
961
+ *Sean Griffin*
962
+
963
+ * When calling `update_columns` on a record that is not persisted, the error
964
+ message now reflects whether that object is a new record or has been
965
+ destroyed.
966
+
967
+ *Lachlan Sylvester*
968
+
969
+ * Define `id_was` to get the previous value of the primary key.
970
+
971
+ Currently when we call `id_was` and we have a custom primary key name,
972
+ Active Record will return the current value of the primary key. This
973
+ makes it impossible to correctly do an update operation if you change the
974
+ id.
975
+
976
+ Fixes #16413.
977
+
978
+ *Rafael Mendonça França*
979
+
980
+ * Deprecate `DatabaseTasks.load_schema` to act on the current connection.
981
+ Use `.load_schema_current` instead. In the future `load_schema` will
982
+ require the `configuration` to act on as an argument.
983
+
984
+ *Yves Senn*
985
+
986
+ * Fix automatic maintaining test schema to properly handle sql structure
987
+ schema format.
988
+
989
+ Fixes #15394.
990
+
991
+ *Wojciech Wnętrzak*
992
+
993
+ * Fix type casting to Decimal from Float with large precision.
994
+
995
+ *Tomohiro Hashidate*
996
+
997
+ * Deprecate `Reflection#source_macro`
998
+
999
+ `Reflection#source_macro` is no longer needed in Active Record
1000
+ source so it has been deprecated. Code that used `source_macro`
1001
+ was removed in #16353.
1002
+
1003
+ *Eileen M. Uchtitelle*, *Aaron Patterson*
1004
+
1005
+ * No verbose backtrace by `db:drop` when database does not exist.
1006
+
1007
+ Fixes #16295.
1008
+
1009
+ *Kenn Ejima*
1010
+
1011
+ * Add support for PostgreSQL JSONB.
1012
+
1013
+ Example:
1014
+
1015
+ create_table :posts do |t|
1016
+ t.jsonb :meta_data
1017
+ end
1018
+
1019
+ *Philippe Creux*, *Chris Teague*
1020
+
1021
+ * `db:purge` with MySQL respects `Rails.env`.
1022
+
1023
+ *Yves Senn*
1024
+
1025
+ * `change_column_default :table, :column, nil` with PostgreSQL will issue a
1026
+ `DROP DEFAULT` instead of a `DEFAULT NULL` query.
1027
+
1028
+ Fixes #16261.
1029
+
1030
+ *Matthew Draper*, *Yves Senn*
1031
+
1032
+ * Allow to specify a type for the foreign key column in `references`
1033
+ and `add_reference`.
1034
+
1035
+ Example:
1036
+
1037
+ change_table :vehicle do |t|
1038
+ t.references :station, type: :uuid
1039
+ end
1040
+
1041
+ *Andrey Novikov*, *Łukasz Sarnacki*
1042
+
1043
+ * `create_join_table` removes a common prefix when generating the join table.
1044
+ This matches the existing behavior of HABTM associations.
1045
+
1046
+ Fixes #13683.
1047
+
1048
+ *Stefan Kanev*
1049
+
1050
+ * Do not swallow errors on `compute_type` when having a bad `alias_method` on
1051
+ a class.
1052
+
1053
+ *arthurnn*
1054
+
1055
+ * PostgreSQL invalid `uuid` are convert to nil.
4
1056
 
5
- ## Rails 3.1.9
1057
+ *Abdelkader Boudih*
6
1058
 
7
- * CVE-2012-5664 ensure that options are never taken from the first parameter
1059
+ * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
8
1060
 
9
- ## Rails 3.1.8 (Aug 9, 2012)
1061
+ With 4.1.x, `serialize` started returning a string when `JSON` was passed as
1062
+ the second attribute. It will now return a hash as per previous versions.
10
1063
 
11
- * No changes.
1064
+ Example:
12
1065
 
13
- ## Rails 3.1.7 (Jul 26, 2012)
1066
+ class Post < ActiveRecord::Base
1067
+ serialize :comment, JSON
1068
+ end
14
1069
 
15
- * No changes.
1070
+ class Comment
1071
+ include ActiveModel::Model
1072
+ attr_accessor :category, :text
1073
+ end
16
1074
 
17
- ## Rails 3.1.6 (Jun 12, 2012)
1075
+ post = Post.create!
1076
+ post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
1077
+ post.save!
18
1078
 
19
- * protect against the nesting of hashes changing the
20
- table context in the next call to build_from_hash. This fix
21
- covers this case as well.
1079
+ # 4.0
1080
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
22
1081
 
23
- CVE-2012-2695
1082
+ # 4.1 before
1083
+ post.comment # => "#<Comment:0x007f80ab48ff98>"
24
1084
 
25
- ## Rails 3.1.5 (May 31, 2012) ##
1085
+ # 4.1 after
1086
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
26
1087
 
27
- * Fix type_to_sql with text and limit on mysql/mysql2. Fix GH #3931.
1088
+ When using `JSON` as the coder in `serialize`, Active Record will use the
1089
+ new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
1090
+ `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
1091
+ correctly using the `#as_json` hook.
28
1092
 
29
- * only log an error if there is a logger. fixes #5226
1093
+ To keep the previous behaviour, supply a custom coder instead
1094
+ ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
30
1095
 
31
- * fix activerecord query_method regression with offset into Fixnum
1096
+ Fixes #15594.
32
1097
 
33
- * predicate builder should not recurse for determining where columns.
34
- Thanks to Ben Murphy for reporting this! CVE-2012-2661
1098
+ *Jenn Cooper*
35
1099
 
36
- ## Rails 3.1.4 (unreleased) ##
1100
+ * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
37
1101
 
38
- * Fix a custom primary key regression *GH 3987*
1102
+ Fixes #15931.
39
1103
 
40
- *Jon Leighton*
1104
+ *Jeff Browning*
41
1105
 
42
- * Perf fix (second try): don't load records for `has many :dependent =>
43
- :delete_all` *GH 3672*
1106
+ * Calling `#empty?` on a `has_many` association would use the value from the
1107
+ counter cache if one exists.
44
1108
 
45
- *Jon Leighton*
1109
+ *David Verhasselt*
46
1110
 
47
- * Fix accessing `proxy_association` method from an association extension
48
- where the calls are chained. *GH #3890*
1111
+ * Fix the schema dump generated for tables without constraints and with
1112
+ primary key with default value of custom PostgreSQL function result.
49
1113
 
50
- (E.g. `post.comments.where(bla).my_proxy_method`)
1114
+ Fixes #16111.
51
1115
 
52
- *Jon Leighton*
1116
+ *Andrey Novikov*
53
1117
 
54
- * Perf fix: MySQL primary key lookup was still slow for very large
55
- tables. *GH 3678*
1118
+ * Fix the SQL generated when a `delete_all` is run on an association to not
1119
+ produce an `IN` statements.
56
1120
 
57
- *Kenny J*
1121
+ Before:
58
1122
 
59
- * Perf fix: If a table has no primary key, don't repeatedly ask the database for it.
1123
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1124
+ "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
60
1125
 
61
- *Julius de Bruijn*
1126
+ After:
62
1127
 
63
- ## Rails 3.1.3 (unreleased) ##
1128
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1129
+ "categorizations"."category_id" = 1
64
1130
 
65
- * Perf fix: If we're deleting all records in an association, don't add a IN(..) clause
66
- to the query. *GH 3672*
1131
+ *Eileen M. Uchitelle, Aaron Patterson*
67
1132
 
68
- *Jon Leighton*
1133
+ * Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
1134
+ values for string columns. Otherwise, in some database, the string column
1135
+ values will be coerced to a numeric allowing false or 0.seconds match any
1136
+ string starting with a non-digit.
69
1137
 
70
- * Fix bug with referencing other mysql databases in set_table_name. *GH 3690*
1138
+ Example:
71
1139
 
72
- * Fix performance bug with mysql databases on a server with lots of other databses. *GH 3678*
1140
+ App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
73
1141
 
74
- *Christos Zisopoulos and Kenny J*
1142
+ *Dylan Thacker-Smith*
75
1143
 
76
- ## Rails 3.1.2 (unreleased) ##
1144
+ * Add a `:required` option to singular associations, providing a nicer
1145
+ API for presence validations on associations.
77
1146
 
78
- * Fix problem with prepared statements and PostgreSQL when multiple schemas are used.
79
- *GH #3232*
1147
+ *Sean Griffin*
80
1148
 
81
- *Juan M. Cuello*
1149
+ * Fix an error in `reset_counters` when associations have `select` scope.
1150
+ (Call to `count` generated invalid SQL.)
82
1151
 
83
- * Fix bug with PostgreSQLAdapter#indexes. When the search path has multiple schemas, spaces
84
- were not being stripped from the schema names after the first.
1152
+ *Cade Truitt*
85
1153
 
86
- *Sean Kirby*
1154
+ * After a successful `reload`, `new_record?` is always false.
87
1155
 
88
- * Preserve SELECT columns on the COUNT for finder_sql when possible. *GH 3503*
1156
+ Fixes #12101.
89
1157
 
90
- *Justin Mazzi*
1158
+ *Matthew Draper*
91
1159
 
92
- * Reset prepared statement cache when schema changes impact statement results. *GH 3335*
1160
+ * PostgreSQL renaming table doesn't attempt to rename non existent sequences.
93
1161
 
94
- *Aaron Patterson*
1162
+ *Abdelkader Boudih*
95
1163
 
96
- * Postgres: Do not attempt to deallocate a statement if the connection is no longer active.
1164
+ * Move 'dependent: :destroy' handling for `belongs_to`
1165
+ from `before_destroy` to `after_destroy` callback chain
97
1166
 
98
- *Ian Leitch*
1167
+ Fixes #12380.
99
1168
 
100
- * Prevent QueryCache leaking database connections. *GH 3243*
1169
+ *Ivan Antropov*
101
1170
 
102
- *Mark J. Titorenko*
1171
+ * Detect in-place modifications on String attributes.
103
1172
 
104
- * Fix bug where building the conditions of a nested through association could potentially
105
- modify the conditions of the through and/or source association. If you have experienced
106
- bugs with conditions appearing in the wrong queries when using nested through associations,
107
- this probably solves your problems. *GH #3271*
1173
+ Before this change, an attribute modified in-place had to be marked as
1174
+ changed in order for it to be persisted in the database. Now it is no longer
1175
+ required.
108
1176
 
109
- *Jon Leighton*
1177
+ Before:
110
1178
 
111
- * If a record is removed from a has_many :through, all of the join records relating to that
112
- record should also be removed from the through association's target.
1179
+ user = User.first
1180
+ user.name << ' Griffin'
1181
+ user.name_will_change!
1182
+ user.save
1183
+ user.reload.name # => "Sean Griffin"
113
1184
 
114
- *Jon Leighton*
1185
+ After:
115
1186
 
116
- * Fix adding multiple instances of the same record to a has_many :through. *GH #3425*
1187
+ user = User.first
1188
+ user.name << ' Griffin'
1189
+ user.save
1190
+ user.reload.name # => "Sean Griffin"
117
1191
 
118
- *Jon Leighton*
1192
+ *Sean Griffin*
119
1193
 
120
- * Fix creating records in a through association with a polymorphic source type. *GH #3247*
1194
+ * Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
1195
+ is invalid.
121
1196
 
122
- *Jon Leighton*
1197
+ *Bogdan Gusiev*, *Marc Schütz*
123
1198
 
124
- * MySQL: use the information_schema than the describe command when we look for a primary key. *GH #3440*
125
- *Kenny J*
1199
+ * Support for adding and removing foreign keys. Foreign keys are now
1200
+ a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
1201
+ and PostgreSQLAdapter.
126
1202
 
127
- ## Rails 3.1.1 (October 7, 2011) ##
1203
+ Many thanks to *Matthew Higgins* for laying the foundation with his work on
1204
+ [foreigner](https://github.com/matthuhiggins/foreigner).
128
1205
 
129
- * Raise an exception if the primary key of a model in an association is needed
130
- but unknown. Fixes #3207.
1206
+ Example:
131
1207
 
132
- *Jon Leighton*
1208
+ # within your migrations:
1209
+ add_foreign_key :articles, :authors
1210
+ remove_foreign_key :articles, :authors
133
1211
 
134
- * Add deprecation for the preload_associations method. Fixes #3022.
1212
+ *Yves Senn*
135
1213
 
136
- *Jon Leighton*
1214
+ * Fix subtle bugs regarding attribute assignment on models with no primary
1215
+ key. `'id'` will no longer be part of the attributes hash.
137
1216
 
138
- * Don't require a DB connection when loading a model that uses set_primary_key. GH #2807.
1217
+ *Sean Griffin*
139
1218
 
140
- *Jon Leighton*
1219
+ * Deprecate automatic counter caches on `has_many :through`. The behavior was
1220
+ broken and inconsistent.
141
1221
 
142
- * Fix using select() with a habtm association, e.g. Person.friends.select(:name). GH #3030 and
143
- \#2923.
1222
+ *Sean Griffin*
144
1223
 
145
- *Hendy Tanata*
1224
+ * `preload` preserves readonly flag for associations.
146
1225
 
147
- * Fix belongs_to polymorphic with custom primary key on target. GH #3104.
1226
+ See #15853.
148
1227
 
149
- *Jon Leighton*
1228
+ *Yves Senn*
150
1229
 
151
- * CollectionProxy#replace should change the DB records rather than just mutating the array.
152
- Fixes #3020.
1230
+ * Assume numeric types have changed if they were assigned to a value that
1231
+ would fail numericality validation, regardless of the old value. Previously
1232
+ this would only occur if the old value was 0.
153
1233
 
154
- *Jon Leighton*
1234
+ Example:
155
1235
 
156
- * LRU cache in mysql and sqlite are now per-process caches.
1236
+ model = Model.create!(number: 5)
1237
+ model.number = '5wibble'
1238
+ model.number_changed? # => true
157
1239
 
158
- * lib/active_record/connection_adapters/mysql_adapter.rb: LRU cache
159
- keys are per process id.
160
- * lib/active_record/connection_adapters/sqlite_adapter.rb: ditto
1240
+ Fixes #14731.
161
1241
 
162
- *Aaron Patterson*
1242
+ *Sean Griffin*
163
1243
 
164
- * Database adapters use a statement pool for limiting the number of open
165
- prepared statments on the database. The limit defaults to 1000, but can
166
- be adjusted in your database config by changing 'statement_limit'.
1244
+ * `reload` no longer merges with the existing attributes.
1245
+ The attribute hash is fully replaced. The record is put into the same state
1246
+ as it would be with `Model.find(model.id)`.
167
1247
 
168
- * Fix clash between using 'preload', 'joins' or 'eager_load' in a default scope and including the
169
- default scoped model in a nested through association. (GH #2834.) *Jon Leighton*
1248
+ *Sean Griffin*
170
1249
 
171
- * Ensure we are not comparing a string with a symbol in HasManyAssociation#inverse_updates_counter_cache?.
172
- Fixes GH #2755, where a counter cache could be decremented twice as far as it was supposed to be.
1250
+ * The object returned from `select_all` must respond to `column_types`.
1251
+ If this is not the case a `NoMethodError` is raised.
173
1252
 
174
- *Jon Leighton*
1253
+ *Sean Griffin*
175
1254
 
176
- * Don't send any queries to the database when the foreign key of a belongs_to is nil. Fixes
177
- GH #2828. *Georg Friedrich*
1255
+ * Detect in-place modifications of PG array types
178
1256
 
179
- * Fixed find_in_batches method to not include order from default_scope. See GH #2832 *Arun Agrawal*
1257
+ *Sean Griffin*
180
1258
 
181
- * Don't compute table name for abstract classes. Fixes problem with setting the primary key
182
- in an abstract class. See GH #2791. *Akira Matsuda*
1259
+ * Add `bin/rake db:purge` task to empty the current database.
183
1260
 
184
- * Psych errors with poor yaml formatting are proxied. Fixes GH #2645 and
185
- GH #2731
1261
+ *Yves Senn*
186
1262
 
187
- * Use the LIMIT word with the methods #last and #first. Fixes GH #2783 *Damien Mathieu*
1263
+ * Deprecate `serialized_attributes` without replacement.
188
1264
 
189
- ## Rails 3.1.0 (August 30, 2011) ##
1265
+ *Sean Griffin*
190
1266
 
191
- * Add a proxy_association method to association proxies, which can be called by association
192
- extensions to access information about the association. This replaces proxy_owner etc with
193
- proxy_association.owner.
1267
+ * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
1268
+ are part of the URI structure, not the actual host.
194
1269
 
195
- *Jon Leighton*
1270
+ Fixes #15705.
196
1271
 
197
- * Active Record's dynamic finder will now show a deprecation warning if you passing in less number of arguments than what you call in method signature. This behavior will raise ArgumentError in the next version of Rails *Prem Sichanugrist*
1272
+ *Andy Bakun*, *Aaron Stone*
198
1273
 
199
- * Deprecated the AssociationCollection constant. CollectionProxy is now the appropriate constant
200
- to use, though be warned that this is not really a public API.
1274
+ * Ensure both parent IDs are set on join records when both sides of a
1275
+ through association are new.
201
1276
 
202
- This should solve upgrade problems with the will_paginate plugin (and perhaps others). Thanks
203
- Paul Battley for reporting.
1277
+ *Sean Griffin*
204
1278
 
205
- *Jon Leighton*
1279
+ * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
1280
+ Serialized attributes on ActiveRecord models will no longer save when
1281
+ unchanged.
206
1282
 
207
- * ActiveRecord::MacroReflection::AssociationReflection#build_record has a new method signature.
1283
+ Fixes #8328.
208
1284
 
209
- Before: def build_association(*options)
210
- After: def build_association(*options, &block)
1285
+ *Sean Griffin*
211
1286
 
212
- Users who are redefining this method to extend functionality should ensure that the block is
213
- passed through to ActiveRecord::Base#new.
1287
+ * `Pluck` now works when selecting columns from different tables with the same
1288
+ name.
214
1289
 
215
- This change is necessary to fix https://github.com/rails/rails/issues/1842.
1290
+ Fixes #15649.
216
1291
 
217
- A deprecation warning and workaround has been added to 3.1, but authors will need to update
218
- their code for it to work correctly in 3.2.
1292
+ *Sean Griffin*
219
1293
 
220
- *Jon Leighton*
1294
+ * Remove `cache_attributes` and friends. All attributes are cached.
221
1295
 
222
- * AR#pluralize_table_names can be used to singularize/pluralize table name of an individual model:
1296
+ *Sean Griffin*
223
1297
 
224
- class User < ActiveRecord::Base
225
- self.pluralize_table_names = false
226
- end
1298
+ * Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
227
1299
 
228
- Previously this could only be set globally for all models through ActiveRecord::Base.pluralize_table_names. *Guillermo Iguaran*
1300
+ *Akshay Vishnoi*
229
1301
 
230
- * Add block setting of attributes to singular associations:
1302
+ * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
1303
+ `Enumerable#find` does.
231
1304
 
232
- class User < ActiveRecord::Base
233
- has_one :account
234
- end
1305
+ Fixes #15382.
235
1306
 
236
- user.build_account{ |a| a.credit_limit => 100.0 }
1307
+ *James Yang*
237
1308
 
238
- The block is called after the instance has been initialized. *Andrew White*
1309
+ * Make timezone aware attributes work with PostgreSQL array columns.
239
1310
 
240
- * Add ActiveRecord::Base.attribute_names to return a list of attribute names. This will return an empty array if the model is abstract or table does not exists. *Prem Sichanugrist*
1311
+ Fixes #13402.
241
1312
 
242
- * CSV Fixtures are deprecated and support will be removed in Rails 3.2.0
1313
+ *Kuldeep Aggarwal*, *Sean Griffin*
243
1314
 
244
- * AR#new, AR#create, AR#create!, AR#update_attributes and AR#update_attributes! all accept a second hash as option that allows you
245
- to specify which role to consider when assigning attributes. This is built on top of ActiveModel's
246
- new mass assignment capabilities:
1315
+ * `ActiveRecord::SchemaMigration` has no primary key regardless of the
1316
+ `primary_key_prefix_type` configuration.
247
1317
 
248
- class Post < ActiveRecord::Base
249
- attr_accessible :title
250
- attr_accessible :title, :published_at, :as => :admin
251
- end
1318
+ Fixes #15051.
252
1319
 
253
- Post.new(params[:post], :as => :admin)
1320
+ *JoseLuis Torres*, *Yves Senn*
254
1321
 
255
- assign_attributes() with similar API was also added and attributes=(params, guard) was deprecated.
1322
+ * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
256
1323
 
257
- Please note that this changes the method signatures for AR#new, AR#create, AR#create!, AR#update_attributes and AR#update_attributes!. If you have overwritten these methods you should update them accordingly.
1324
+ Fixes #15538.
258
1325
 
259
- *Josh Kalderimis*
1326
+ *Yves Senn*
260
1327
 
261
- * default_scope can take a block, lambda, or any other object which responds to `call` for lazy
262
- evaluation:
1328
+ * Baseclass becomes! subclass.
263
1329
 
264
- default_scope { ... }
265
- default_scope lambda { ... }
266
- default_scope method(:foo)
1330
+ Before this change, a record which changed its STI type, could not be
1331
+ updated.
267
1332
 
268
- This feature was originally implemented by Tim Morgan, but was then removed in favour of
269
- defining a 'default_scope' class method, but has now been added back in by Jon Leighton.
270
- The relevant lighthouse ticket is #1812.
1333
+ Fixes #14785.
271
1334
 
272
- * Default scopes are now evaluated at the latest possible moment, to avoid problems where
273
- scopes would be created which would implicitly contain the default scope, which would then
274
- be impossible to get rid of via Model.unscoped.
1335
+ *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
275
1336
 
276
- Note that this means that if you are inspecting the internal structure of an
277
- ActiveRecord::Relation, it will *not* contain the default scope, though the resulting
278
- query will do. You can get a relation containing the default scope by calling
279
- ActiveRecord#with_default_scope, though this is not part of the public API.
1337
+ * Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
1338
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
280
1339
 
281
- *Jon Leighton*
1340
+ *Akshay Vishnoi*
282
1341
 
283
- * If you wish to merge default scopes in special ways, it is recommended to define your default
284
- scope as a class method and use the standard techniques for sharing code (inheritance, mixins,
285
- etc.):
1342
+ * Fix regression on eager loading association based on SQL query rather than
1343
+ existing column.
286
1344
 
287
- class Post < ActiveRecord::Base
288
- def self.default_scope
289
- where(:published => true).where(:hidden => false)
290
- end
291
- end
1345
+ Fixes #15480.
292
1346
 
293
- *Jon Leighton*
1347
+ *Lauro Caetano*, *Carlos Antonio da Silva*
294
1348
 
295
- * PostgreSQL adapter only supports PostgreSQL version 8.2 and higher.
1349
+ * Deprecate returning `nil` from `column_for_attribute` when no column exists.
1350
+ It will return a null object in Rails 5.0
296
1351
 
297
- * ConnectionManagement middleware is changed to clean up the connection pool
298
- after the rack body has been flushed.
1352
+ *Sean Griffin*
299
1353
 
300
- * Added an update_column method on ActiveRecord. This new method updates a given attribute on an object, skipping validations and callbacks.
301
- It is recommended to use #update_attribute unless you are sure you do not want to execute any callback, including the modification of
302
- the updated_at column. It should not be called on new records.
303
- Example:
1354
+ * Implemented `ActiveRecord::Base#pretty_print` to work with PP.
304
1355
 
305
- User.first.update_column(:name, "sebastian") # => true
1356
+ *Ethan*
306
1357
 
307
- *Sebastian Martinez*
1358
+ * Preserve type when dumping PostgreSQL point, bit, bit varying and money
1359
+ columns.
308
1360
 
309
- * Associations with a :through option can now use *any* association as the
310
- through or source association, including other associations which have a
311
- :through option and has_and_belongs_to_many associations
1361
+ *Yves Senn*
312
1362
 
313
- *Jon Leighton*
1363
+ * New records remain new after YAML serialization.
314
1364
 
315
- * The configuration for the current database connection is now accessible via
316
- ActiveRecord::Base.connection_config. *fxn*
1365
+ *Sean Griffin*
317
1366
 
318
- * limits and offsets are removed from COUNT queries unless both are supplied.
319
- For example:
1367
+ * PostgreSQL support default values for enum types. Fixes #7814.
320
1368
 
321
- People.limit(1).count # => 'SELECT COUNT(*) FROM people'
322
- People.offset(1).count # => 'SELECT COUNT(*) FROM people'
323
- People.limit(1).offset(1).count # => 'SELECT COUNT(*) FROM people LIMIT 1 OFFSET 1'
1369
+ *Yves Senn*
324
1370
 
325
- *lighthouse #6262*
1371
+ * PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
326
1372
 
327
- * ActiveRecord::Associations::AssociationProxy has been split. There is now an Association class
328
- (and subclasses) which are responsible for operating on associations, and then a separate,
329
- thin wrapper called CollectionProxy, which proxies collection associations.
1373
+ *Yves Senn*
330
1374
 
331
- This prevents namespace pollution, separates concerns, and will allow further refactorings.
1375
+ * Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
1376
+ with orders without sort direction modifiers.
332
1377
 
333
- Singular associations (has_one, belongs_to) no longer have a proxy at all. They simply return
334
- the associated record or nil. This means that you should not use undocumented methods such
335
- as bob.mother.create - use bob.create_mother instead.
1378
+ *Nikolay Kondratyev*
336
1379
 
337
- *Jon Leighton*
1380
+ * PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
338
1381
 
339
- * Make has_many :through associations work correctly when you build a record and then save it. This
340
- requires you to set the :inverse_of option on the source reflection on the join model, like so:
1382
+ *Yves Senn*
341
1383
 
342
- class Post < ActiveRecord::Base
343
- has_many :taggings
344
- has_many :tags, :through => :taggings
345
- end
1384
+ * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
1385
+ Fixes duplication in combination with `store_accessor`.
346
1386
 
347
- class Tagging < ActiveRecord::Base
348
- belongs_to :post
349
- belongs_to :tag, :inverse_of => :tagging # :inverse_of must be set!
350
- end
1387
+ Fixes #15369.
351
1388
 
352
- class Tag < ActiveRecord::Base
353
- has_many :taggings
354
- has_many :posts, :through => :taggings
355
- end
1389
+ *Yves Senn*
356
1390
 
357
- post = Post.first
358
- tag = post.tags.build :name => "ruby"
359
- tag.save # will save a Taggable linking to the post
1391
+ * `rake railties:install:migrations` respects the order of railties.
360
1392
 
361
- *Jon Leighton*
1393
+ *Arun Agrawal*
362
1394
 
363
- * Support the :dependent option on has_many :through associations. For historical and practical
364
- reasons, :delete_all is the default deletion strategy employed by association.delete(*records),
365
- despite the fact that the default strategy is :nullify for regular has_many. Also, this only
366
- works at all if the source reflection is a belongs_to. For other situations, you should directly
367
- modify the through association.
1395
+ * Fix redefine a `has_and_belongs_to_many` inside inherited class
1396
+ Fixing regression case, where redefining the same `has_and_belongs_to_many`
1397
+ definition into a subclass would raise.
368
1398
 
369
- *Jon Leighton*
1399
+ Fixes #14983.
370
1400
 
371
- * Changed the behaviour of association.destroy for has_and_belongs_to_many and has_many :through.
372
- From now on, 'destroy' or 'delete' on an association will be taken to mean 'get rid of the link',
373
- not (necessarily) 'get rid of the associated records'.
1401
+ *arthurnn*
374
1402
 
375
- Previously, has_and_belongs_to_many.destroy(*records) would destroy the records themselves. It
376
- would not delete any records in the join table. Now, it deletes the records in the join table.
1403
+ * Fix `has_and_belongs_to_many` public reflection.
1404
+ When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
1405
+ But as `reflections` is a public API, people expect to see the right macro.
377
1406
 
378
- Previously, has_many_through.destroy(*records) would destroy the records themselves, and the
379
- records in the join table. [Note: This has not always been the case; previous version of Rails
380
- only deleted the records themselves.] Now, it destroys only the records in the join table.
1407
+ Fixes #14682.
381
1408
 
382
- Note that this change is backwards-incompatible to an extent, but there is unfortunately no
383
- way to 'deprecate' it before changing it. The change is being made in order to have
384
- consistency as to the meaning of 'destroy' or 'delete' across the different types of associations.
1409
+ *arthurnn*
385
1410
 
386
- If you wish to destroy the records themselves, you can do records.association.each(&:destroy)
1411
+ * Fix serialization for records with an attribute named `format`.
387
1412
 
388
- *Jon Leighton*
1413
+ Fixes #15188.
389
1414
 
390
- * Add :bulk => true option to change_table to make all the schema changes defined in change_table block using a single ALTER statement. *Pratik Naik*
1415
+ *Godfrey Chan*
391
1416
 
392
- Example:
1417
+ * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
1418
+ on a NullRelation should return a Hash.
1419
+
1420
+ *Kuldeep Aggarwal*
1421
+
1422
+ * Fix serialized fields returning serialized data after being updated with
1423
+ `update_column`.
1424
+
1425
+ *Simon Hørup Eskildsen*
1426
+
1427
+ * Fix polymorphic eager loading when using a String as foreign key.
1428
+
1429
+ Fixes #14734.
1430
+
1431
+ *Lauro Caetano*
1432
+
1433
+ * Change belongs_to touch to be consistent with timestamp updates
1434
+
1435
+ If a model is set up with a belongs_to: touch relationship the parent
1436
+ record will only be touched if the record was modified. This makes it
1437
+ consistent with timestamp updating on the record itself.
393
1438
 
394
- change_table(:users, :bulk => true) do |t|
395
- t.string :company_name
396
- t.change :birthdate, :datetime
397
- end
1439
+ *Brock Trappitt*
398
1440
 
399
- This will now result in:
1441
+ * Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
1442
+ table inside a schema.
400
1443
 
401
- ALTER TABLE `users` ADD COLUMN `company_name` varchar(255), CHANGE `updated_at` `updated_at` datetime DEFAULT NULL
1444
+ Fixes #14824.
402
1445
 
403
- * Removed support for accessing attributes on a has_and_belongs_to_many join table. This has been
404
- documented as deprecated behaviour since April 2006. Please use has_many :through instead.
405
- *Jon Leighton*
1446
+ *Eric Chahin*
406
1447
 
407
- * Added a create_association! method for has_one and belongs_to associations. *Jon Leighton*
1448
+ * Remove unused `:timestamp` type. Transparently alias it to `:datetime`
1449
+ in all cases. Fixes inconsistencies when column types are sent outside of
1450
+ `ActiveRecord`, such as for XML Serialization.
408
1451
 
409
- * Migration files generated from model and constructive migration generators
410
- (for example, add_name_to_users) use the reversible migration's `change`
411
- method instead of the ordinary `up` and `down` methods. *Prem Sichanugrist*
1452
+ *Sean Griffin*
412
1453
 
413
- * Removed support for interpolating string SQL conditions on associations. Instead, you should
414
- use a proc, like so:
1454
+ * Fix bug that added `table_name_prefix` and `table_name_suffix` to
1455
+ extension names in PostgreSQL when migrating.
1456
+
1457
+ *Joao Carlos*
1458
+
1459
+ * The `:index` option in migrations, which previously was only available for
1460
+ `references`, now works with any column types.
1461
+
1462
+ *Marc Schütz*
1463
+
1464
+ * Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
1465
+
1466
+ *jnormore*
1467
+
1468
+ * Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
1469
+ or `offset`.
1470
+
1471
+ In these cases the generated query ignored them and that caused unintended
1472
+ records to be deleted.
1473
+
1474
+ Fixes #11985.
1475
+
1476
+ *Leandro Facchinetti*
1477
+
1478
+ * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
1479
+ their limit dropped from the schema.
1480
+
1481
+ Fixes #14135.
1482
+
1483
+ *Aaron Nelson*
1484
+
1485
+ * Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
1486
+ association.
1487
+
1488
+ Fixes #14709.
1489
+
1490
+ *Kassio Borges*
1491
+
1492
+ * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
1493
+ strings in column names as equal.
1494
+
1495
+ This fixes a rare case in which more bind values are passed than there are
1496
+ placeholders for them in the generated SQL statement, which can make PostgreSQL
1497
+ throw a `StatementInvalid` exception.
1498
+
1499
+ *Nat Budin*
1500
+
1501
+ * Fix `stored_attributes` to correctly merge the details of stored
1502
+ attributes defined in parent classes.
1503
+
1504
+ Fixes #14672.
1505
+
1506
+ *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
1507
+
1508
+ * `change_column_default` allows `[]` as argument to `change_column_default`.
1509
+
1510
+ Fixes #11586.
1511
+
1512
+ *Yves Senn*
1513
+
1514
+ * Handle `name` and `"char"` column types in the PostgreSQL adapter.
1515
+
1516
+ `name` and `"char"` are special character types used internally by
1517
+ PostgreSQL and are used by internal system catalogs. These field types
1518
+ can sometimes show up in structure-sniffing queries that feature internal system
1519
+ structures or with certain PostgreSQL extensions.
1520
+
1521
+ *J Smith*, *Yves Senn*
1522
+
1523
+ * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
1524
+ NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
415
1525
 
416
1526
  Before:
417
1527
 
418
- has_many :things, :conditions => 'foo = #{bar}'
1528
+ Point.create(value: 1.0/0)
1529
+ Point.last.value # => 0.0
419
1530
 
420
1531
  After:
421
1532
 
422
- has_many :things, :conditions => proc { "foo = #{bar}" }
1533
+ Point.create(value: 1.0/0)
1534
+ Point.last.value # => Infinity
423
1535
 
424
- Inside the proc, 'self' is the object which is the owner of the association, unless you are
425
- eager loading the association, in which case 'self' is the class which the association is within.
1536
+ *Innokenty Mikhailov*
426
1537
 
427
- You can have any "normal" conditions inside the proc, so the following will work too:
1538
+ * Allow the PostgreSQL adapter to handle bigserial primary key types again.
428
1539
 
429
- has_many :things, :conditions => proc { ["foo = ?", bar] }
1540
+ Fixes #10410.
430
1541
 
431
- Previously :insert_sql and :delete_sql on has_and_belongs_to_many association allowed you to call
432
- 'record' to get the record being inserted or deleted. This is now passed as an argument to
433
- the proc.
1542
+ *Patrick Robertson*
434
1543
 
435
- * Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with BCrypt encryption and salting [DHH]. Example:
1544
+ * Deprecate joining, eager loading and preloading of instance dependent
1545
+ associations without replacement. These operations happen before instances
1546
+ are created. The current behavior is unexpected and can result in broken
1547
+ behavior.
436
1548
 
437
- # Schema: User(name:string, password_digest:string, password_salt:string)
438
- class User < ActiveRecord::Base
439
- has_secure_password
440
- end
1549
+ Fixes #15024.
441
1550
 
442
- user = User.new(:name => "david", :password => "", :password_confirmation => "nomatch")
443
- user.save # => false, password required
444
- user.password = "mUc3m00RsqyRe"
445
- user.save # => false, confirmation doesn't match
446
- user.password_confirmation = "mUc3m00RsqyRe"
447
- user.save # => true
448
- user.authenticate("notright") # => false
449
- user.authenticate("mUc3m00RsqyRe") # => user
450
- User.find_by_name("david").try(:authenticate, "notright") # => nil
451
- User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
452
-
453
-
454
- * When a model is generated add_index is added by default for belongs_to or references columns
455
-
456
- rails g model post user:belongs_to will generate the following:
457
-
458
- class CreatePosts < ActiveRecord::Migration
459
- def change
460
- create_table :posts do |t|
461
- t.belongs_to :user
462
- t.timestamps
463
- end
464
- add_index :posts, :user_id
465
- end
466
- end
1551
+ *Yves Senn*
1552
+
1553
+ * Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
467
1554
 
468
- *Santiago Pastorino*
1555
+ `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
1556
+ size calculation if the collection is not cached or loaded.
469
1557
 
470
- * Setting the id of a belongs_to object will update the reference to the
471
- object. *#2989 state:resolved*
1558
+ Fixes #14913, #14914.
472
1559
 
473
- * ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed
474
- to closer match normal Ruby dup and clone semantics.
1560
+ *Fred Wu*
475
1561
 
476
- * Calling ActiveRecord::Base#clone will result in a shallow copy of the record,
477
- including copying the frozen state. No callbacks will be called.
1562
+ * Return a non zero status when running `rake db:migrate:status` and migration table does
1563
+ not exist.
478
1564
 
479
- * Calling ActiveRecord::Base#dup will duplicate the record, including calling
480
- after initialize hooks. Frozen state will not be copied, and all associations
481
- will be cleared. A duped record will return true for new_record?, have a nil
482
- id field, and is saveable.
1565
+ *Paul B.*
483
1566
 
484
- * Migrations can be defined as reversible, meaning that the migration system
485
- will figure out how to reverse your migration. To use reversible migrations,
486
- just define the "change" method. For example:
1567
+ * Add support for module-level `table_name_suffix` in models.
487
1568
 
488
- class MyMigration < ActiveRecord::Migration
489
- def change
490
- create_table(:horses) do
491
- t.column :content, :text
492
- t.column :remind_at, :datetime
493
- end
1569
+ This makes `table_name_suffix` work the same way as `table_name_prefix` when
1570
+ using namespaced models.
1571
+
1572
+ *Jenner LaFave*
1573
+
1574
+ * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
1575
+
1576
+ In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
1577
+ In 4.0 series it is delegated to `Array#join`.
1578
+
1579
+ *Bogdan Gusiev*
1580
+
1581
+ * Log nil binary column values correctly.
1582
+
1583
+ When an object with a binary column is updated with a nil value
1584
+ in that column, the SQL logger would throw an exception when trying
1585
+ to log that nil value. This only occurs when updating a record
1586
+ that already has a non-nil value in that column since an initial nil
1587
+ value isn't included in the SQL anyway (at least, when dirty checking
1588
+ is enabled.) The column's new value will now be logged as `<NULL binary data>`
1589
+ to parallel the existing `<N bytes of binary data>` for non-nil values.
1590
+
1591
+ *James Coleman*
1592
+
1593
+ * Rails will now pass a custom validation context through to autosave associations
1594
+ in order to validate child associations with the same context.
1595
+
1596
+ Fixes #13854.
1597
+
1598
+ *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
1599
+
1600
+ * Stringify all variables keys of MySQL connection configuration.
1601
+
1602
+ When `sql_mode` variable for MySQL adapters set in configuration as `String`
1603
+ was ignored and overwritten by strict mode option.
1604
+
1605
+ Fixes #14895.
1606
+
1607
+ *Paul Nikitochkin*
1608
+
1609
+ * Ensure SQLite3 statements are closed on errors.
1610
+
1611
+ Fixes #13631.
1612
+
1613
+ *Timur Alperovich*
1614
+
1615
+ * Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
1616
+
1617
+ *Hector Satre*
1618
+
1619
+ * When using a custom `join_table` name on a `habtm`, rails was not saving it
1620
+ on Reflections. This causes a problem when rails loads fixtures, because it
1621
+ uses the reflections to set database with fixtures.
1622
+
1623
+ Fixes #14845.
1624
+
1625
+ *Kassio Borges*
1626
+
1627
+ * Reset the cache when modifying a Relation with cached Arel.
1628
+ Additionally display a warning message to make the user aware.
1629
+
1630
+ *Yves Senn*
1631
+
1632
+ * PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
1633
+ different spellings of timestamps are treated the same.
1634
+
1635
+ Example:
1636
+
1637
+ mytimestamp.simplified_type('timestamp without time zone')
1638
+ # => :datetime
1639
+ mytimestamp.simplified_type('timestamp(6) without time zone')
1640
+ # => also :datetime (previously would be :timestamp)
1641
+
1642
+ See #14513.
1643
+
1644
+ *Jefferson Lai*
1645
+
1646
+ * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
1647
+
1648
+ Fixes #14841.
1649
+
1650
+ *Lucas Mazza*
1651
+
1652
+ * Fix name collision with `Array#select!` with `Relation#select!`.
1653
+
1654
+ Fixes #14752.
1655
+
1656
+ *Earl St Sauver*
1657
+
1658
+ * Fix unexpected behavior for `has_many :through` associations going through
1659
+ a scoped `has_many`.
1660
+
1661
+ If a `has_many` association is adjusted using a scope, and another
1662
+ `has_many :through` uses this association, then the scope adjustment is
1663
+ unexpectedly neglected.
1664
+
1665
+ Fixes #14537.
1666
+
1667
+ *Jan Habermann*
1668
+
1669
+ * `@destroyed` should always be set to `false` when an object is duped.
1670
+
1671
+ *Kuldeep Aggarwal*
1672
+
1673
+ * Enable `has_many` associations to support irregular inflections.
1674
+
1675
+ Fixes #8928.
1676
+
1677
+ *arthurnn*, *Javier Goizueta*
1678
+
1679
+ * Fix `count` used with a grouping not returning a Hash.
1680
+
1681
+ Fixes #14721.
1682
+
1683
+ *Eric Chahin*
1684
+
1685
+ * `sanitize_sql_like` helper method to escape a string for safe use in an SQL
1686
+ LIKE statement.
1687
+
1688
+ Example:
1689
+
1690
+ class Article
1691
+ def self.search(term)
1692
+ where("title LIKE ?", sanitize_sql_like(term))
494
1693
  end
495
1694
  end
496
1695
 
497
- Some things cannot be automatically reversed for you. If you know how to
498
- reverse those things, you should define 'up' and 'down' in your migration. If
499
- you define something in `change` that cannot be reversed, an
500
- IrreversibleMigration exception will be raised when going down.
1696
+ Article.search("20% _reduction_")
1697
+ # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
501
1698
 
502
- * Migrations should use instance methods rather than class methods:
503
- class FooMigration < ActiveRecord::Migration
504
- def up
505
- ...
506
- end
1699
+ *Rob Gilson*, *Yves Senn*
1700
+
1701
+ * Do not quote uuid default value on `change_column`.
1702
+
1703
+ Fixes #14604.
1704
+
1705
+ *Eric Chahin*
1706
+
1707
+ * The comparison between `Relation` and `CollectionProxy` should be consistent.
1708
+
1709
+ Example:
1710
+
1711
+ author.posts == Post.where(author_id: author.id)
1712
+ # => true
1713
+ Post.where(author_id: author.id) == author.posts
1714
+ # => true
1715
+
1716
+ Fixes #13506.
1717
+
1718
+ *Lauro Caetano*
1719
+
1720
+ * Calling `delete_all` on an unloaded `CollectionProxy` no longer
1721
+ generates an SQL statement containing each id of the collection:
1722
+
1723
+ Before:
1724
+
1725
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1726
+ AND `model`.`id` IN (1, 2, 3...)
1727
+
1728
+ After:
1729
+
1730
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1731
+
1732
+ *Eileen M. Uchitelle*, *Aaron Patterson*
1733
+
1734
+ * Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
1735
+ with `select`.
1736
+
1737
+ Fixes #13648.
1738
+
1739
+ *Simon Woker*
1740
+
1741
+ * PostgreSQL adapter only warns once for every missing OID per connection.
1742
+
1743
+ Fixes #14275.
1744
+
1745
+ *Matthew Draper*, *Yves Senn*
1746
+
1747
+ * PostgreSQL adapter automatically reloads it's type map when encountering
1748
+ unknown OIDs.
1749
+
1750
+ Fixes #14678.
1751
+
1752
+ *Matthew Draper*, *Yves Senn*
1753
+
1754
+ * Fix insertion of records via `has_many :through` association with scope.
1755
+
1756
+ Fixes #3548.
1757
+
1758
+ *Ivan Antropov*
1759
+
1760
+ * Auto-generate stable fixture UUIDs on PostgreSQL.
1761
+
1762
+ Fixes #11524.
1763
+
1764
+ *Roderick van Domburg*
1765
+
1766
+ * Fix a problem where an enum would overwrite values of another enum with the
1767
+ same name in an unrelated class.
1768
+
1769
+ Fixes #14607.
1770
+
1771
+ *Evan Whalen*
1772
+
1773
+ * PostgreSQL and SQLite string columns no longer have a default limit of 255.
1774
+
1775
+ Fixes #13435, #9153.
1776
+
1777
+ *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
1778
+
1779
+ * Make possible to have an association called `records`.
1780
+
1781
+ Fixes #11645.
1782
+
1783
+ *prathamesh-sonpatki*
1784
+
1785
+ * `to_sql` on an association now matches the query that is actually executed, where it
1786
+ could previously have incorrectly accrued additional conditions (e.g. as a result of
1787
+ a previous query). `CollectionProxy` now always defers to the association scope's
1788
+ `arel` method so the (incorrect) inherited one should be entirely concealed.
1789
+
1790
+ Fixes #14003.
1791
+
1792
+ *Jefferson Lai*
1793
+
1794
+ * Block a few default Class methods as scope name.
1795
+
1796
+ For instance, this will raise:
1797
+
1798
+ scope :public, -> { where(status: 1) }
1799
+
1800
+ *arthurnn*
1801
+
1802
+ * Fix error when using `with_options` with lambda.
1803
+
1804
+ Fixes #9805.
1805
+
1806
+ *Lauro Caetano*
1807
+
1808
+ * Switch `sqlite3:///` URLs (which were temporarily
1809
+ deprecated in 4.1) from relative to absolute.
1810
+
1811
+ If you still want the previous interpretation, you should replace
1812
+ `sqlite3:///my/path` with `sqlite3:my/path`.
1813
+
1814
+ *Matthew Draper*
1815
+
1816
+ * Treat blank UUID values as `nil`.
1817
+
1818
+ Example:
1819
+
1820
+ Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
1821
+
1822
+ *Dmitry Lavrov*
1823
+
1824
+ * Enable support for materialized views on PostgreSQL >= 9.3.
1825
+
1826
+ *Dave Lee*
1827
+
1828
+ * The PostgreSQL adapter supports custom domains. Fixes #14305.
1829
+
1830
+ *Yves Senn*
1831
+
1832
+ * PostgreSQL `Column#type` is now determined through the corresponding OID.
1833
+ The column types stay the same except for enum columns. They no longer have
1834
+ `nil` as type but `enum`.
1835
+
1836
+ See #7814.
1837
+
1838
+ *Yves Senn*
1839
+
1840
+ * Fix error when specifying a non-empty default value on a PostgreSQL array
1841
+ column.
1842
+
1843
+ Fixes #10613.
1844
+
1845
+ *Luke Steensen*
1846
+
1847
+ * Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
1848
+ custom primary key that did not save due to validation error.
1849
+
1850
+ Fixes #14393.
1851
+
1852
+ *Chris Finne*
1853
+
1854
+ * Introduce `validate` as an alias for `valid?`.
1855
+
1856
+ This is more intuitive when you want to run validations but don't care about the return value.
1857
+
1858
+ *Henrik Nyh*
1859
+
1860
+ * Create indexes inline in CREATE TABLE for MySQL.
1861
+
1862
+ This is important, because adding an index on a temporary table after it has been created
1863
+ would commit the transaction.
1864
+
1865
+ It also allows creating and dropping indexed tables with fewer queries and fewer permissions
1866
+ required.
1867
+
1868
+ Example:
1869
+
1870
+ create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
1871
+ t.index :zip
507
1872
  end
1873
+ # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
508
1874
 
509
- *Aaron Patterson*
1875
+ *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
1876
+
1877
+ * Use singular table name in generated migrations when
1878
+ `ActiveRecord::Base.pluralize_table_names` is `false`.
1879
+
1880
+ Fixes #13426.
1881
+
1882
+ *Kuldeep Aggarwal*
1883
+
1884
+ * `touch` accepts many attributes to be touched at once.
1885
+
1886
+ Example:
1887
+
1888
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
1889
+ Photo.last.touch(:signed_at, :sealed_at)
1890
+
1891
+ *James Pinto*
1892
+
1893
+ * `rake db:structure:dump` only dumps schema information if the schema
1894
+ migration table exists.
510
1895
 
511
- * has_one maintains the association with separate after_create/after_update instead
512
- of a single after_save. *fxn*
1896
+ Fixes #14217.
513
1897
 
514
- * The following code:
1898
+ *Yves Senn*
515
1899
 
516
- Model.limit(10).scoping { Model.count }
1900
+ * Reap connections that were checked out by now-dead threads, instead
1901
+ of waiting until they disconnect by themselves. Before this change,
1902
+ a suitably constructed series of short-lived threads could starve
1903
+ the connection pool, without ever having more than a couple alive at
1904
+ the same time.
517
1905
 
518
- now generates the following SQL:
1906
+ *Matthew Draper*
519
1907
 
520
- SELECT COUNT(*) FROM models LIMIT 10
1908
+ * `pk_and_sequence_for` now ensures that only the pg_depend entries
1909
+ pointing to pg_class, and thus only sequence objects, are considered.
521
1910
 
522
- This may not return what you want. Instead, you may with to do something
523
- like this:
1911
+ *Josh Williams*
524
1912
 
525
- Model.limit(10).scoping { Model.all.size }
1913
+ * `where.not` adds `references` for `includes` like normal `where` calls do.
1914
+
1915
+ Fixes #14406.
1916
+
1917
+ *Yves Senn*
1918
+
1919
+ * Extend fixture `$LABEL` replacement to allow string interpolation.
1920
+
1921
+ Example:
1922
+
1923
+ martin:
1924
+ email: $LABEL@email.com
1925
+
1926
+ users(:martin).email # => martin@email.com
1927
+
1928
+ *Eric Steele*
1929
+
1930
+ * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
1931
+
1932
+ Fixes #14361.
1933
+
1934
+ *arthurnn*
1935
+
1936
+ * Passing an Active Record object to `find` or `exists?` is now deprecated.
1937
+ Call `.id` on the object first.
526
1938
 
527
1939
  *Aaron Patterson*
528
1940
 
529
- Please check [3-0-stable](https://github.com/rails/rails/blob/3-0-stable/activerecord/CHANGELOG) for previous changes.
1941
+ * Only use BINARY for MySQL case sensitive uniqueness check when column
1942
+ has a case insensitive collation.
1943
+
1944
+ *Ryuta Kamizono*
1945
+
1946
+ * Support for MySQL 5.6 fractional seconds.
1947
+
1948
+ *arthurnn*, *Tatsuhiko Miyagawa*
1949
+
1950
+ * Support for PostgreSQL `citext` data type enabling case-insensitive
1951
+ `where` values without needing to wrap in UPPER/LOWER sql functions.
1952
+
1953
+ *Troy Kruthoff*, *Lachlan Sylvester*
1954
+
1955
+ * Only save has_one associations if record has changes.
1956
+ Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
1957
+ object did not get saved to the db.
1958
+
1959
+ *Alan Kennedy*
1960
+
1961
+ * Allow strings to specify the `#order` value.
1962
+
1963
+ Example:
1964
+
1965
+ Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
1966
+
1967
+ *Marcelo Casiraghi*, *Robin Dupret*
1968
+
1969
+ * Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
1970
+ warnings on enum columns.
1971
+
1972
+ *Dieter Komendera*
1973
+
1974
+ * `includes` is able to detect the right preloading strategy when string
1975
+ joins are involved.
1976
+
1977
+ Fixes #14109.
1978
+
1979
+ *Aaron Patterson*, *Yves Senn*
1980
+
1981
+ * Fix error with validation with enum fields for records where the value for
1982
+ any enum attribute is always evaluated as 0 during uniqueness validation.
1983
+
1984
+ Fixes #14172.
1985
+
1986
+ *Vilius Luneckas* *Ahmed AbouElhamayed*
1987
+
1988
+ * `before_add` callbacks are fired before the record is saved on
1989
+ `has_and_belongs_to_many` associations *and* on `has_many :through`
1990
+ associations. Before this change, `before_add` callbacks would be fired
1991
+ before the record was saved on `has_and_belongs_to_many` associations, but
1992
+ *not* on `has_many :through` associations.
1993
+
1994
+ Fixes #14144.
1995
+
1996
+ * Fix STI classes not defining an attribute method if there is a conflicting
1997
+ private method defined on its ancestors.
1998
+
1999
+ Fixes #11569.
2000
+
2001
+ *Godfrey Chan*
2002
+
2003
+ * Coerce strings when reading attributes. Fixes #10485.
2004
+
2005
+ Example:
2006
+
2007
+ book = Book.new(title: 12345)
2008
+ book.save!
2009
+ book.title # => "12345"
2010
+
2011
+ *Yves Senn*
2012
+
2013
+ * Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
2014
+ We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
2015
+ possible because the Ruby range does not support excluded beginnings.
2016
+
2017
+ The current solution of incrementing the beginning is not correct and is now
2018
+ deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
2019
+ is not defined) it will raise an `ArgumentException` for ranges with excluding
2020
+ beginnings.
2021
+
2022
+ *Yves Senn*
2023
+
2024
+ * Support for user created range types in PostgreSQL.
2025
+
2026
+ *Yves Senn*
2027
+
2028
+ Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.