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