activerecord 4.2.11.2 → 6.0.0

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