activerecord 4.2.9 → 5.2.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

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