activerecord 5.1.0 → 5.2.3

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 (261) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +596 -450
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +5 -5
  5. data/examples/performance.rb +2 -0
  6. data/examples/simple.rb +2 -0
  7. data/lib/active_record.rb +11 -4
  8. data/lib/active_record/aggregations.rb +6 -5
  9. data/lib/active_record/association_relation.rb +7 -5
  10. data/lib/active_record/associations.rb +77 -85
  11. data/lib/active_record/associations/alias_tracker.rb +23 -32
  12. data/lib/active_record/associations/association.rb +49 -35
  13. data/lib/active_record/associations/association_scope.rb +55 -55
  14. data/lib/active_record/associations/belongs_to_association.rb +30 -11
  15. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -8
  16. data/lib/active_record/associations/builder/association.rb +4 -7
  17. data/lib/active_record/associations/builder/belongs_to.rb +21 -8
  18. data/lib/active_record/associations/builder/collection_association.rb +1 -1
  19. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +3 -1
  20. data/lib/active_record/associations/builder/has_many.rb +2 -0
  21. data/lib/active_record/associations/builder/has_one.rb +2 -0
  22. data/lib/active_record/associations/builder/singular_association.rb +2 -0
  23. data/lib/active_record/associations/collection_association.rb +66 -53
  24. data/lib/active_record/associations/collection_proxy.rb +30 -73
  25. data/lib/active_record/associations/foreign_association.rb +2 -0
  26. data/lib/active_record/associations/has_many_association.rb +13 -2
  27. data/lib/active_record/associations/has_many_through_association.rb +37 -19
  28. data/lib/active_record/associations/has_one_association.rb +14 -1
  29. data/lib/active_record/associations/has_one_through_association.rb +13 -8
  30. data/lib/active_record/associations/join_dependency.rb +52 -96
  31. data/lib/active_record/associations/join_dependency/join_association.rb +22 -75
  32. data/lib/active_record/associations/join_dependency/join_base.rb +9 -8
  33. data/lib/active_record/associations/join_dependency/join_part.rb +9 -9
  34. data/lib/active_record/associations/preloader.rb +17 -37
  35. data/lib/active_record/associations/preloader/association.rb +53 -92
  36. data/lib/active_record/associations/preloader/through_association.rb +72 -73
  37. data/lib/active_record/associations/singular_association.rb +14 -16
  38. data/lib/active_record/associations/through_association.rb +27 -12
  39. data/lib/active_record/attribute_assignment.rb +2 -5
  40. data/lib/active_record/attribute_decorators.rb +3 -2
  41. data/lib/active_record/attribute_methods.rb +65 -24
  42. data/lib/active_record/attribute_methods/before_type_cast.rb +2 -0
  43. data/lib/active_record/attribute_methods/dirty.rb +33 -216
  44. data/lib/active_record/attribute_methods/primary_key.rb +10 -13
  45. data/lib/active_record/attribute_methods/query.rb +2 -0
  46. data/lib/active_record/attribute_methods/read.rb +9 -3
  47. data/lib/active_record/attribute_methods/serialization.rb +23 -0
  48. data/lib/active_record/attribute_methods/time_zone_conversion.rb +6 -8
  49. data/lib/active_record/attribute_methods/write.rb +22 -19
  50. data/lib/active_record/attributes.rb +7 -6
  51. data/lib/active_record/autosave_association.rb +15 -13
  52. data/lib/active_record/base.rb +2 -0
  53. data/lib/active_record/callbacks.rb +12 -6
  54. data/lib/active_record/coders/json.rb +2 -0
  55. data/lib/active_record/coders/yaml_column.rb +2 -0
  56. data/lib/active_record/collection_cache_key.rb +15 -11
  57. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +120 -39
  58. data/lib/active_record/connection_adapters/abstract/database_limits.rb +7 -0
  59. data/lib/active_record/connection_adapters/abstract/database_statements.rb +192 -37
  60. data/lib/active_record/connection_adapters/abstract/query_cache.rb +13 -2
  61. data/lib/active_record/connection_adapters/abstract/quoting.rb +15 -25
  62. data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
  63. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +15 -6
  64. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +65 -7
  65. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +31 -53
  66. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +158 -87
  67. data/lib/active_record/connection_adapters/abstract/transaction.rb +66 -21
  68. data/lib/active_record/connection_adapters/abstract_adapter.rb +86 -98
  69. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +126 -189
  70. data/lib/active_record/connection_adapters/column.rb +4 -2
  71. data/lib/active_record/connection_adapters/connection_specification.rb +17 -3
  72. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +13 -2
  73. data/lib/active_record/connection_adapters/mysql/column.rb +2 -0
  74. data/lib/active_record/connection_adapters/mysql/database_statements.rb +45 -15
  75. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +2 -0
  76. data/lib/active_record/connection_adapters/mysql/quoting.rb +9 -10
  77. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +5 -3
  78. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +7 -10
  79. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +30 -23
  80. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +106 -1
  81. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +2 -0
  82. data/lib/active_record/connection_adapters/mysql2_adapter.rb +8 -2
  83. data/lib/active_record/connection_adapters/postgresql/column.rb +30 -1
  84. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -32
  85. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +2 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid.rb +3 -1
  87. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +13 -1
  88. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -0
  89. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
  90. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
  91. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +2 -0
  92. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
  93. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +2 -0
  94. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
  95. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +2 -0
  96. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +2 -0
  97. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
  98. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -11
  99. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -0
  100. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +3 -1
  101. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +2 -0
  102. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -0
  103. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +8 -2
  104. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -0
  105. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +4 -2
  106. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +3 -1
  107. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
  108. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
  109. data/lib/active_record/connection_adapters/postgresql/quoting.rb +22 -1
  110. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +19 -25
  111. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +50 -0
  112. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +24 -11
  113. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +20 -13
  114. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +258 -129
  115. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -0
  116. data/lib/active_record/connection_adapters/postgresql/utils.rb +3 -1
  117. data/lib/active_record/connection_adapters/postgresql_adapter.rb +75 -87
  118. data/lib/active_record/connection_adapters/schema_cache.rb +4 -2
  119. data/lib/active_record/connection_adapters/sql_type_metadata.rb +2 -0
  120. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +2 -0
  121. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +24 -1
  122. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +2 -0
  123. data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -15
  124. data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +3 -2
  125. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +75 -1
  126. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +90 -96
  127. data/lib/active_record/connection_adapters/statement_pool.rb +2 -0
  128. data/lib/active_record/connection_handling.rb +4 -2
  129. data/lib/active_record/core.rb +41 -61
  130. data/lib/active_record/counter_cache.rb +20 -15
  131. data/lib/active_record/define_callbacks.rb +5 -3
  132. data/lib/active_record/dynamic_matchers.rb +9 -9
  133. data/lib/active_record/enum.rb +18 -13
  134. data/lib/active_record/errors.rb +60 -15
  135. data/lib/active_record/explain.rb +3 -1
  136. data/lib/active_record/explain_registry.rb +2 -0
  137. data/lib/active_record/explain_subscriber.rb +2 -0
  138. data/lib/active_record/fixture_set/file.rb +2 -0
  139. data/lib/active_record/fixtures.rb +67 -60
  140. data/lib/active_record/gem_version.rb +4 -2
  141. data/lib/active_record/inheritance.rb +49 -19
  142. data/lib/active_record/integration.rb +58 -19
  143. data/lib/active_record/internal_metadata.rb +2 -0
  144. data/lib/active_record/legacy_yaml_adapter.rb +3 -1
  145. data/lib/active_record/locking/optimistic.rb +30 -42
  146. data/lib/active_record/locking/pessimistic.rb +10 -7
  147. data/lib/active_record/log_subscriber.rb +46 -4
  148. data/lib/active_record/migration.rb +189 -139
  149. data/lib/active_record/migration/command_recorder.rb +11 -9
  150. data/lib/active_record/migration/compatibility.rb +81 -29
  151. data/lib/active_record/migration/join_table.rb +2 -0
  152. data/lib/active_record/model_schema.rb +74 -58
  153. data/lib/active_record/nested_attributes.rb +18 -6
  154. data/lib/active_record/no_touching.rb +3 -1
  155. data/lib/active_record/null_relation.rb +2 -0
  156. data/lib/active_record/persistence.rb +199 -54
  157. data/lib/active_record/query_cache.rb +8 -10
  158. data/lib/active_record/querying.rb +5 -3
  159. data/lib/active_record/railtie.rb +62 -6
  160. data/lib/active_record/railties/console_sandbox.rb +2 -0
  161. data/lib/active_record/railties/controller_runtime.rb +2 -0
  162. data/lib/active_record/railties/databases.rake +48 -38
  163. data/lib/active_record/readonly_attributes.rb +3 -2
  164. data/lib/active_record/reflection.rb +137 -207
  165. data/lib/active_record/relation.rb +132 -207
  166. data/lib/active_record/relation/batches.rb +32 -17
  167. data/lib/active_record/relation/batches/batch_enumerator.rb +2 -0
  168. data/lib/active_record/relation/calculations.rb +66 -25
  169. data/lib/active_record/relation/delegation.rb +45 -29
  170. data/lib/active_record/relation/finder_methods.rb +76 -85
  171. data/lib/active_record/relation/from_clause.rb +2 -8
  172. data/lib/active_record/relation/merger.rb +53 -23
  173. data/lib/active_record/relation/predicate_builder.rb +60 -79
  174. data/lib/active_record/relation/predicate_builder/array_handler.rb +10 -7
  175. data/lib/active_record/relation/predicate_builder/association_query_value.rb +46 -0
  176. data/lib/active_record/relation/predicate_builder/base_handler.rb +2 -2
  177. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +12 -1
  178. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +56 -0
  179. data/lib/active_record/relation/predicate_builder/range_handler.rb +26 -9
  180. data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
  181. data/lib/active_record/relation/query_attribute.rb +28 -2
  182. data/lib/active_record/relation/query_methods.rb +135 -103
  183. data/lib/active_record/relation/record_fetch_warning.rb +2 -0
  184. data/lib/active_record/relation/spawn_methods.rb +4 -2
  185. data/lib/active_record/relation/where_clause.rb +65 -67
  186. data/lib/active_record/relation/where_clause_factory.rb +5 -48
  187. data/lib/active_record/result.rb +2 -0
  188. data/lib/active_record/runtime_registry.rb +2 -0
  189. data/lib/active_record/sanitization.rb +129 -121
  190. data/lib/active_record/schema.rb +4 -2
  191. data/lib/active_record/schema_dumper.rb +36 -26
  192. data/lib/active_record/schema_migration.rb +2 -0
  193. data/lib/active_record/scoping.rb +12 -10
  194. data/lib/active_record/scoping/default.rb +10 -7
  195. data/lib/active_record/scoping/named.rb +40 -12
  196. data/lib/active_record/secure_token.rb +2 -0
  197. data/lib/active_record/serialization.rb +2 -0
  198. data/lib/active_record/statement_cache.rb +22 -12
  199. data/lib/active_record/store.rb +3 -1
  200. data/lib/active_record/suppressor.rb +2 -0
  201. data/lib/active_record/table_metadata.rb +12 -3
  202. data/lib/active_record/tasks/database_tasks.rb +38 -26
  203. data/lib/active_record/tasks/mysql_database_tasks.rb +11 -50
  204. data/lib/active_record/tasks/postgresql_database_tasks.rb +11 -3
  205. data/lib/active_record/tasks/sqlite_database_tasks.rb +25 -3
  206. data/lib/active_record/timestamp.rb +13 -6
  207. data/lib/active_record/touch_later.rb +2 -0
  208. data/lib/active_record/transactions.rb +32 -27
  209. data/lib/active_record/translation.rb +2 -0
  210. data/lib/active_record/type.rb +4 -1
  211. data/lib/active_record/type/adapter_specific_registry.rb +2 -0
  212. data/lib/active_record/type/date.rb +2 -0
  213. data/lib/active_record/type/date_time.rb +2 -0
  214. data/lib/active_record/type/decimal_without_scale.rb +2 -0
  215. data/lib/active_record/type/hash_lookup_type_map.rb +2 -0
  216. data/lib/active_record/type/internal/timezone.rb +2 -0
  217. data/lib/active_record/type/json.rb +30 -0
  218. data/lib/active_record/type/serialized.rb +6 -0
  219. data/lib/active_record/type/text.rb +2 -0
  220. data/lib/active_record/type/time.rb +2 -0
  221. data/lib/active_record/type/type_map.rb +2 -0
  222. data/lib/active_record/type/unsigned_integer.rb +2 -0
  223. data/lib/active_record/type_caster.rb +2 -0
  224. data/lib/active_record/type_caster/connection.rb +2 -0
  225. data/lib/active_record/type_caster/map.rb +3 -1
  226. data/lib/active_record/validations.rb +2 -0
  227. data/lib/active_record/validations/absence.rb +2 -0
  228. data/lib/active_record/validations/associated.rb +2 -0
  229. data/lib/active_record/validations/length.rb +2 -0
  230. data/lib/active_record/validations/presence.rb +2 -0
  231. data/lib/active_record/validations/uniqueness.rb +36 -6
  232. data/lib/active_record/version.rb +2 -0
  233. data/lib/rails/generators/active_record.rb +3 -1
  234. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
  235. data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
  236. data/lib/rails/generators/active_record/migration.rb +2 -0
  237. data/lib/rails/generators/active_record/migration/migration_generator.rb +3 -1
  238. data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +0 -0
  239. data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +0 -0
  240. data/lib/rails/generators/active_record/model/model_generator.rb +2 -23
  241. data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +0 -0
  242. data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
  243. metadata +24 -36
  244. data/lib/active_record/associations/preloader/belongs_to.rb +0 -15
  245. data/lib/active_record/associations/preloader/collection_association.rb +0 -17
  246. data/lib/active_record/associations/preloader/has_many.rb +0 -15
  247. data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
  248. data/lib/active_record/associations/preloader/has_one.rb +0 -15
  249. data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
  250. data/lib/active_record/associations/preloader/singular_association.rb +0 -18
  251. data/lib/active_record/attribute.rb +0 -240
  252. data/lib/active_record/attribute/user_provided_default.rb +0 -30
  253. data/lib/active_record/attribute_mutation_tracker.rb +0 -113
  254. data/lib/active_record/attribute_set.rb +0 -113
  255. data/lib/active_record/attribute_set/builder.rb +0 -124
  256. data/lib/active_record/attribute_set/yaml_encoder.rb +0 -41
  257. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -10
  258. data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
  259. data/lib/active_record/relation/predicate_builder/association_query_handler.rb +0 -88
  260. data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -59
  261. data/lib/active_record/type/internal/abstract_json.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b681beb18e3fb91541c6c1111e35b2a339cc0938
4
- data.tar.gz: 0314f6221b13f28cf656b1d3443588f4d67e7982
2
+ SHA256:
3
+ metadata.gz: 3a6a58445af3e133df097836131d528804585b935b40025174db5e3a284351b5
4
+ data.tar.gz: 4d1b7fbc93cb5582065167d8d8a197ed887133b06170c5acf0ab6a18dea29465
5
5
  SHA512:
6
- metadata.gz: 57725b96fdd14163059603613367d25276c1392c9389c1a1e79ea1993d569884da3a057869480545ab3310d01cb47e9da06116f42b8ea61c71b5e0dff2fb7bfc
7
- data.tar.gz: e51aae2c1dace0810c3b7f572ba405a8892d07dccce8d4632540c488f875a815ab56e82c8e7de04a9bfe341c7733e4a2cc61187c2297ffefcb2a0fa000fc0f3f
6
+ metadata.gz: c91429dea93398c1c532da4f5a66435b73842887a4d0f86782dfb19ba3801dfa65e04410a26f503e18cbc434793f293c051c7844a3702a638f14443711d7d6ea
7
+ data.tar.gz: a224f223a6f2da2ac314fa2d6f0deb4befbb0a962cad19d8a5c93a769ffd45450d23df71d791dfadae0b56435207beee54e5126e2e9cee50e9678fbe233fff9b
@@ -1,791 +1,937 @@
1
- ## Rails 5.1.0 (April 27, 2017) ##
1
+ ## Rails 5.2.3 (March 27, 2019) ##
2
2
 
3
- * Quote database name in db:create grant statement (when database_user does not have access to create the database).
3
+ * Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
4
4
 
5
- *Rune Philosof*
5
+ Fixes #35214.
6
6
 
7
- * When multiple threads are sharing a database connection inside a test using
8
- transactional fixtures, a nested transaction will temporarily lock the
9
- connection to the current thread, forcing others to wait.
7
+ *Juani Villarejo*
10
8
 
11
- Fixes #28197.
9
+ * Fix prepared statements caching to be enabled even when query caching is enabled.
12
10
 
13
- *Matthew Draper*
11
+ *Ryuta Kamizono*
14
12
 
15
- * Load only needed records on `ActiveRecord::Relation#inspect`.
13
+ * Don't allow `where` with invalid value matches to nil values.
16
14
 
17
- Instead of loading all records and returning only a subset of those, just
18
- load the records as needed.
15
+ Fixes #33624.
19
16
 
20
- Fixes #25537.
17
+ *Ryuta Kamizono*
21
18
 
22
- *Hendy Tanata*
19
+ * Restore an ability that class level `update` without giving ids.
23
20
 
24
- * Remove comments from structure.sql when using postgresql adapter to avoid
25
- version-specific parts of the file.
21
+ Fixes #34743.
26
22
 
27
- Fixes #28153.
23
+ *Ryuta Kamizono*
28
24
 
29
- *Ari Pollak*
25
+ * Fix join table column quoting with SQLite.
30
26
 
31
- * Add `:default` option to `belongs_to`.
27
+ *Gannon McGibbon*
32
28
 
33
- Use it to specify that an association should be initialized with a particular
34
- record before validation. For example:
29
+ * Ensure that `delete_all` on collection proxy returns affected count.
35
30
 
36
- # Before
37
- belongs_to :account
38
- before_validation -> { self.account ||= Current.account }
31
+ *Ryuta Kamizono*
39
32
 
40
- # After
41
- belongs_to :account, default: -> { Current.account }
33
+ * Reset scope after delete on collection association to clear stale offsets of removed records.
42
34
 
43
- *George Claghorn*
35
+ *Gannon McGibbon*
44
36
 
45
- * Deprecate `Migrator.schema_migrations_table_name`.
46
37
 
47
- *Ryuta Kamizono*
38
+ ## Rails 5.2.2.1 (March 11, 2019) ##
48
39
 
49
- * Fix select with block doesn't return newly built records in has_many association.
40
+ * No changes.
50
41
 
51
- Fixes #28348.
52
42
 
53
- *Ryuta Kamizono*
43
+ ## Rails 5.2.2 (December 04, 2018) ##
54
44
 
55
- * Check whether `Rails.application` defined before calling it
45
+ * Do not ignore the scoping with query methods in the scope block.
56
46
 
57
- In #27674 we changed the migration generator to generate migrations at the
58
- path defined in `Rails.application.config.paths` however the code checked
59
- for the presence of the `Rails` constant but not the `Rails.application`
60
- method which caused problems when using Active Record and generators outside
61
- of the context of a Rails application.
47
+ *Ryuta Kamizono*
62
48
 
63
- Fixes #28325.
49
+ * Allow aliased attributes to be used in `#update_columns` and `#update`.
64
50
 
65
- *Andrew White*
51
+ *Gannon McGibbon*
66
52
 
67
- * Fix `deserialize` with JSON array.
53
+ * Allow spaces in postgres table names.
68
54
 
69
- Fixes #28285.
55
+ Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
56
+ adapter.
70
57
 
71
- *Ryuta Kamizono*
58
+ *Gannon McGibbon*
72
59
 
73
- * Fix `rake db:schema:load` with subdirectories.
60
+ * Cached columns_hash fields should be excluded from ResultSet#column_types
74
61
 
75
- *Ryuta Kamizono*
62
+ PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
63
+ was passing for SQLite and MySQL, but failed for PostgreSQL:
76
64
 
77
- * Fix `rake db:migrate:status` with subdirectories.
65
+ ```ruby
66
+ class DeveloperName < ActiveRecord::Type::String
67
+ def deserialize(value)
68
+ "Developer: #{value}"
69
+ end
70
+ end
78
71
 
79
- *Ryuta Kamizono*
72
+ class AttributedDeveloper < ActiveRecord::Base
73
+ self.table_name = "developers"
80
74
 
81
- * Don't share options between reference id and type columns
75
+ attribute :name, DeveloperName.new
82
76
 
83
- When using a polymorphic reference column in a migration, sharing options
84
- between the two columns doesn't make sense since they are different types.
85
- The `reference_id` column is usually an integer and the `reference_type`
86
- column a string so options like `unsigned: true` will result in an invalid
87
- table definition.
77
+ self.ignored_columns += ["name"]
78
+ end
88
79
 
89
- *Ryuta Kamizono*
80
+ developer = AttributedDeveloper.create
81
+ developer.update_column :name, "name"
90
82
 
91
- * Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
83
+ loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
84
+ puts loaded_developer.name # should be "Developer: name" but it's just "name"
85
+ ```
92
86
 
93
- *Ryuta Kamizono*
87
+ *Dmitry Tsepelev*
94
88
 
95
- * Deprecate `supports_migrations?` on connection adapters.
89
+ * Values of enum are frozen, raising an error when attempting to modify them.
96
90
 
97
- *Ryuta Kamizono*
91
+ *Emmanuel Byrd*
98
92
 
99
- * Fix regression of #1969 with SELECT aliases in HAVING clause.
93
+ * `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
94
+ if the attribute does not exist.
100
95
 
101
- *Eugene Kenny*
96
+ *Sean Griffin*
102
97
 
103
- * Deprecate using `#quoted_id` in quoting.
98
+ * Do not use prepared statement in queries that have a large number of binds.
104
99
 
105
100
  *Ryuta Kamizono*
106
101
 
107
- * Fix `wait_timeout` to configurable for mysql2 adapter.
102
+ * Fix query cache to load before first request.
108
103
 
109
- Fixes #26556.
104
+ *Eileen M. Uchitelle*
110
105
 
111
- *Ryuta Kamizono*
106
+ * Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
112
107
 
113
- * Correctly dump native timestamp types for MySQL.
108
+ Fixes #33056.
114
109
 
115
- The native timestamp type in MySQL is different from datetime type.
116
- Internal representation of the timestamp type is UNIX time, This means
117
- that timestamp columns are affected by time zone.
110
+ *Federico Martinez*
118
111
 
119
- > SET time_zone = '+00:00';
120
- Query OK, 0 rows affected (0.00 sec)
112
+ * Fix duplicated record creation when using nested attributes with `create_with`.
121
113
 
122
- > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW());
123
- Query OK, 1 row affected (0.02 sec)
114
+ *Darwin Wu*
124
115
 
125
- > SELECT * FROM time_with_zone;
126
- +---------------------+---------------------+
127
- | ts | dt |
128
- +---------------------+---------------------+
129
- | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 |
130
- +---------------------+---------------------+
131
- 1 row in set (0.00 sec)
116
+ * Fix regression setting children record in parent `before_save` callback.
132
117
 
133
- > SET time_zone = '-08:00';
134
- Query OK, 0 rows affected (0.00 sec)
118
+ *Guo Xiang Tan*
135
119
 
136
- > SELECT * FROM time_with_zone;
137
- +---------------------+---------------------+
138
- | ts | dt |
139
- +---------------------+---------------------+
140
- | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 |
141
- +---------------------+---------------------+
142
- 1 row in set (0.00 sec)
120
+ * Prevent leaking of user's DB credentials on `rails db:create` failure.
143
121
 
144
- *Ryuta Kamizono*
122
+ *bogdanvlviv*
145
123
 
146
- * All integer-like PKs are autoincrement unless they have an explicit default.
124
+ * Clear mutation tracker before continuing the around callbacks.
147
125
 
148
- *Matthew Draper*
126
+ *Yuya Tanaka*
149
127
 
150
- * Omit redundant `using: :btree` for schema dumping.
128
+ * Prevent deadlocks when waiting for connection from pool.
151
129
 
152
- *Ryuta Kamizono*
130
+ *Brent Wheeldon*
153
131
 
154
- * Deprecate passing `default` to `index_name_exists?`.
132
+ * Avoid extra scoping when using `Relation#update` that was causing this method to change the current scope.
155
133
 
156
134
  *Ryuta Kamizono*
157
135
 
158
- * PostgreSQL: schema dumping support for interval and OID columns.
136
+ * Fix numericality validator not to be affected by custom getter.
159
137
 
160
138
  *Ryuta Kamizono*
161
139
 
162
- * Deprecate `supports_primary_key?` on connection adapters since it's
163
- been long unused and unsupported.
140
+ * Fix bulk change table ignores comment option on PostgreSQL.
164
141
 
165
- *Ryuta Kamizono*
142
+ *Yoshiyuki Kinjo*
166
143
 
167
- * Make `table_name=` reset current statement cache,
168
- so queries are not run against the previous table name.
169
144
 
170
- *namusyaka*
145
+ ## Rails 5.2.1.1 (November 27, 2018) ##
171
146
 
172
- * Allow `ActiveRecord::Base#as_json` to be passed a frozen Hash.
147
+ * No changes.
173
148
 
174
- *Isaac Betesh*
175
149
 
176
- * Fix inspection behavior when the :id column is not primary key.
150
+ ## Rails 5.2.1 (August 07, 2018) ##
177
151
 
178
- *namusyaka*
152
+ * PostgreSQL: Support new relkind for partitioned tables.
179
153
 
180
- * Deprecate locking records with unpersisted changes.
154
+ Fixes #33008.
181
155
 
182
- *Marc Schütz*
156
+ *Yannick Schutz*
183
157
 
184
- * Remove deprecated behavior that halts callbacks when the return is false.
158
+ * Rollback parent transaction when children fails to update.
185
159
 
186
- *Rafael Mendonça França*
160
+ *Guillaume Malette*
161
+
162
+ * Fix default value for MySQL time types with specified precision.
187
163
 
188
- * Deprecate `ColumnDumper#migration_keys`.
164
+ *Nikolay Kondratyev*
165
+
166
+ * Fix `touch` option to behave consistently with `Persistence#touch` method.
189
167
 
190
168
  *Ryuta Kamizono*
191
169
 
192
- * Fix `association_primary_key_type` for reflections with symbol primary key.
170
+ * Fix `save` in `after_create_commit` won't invoke extra `after_create_commit`.
193
171
 
194
- Fixes #27864.
172
+ Fixes #32831.
195
173
 
196
- *Daniel Colson*
174
+ *Ryuta Kamizono*
197
175
 
198
- * Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+.
176
+ * Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
199
177
 
200
- MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html
201
- MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
178
+ *Brian Durand*
202
179
 
203
- Declare virtual columns with `t.virtual name, type: …, as: "expression"`.
204
- Pass `stored: true` to persist the generated value (false by default).
180
+ * Fix parent record should not get saved with duplicate children records.
205
181
 
206
- Example:
182
+ Fixes #32940.
207
183
 
208
- create_table :generated_columns do |t|
209
- t.string :name
210
- t.virtual :upper_name, type: :string, as: "UPPER(name)"
211
- t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
212
- t.index :name_length # May be indexed, too!
213
- end
184
+ *Santosh Wadghule*
214
185
 
215
- *Ryuta Kamizono*
186
+ * Fix that association's after_touch is not called with counter cache.
216
187
 
217
- * Deprecate `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
188
+ Fixes #31559.
218
189
 
219
190
  *Ryuta Kamizono*
220
191
 
221
- * Support foreign key creation for SQLite3.
192
+ * `becomes` should clear the mutation tracker which is created in `after_initialize`.
193
+
194
+ Fixes #32867.
222
195
 
223
196
  *Ryuta Kamizono*
224
197
 
225
- * Place generated migrations into the path set by `config.paths["db/migrate"]`.
198
+ * Allow a belonging to parent object to be created from a new record.
226
199
 
227
- *Kevin Glowacz*
200
+ *Jolyon Pawlyn*
228
201
 
229
- * Raise `ActiveRecord::InvalidForeignKey` when a foreign key constraint fails on SQLite3.
202
+ * Fix that building record with assigning multiple has_one associations
203
+ wrongly persists through record.
230
204
 
231
- *Ryuta Kamizono*
205
+ Fixes #32511.
232
206
 
233
- * Add the touch option to `#increment!` and `#decrement!`.
207
+ *Sam DeCesare*
234
208
 
235
- *Hiroaki Izu*
209
+ * Fix relation merging when one of the relations is going to skip the
210
+ query cache.
236
211
 
237
- * Deprecate passing a class to the `class_name` because it eagerloads more classes than
238
- necessary and potentially creates circular dependencies.
212
+ *James Williams*
239
213
 
240
- *Kir Shatrov*
241
214
 
242
- * Raise error when has_many through is defined before through association.
215
+ ## Rails 5.2.0 (April 09, 2018) ##
243
216
 
244
- Fixes #26834.
217
+ * MySQL: Support mysql2 0.5.x.
245
218
 
246
- *Chris Holmes*
219
+ *Aaron Stone*
247
220
 
248
- * Deprecate passing `name` to `indexes`.
221
+ * Apply time column precision on assignment.
249
222
 
250
- *Ryuta Kamizono*
223
+ PR #20317 changed the behavior of datetime columns so that when they
224
+ have a specified precision then on assignment the value is rounded to
225
+ that precision. This behavior is now applied to time columns as well.
251
226
 
252
- * Remove deprecated tasks: `db:test:clone`, `db:test:clone_schema`, `db:test:clone_structure`.
227
+ Fixes #30301.
253
228
 
254
- *Rafel Mendonça França*
229
+ *Andrew White*
255
230
 
256
- * Compare deserialized values for `PostgreSQL::OID::Hstore` types when
257
- calling `ActiveRecord::Dirty#changed_in_place?`.
231
+ * Normalize time column values for SQLite database.
258
232
 
259
- Fixes #27502.
233
+ For legacy reasons, time columns in SQLite are stored as full datetimes
234
+ because until #24542 the quoting for time columns didn't remove the date
235
+ component. To ensure that values are consistent we now normalize the
236
+ date component to 2001-01-01 on reading and writing.
260
237
 
261
- *Jon Moss*
238
+ *Andrew White*
262
239
 
263
- * Raise `ArgumentError` when passing an `ActiveRecord::Base` instance to `.find`,
264
- `.exists?` and `.update`.
240
+ * Ensure that the date component is removed when quoting times.
265
241
 
266
- *Rafael Mendonça França*
242
+ PR #24542 altered the quoting for time columns so that the date component
243
+ was removed however it only removed it when it was 2001-01-01. Now the
244
+ date component is removed irrespective of what the date is.
267
245
 
268
- * Respect precision option for arrays of timestamps.
246
+ *Andrew White*
269
247
 
270
- Fixes #27514.
248
+ * Fix `dependent: :destroy` issue for has_one/belongs_to relationship where
249
+ the parent class was getting deleted when the child was not.
271
250
 
272
- *Sean Griffin*
251
+ Fixes #32022.
273
252
 
274
- * Optimize slow model instantiation when using STI and `store_full_sti_class = false` option.
253
+ *Fernando Gorodscy*
275
254
 
276
- *Konstantin Lazarev*
255
+ * Whitelist `NULLS FIRST` and `NULLS LAST` in order clauses too.
277
256
 
278
- * Add `touch` option to counter cache modifying methods.
257
+ *Xavier Noria*
279
258
 
280
- Works when updating, resetting, incrementing and decrementing counters:
259
+ * Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
281
260
 
282
- # Touches `updated_at`/`updated_on`.
283
- Topic.increment_counter(:messages_count, 1, touch: true)
284
- Topic.decrement_counter(:messages_count, 1, touch: true)
261
+ *Ryuta Kamizono*
285
262
 
286
- # Touches `last_discussed_at`.
287
- Topic.reset_counters(18, :messages, touch: :last_discussed_at)
263
+ * Fix `#columns_for_distinct` of MySQL and PostgreSQL to make
264
+ `ActiveRecord::FinderMethods#limited_ids_for` use correct primary key values
265
+ even if `ORDER BY` columns include other table's primary key.
288
266
 
289
- # Touches `updated_at` and `last_discussed_at`.
290
- Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
267
+ Fixes #28364.
291
268
 
292
- Fixes #26724.
269
+ *Takumi Kagiyama*
293
270
 
294
- *Jarred Trost*
271
+ * Make `reflection.klass` raise if `polymorphic?` not to be misused.
295
272
 
296
- * Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`.
273
+ Fixes #31876.
297
274
 
298
275
  *Ryuta Kamizono*
299
276
 
300
- * Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`.
277
+ * PostgreSQL: Allow pg-1.0 gem to be used with Active Record.
301
278
 
302
- *Ryuta Kamizono*
279
+ *Lars Kanis*
303
280
 
304
- * Remove deprecated `#use_transactional_fixtures` configuration.
281
+ * Deprecate `expand_hash_conditions_for_aggregates` without replacement.
282
+ Using a `Relation` for performing queries is the prefered API.
305
283
 
306
- *Rafael Mendonça França*
284
+ *Ryuta Kamizono*
307
285
 
308
- * Remove deprecated `#raise_in_transactional_callbacks` configuration.
286
+ * Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
309
287
 
310
- *Rafael Mendonça França*
288
+ ```
289
+ david_balance = customers(:david).balance
290
+ Customer.where(balance: [david_balance]).to_sql
311
291
 
312
- * Remove deprecated `#load_schema_for`.
292
+ # Before: WHERE `customers`.`balance` = NULL
293
+ # After : WHERE `customers`.`balance` = 50
294
+ ```
313
295
 
314
- *Rafael Mendonça França*
296
+ Fixes #31723.
315
297
 
316
- * Remove deprecated conditions parameter from `#destroy_all` and `#delete_all`.
298
+ *Yutaro Kanagawa*
317
299
 
318
- *Rafael Mendonça França*
300
+ * Fix `count(:all)` with eager loading and having an order other than the driving table.
319
301
 
320
- * Remove deprecated support to passing arguments to `#select` when a block is provided.
302
+ Fixes #31783.
321
303
 
322
- *Rafael Mendonça França*
304
+ *Ryuta Kamizono*
323
305
 
324
- * Remove deprecated support to query using commas on LIMIT.
306
+ * Clear the transaction state when an Active Record object is duped.
325
307
 
326
- *Rafael Mendonça França*
308
+ Fixes #31670.
327
309
 
328
- * Remove deprecated support to passing a class as a value in a query.
310
+ *Yuriy Ustushenko*
329
311
 
330
- *Rafael Mendonça França*
312
+ * Support for PostgreSQL foreign tables.
331
313
 
332
- * Raise `ActiveRecord::IrreversibleOrderError` when using `last` with an irreversible
333
- order.
314
+ *fatkodima*
334
315
 
335
- *Rafael Mendonça França*
316
+ * Fix relation merger issue with `left_outer_joins`.
336
317
 
337
- * Raise when a `has_many :through` association has an ambiguous reflection name.
318
+ *Mehmet Emin İNAÇ*
338
319
 
339
- *Rafael Mendonça França*
320
+ * Don't allow destroyed object mutation after `save` or `save!` is called.
340
321
 
341
- * Raise when `ActiveRecord::Migration` is inherited from directly.
322
+ *Ryuta Kamizono*
342
323
 
343
- *Rafael Mendonça França*
324
+ * Take into account association conditions when deleting through records.
344
325
 
345
- * Remove deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize`
346
- and `ActiveRecord::StatementInvalid#original_exception`.
326
+ Fixes #18424.
347
327
 
348
- *Rafael Mendonça França*
328
+ *Piotr Jakubowski*
349
329
 
350
- * `#tables` and `#table_exists?` return only tables and not views.
330
+ * Fix nested `has_many :through` associations on unpersisted parent instances.
351
331
 
352
- All the deprecations on those methods were removed.
332
+ For example, if you have
353
333
 
354
- *Rafael Mendonça França*
334
+ class Post < ActiveRecord::Base
335
+ belongs_to :author
336
+ has_many :books, through: :author
337
+ has_many :subscriptions, through: :books
338
+ end
355
339
 
356
- * Remove deprecated `name` argument from `#tables`.
340
+ class Author < ActiveRecord::Base
341
+ has_one :post
342
+ has_many :books
343
+ has_many :subscriptions, through: :books
344
+ end
357
345
 
358
- *Rafael Mendonça França*
346
+ class Book < ActiveRecord::Base
347
+ belongs_to :author
348
+ has_many :subscriptions
349
+ end
359
350
 
360
- * Remove deprecated support to passing a column to `#quote`.
351
+ class Subscription < ActiveRecord::Base
352
+ belongs_to :book
353
+ end
361
354
 
362
- *Rafael Mendonça França*
355
+ Before:
363
356
 
364
- * Set `:time` as a timezone aware type and remove deprecation when
365
- `config.active_record.time_zone_aware_types` is not explicitly set.
357
+ If `post` is not persisted, then `post.subscriptions` will be empty.
366
358
 
367
- *Rafael Mendonça França*
359
+ After:
368
360
 
369
- * Remove deprecated force reload argument in singular and collection association readers.
361
+ If `post` is not persisted, then `post.subscriptions` can be set and used
362
+ just like it would if `post` were persisted.
370
363
 
371
- *Rafael Mendonça França*
364
+ Fixes #16313.
372
365
 
373
- * Remove deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and
374
- `activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes.
366
+ *Zoltan Kiss*
375
367
 
376
- *Rafael Mendonça França*
368
+ * Fixed inconsistency with `first(n)` when used with `limit()`.
369
+ The `first(n)` finder now respects the `limit()`, making it consistent
370
+ with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
377
371
 
378
- * Allow passing extra flags to `db:structure:load` and `db:structure:dump`
372
+ Fixes #23979.
379
373
 
380
- Introduces `ActiveRecord::Tasks::DatabaseTasks.structure_(load|dump)_flags` to customize the
381
- eventual commands run against the database, e.g. mysqldump/pg_dump.
374
+ *Brian Christian*
382
375
 
383
- *Kir Shatrov*
376
+ * Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
377
+ SQL queries for association counting.
384
378
 
385
- * Notifications see frozen SQL string.
379
+ *Klas Eskilson*
386
380
 
387
- Fixes #23774.
381
+ * Fix to invoke callbacks when using `update_attribute`.
388
382
 
389
- *Richard Monette*
383
+ *Mike Busch*
390
384
 
391
- * RuntimeErrors are no longer translated to `ActiveRecord::StatementInvalid`.
385
+ * Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
392
386
 
393
- *Richard Monette*
387
+ *Ryuta Kamizono*
394
388
 
395
- * Change the schema cache format to use YAML instead of Marshal.
389
+ * Using subselect for `delete_all` with `limit` or `offset`.
396
390
 
397
- *Kir Shatrov*
391
+ *Ryuta Kamizono*
398
392
 
399
- * Support index length and order options using both string and symbol
400
- column names.
393
+ * Undefine attribute methods on descendants when resetting column
394
+ information.
395
+
396
+ *Chris Salzberg*
397
+
398
+ * Log database query callers.
399
+
400
+ Add `verbose_query_logs` configuration option to display the caller
401
+ of database queries in the log to facilitate N+1 query resolution
402
+ and other debugging.
403
+
404
+ Enabled in development only for new and upgraded applications. Not
405
+ recommended for use in the production environment since it relies
406
+ on Ruby's `Kernel#caller_locations` which is fairly slow.
407
+
408
+ *Olivier Lacan*
409
+
410
+ * Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
411
+
412
+ ```
413
+ # create_table :posts do |t|
414
+ # t.integer :comments_count, default: 0
415
+ # t.integer :lock_version
416
+ # t.timestamps
417
+ # end
418
+ class Post < ApplicationRecord
419
+ end
420
+
421
+ # create_table :comments do |t|
422
+ # t.belongs_to :post
423
+ # end
424
+ class Comment < ApplicationRecord
425
+ belongs_to :post, touch: true, counter_cache: true
426
+ end
427
+ ```
428
+
429
+ Before:
430
+ ```
431
+ post = Post.create!
432
+ # => begin transaction
433
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
434
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
435
+ commit transaction
436
+
437
+ comment = Comment.create!(post: post)
438
+ # => begin transaction
439
+ INSERT INTO "comments" ("post_id") VALUES (1)
440
+
441
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
442
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
443
+
444
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
445
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
446
+ rollback transaction
447
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
448
+
449
+ Comment.take.destroy!
450
+ # => begin transaction
451
+ DELETE FROM "comments" WHERE "comments"."id" = 1
452
+
453
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
454
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
455
+
456
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
457
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
458
+ rollback transaction
459
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
460
+ ```
461
+
462
+ After:
463
+ ```
464
+ post = Post.create!
465
+ # => begin transaction
466
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
467
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
468
+ commit transaction
469
+
470
+ comment = Comment.create!(post: post)
471
+ # => begin transaction
472
+ INSERT INTO "comments" ("post_id") VALUES (1)
473
+
474
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
475
+ "lock_version" = COALESCE("lock_version", 0) + 1,
476
+ "updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
477
+ commit transaction
478
+
479
+ comment.destroy!
480
+ # => begin transaction
481
+ DELETE FROM "comments" WHERE "comments"."id" = 1
482
+
483
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
484
+ "lock_version" = COALESCE("lock_version", 0) + 1,
485
+ "updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
486
+ commit transaction
487
+ ```
488
+
489
+ Fixes #31199.
401
490
 
402
- Fixes #27243.
491
+ *bogdanvlviv*
403
492
 
404
- *Ryuta Kamizono*
493
+ * Add support for PostgreSQL operator classes to `add_index`.
405
494
 
406
- * Raise `ActiveRecord::RangeError` when values that executed are out of range.
495
+ Example:
407
496
 
408
- *Ryuta Kamizono*
497
+ add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
409
498
 
410
- * Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted
411
- or updated because it would violate a not null constraint.
499
+ *Greg Navis*
412
500
 
413
- *Ryuta Kamizono*
501
+ * Don't allow scopes to be defined which conflict with instance methods on `Relation`.
414
502
 
415
- * Emulate db trigger behaviour for after_commit :destroy, :update.
503
+ Fixes #31120.
416
504
 
417
- Race conditions can occur when an ActiveRecord is destroyed
418
- twice or destroyed and updated. The callbacks should only be
419
- triggered once, similar to a SQL database trigger.
505
+ *kinnrot*
420
506
 
421
- *Stefan Budeanu*
507
+ * Add new error class `QueryCanceled` which will be raised
508
+ when canceling statement due to user request.
422
509
 
423
- * Moved `DecimalWithoutScale`, `Text`, and `UnsignedInteger` from Active Model to Active Record.
510
+ *Ryuta Kamizono*
424
511
 
425
- *Iain Beeston*
512
+ * Add `#up_only` to database migrations for code that is only relevant when
513
+ migrating up, e.g. populating a new column.
426
514
 
427
- * Fix `write_attribute` method to check whether an attribute is aliased or not, and
428
- use the aliased attribute name if needed.
515
+ *Rich Daley*
429
516
 
430
- *Prathamesh Sonpatki*
517
+ * Require raw SQL fragments to be explicitly marked when used in
518
+ relation query methods.
431
519
 
432
- * Fix `read_attribute` method to check whether an attribute is aliased or not, and
433
- use the aliased attribute name if needed.
520
+ Before:
521
+ ```
522
+ Article.order("LENGTH(title)")
523
+ ```
434
524
 
435
- Fixes #26417.
525
+ After:
526
+ ```
527
+ Article.order(Arel.sql("LENGTH(title)"))
528
+ ```
436
529
 
437
- *Prathamesh Sonpatki*
530
+ This prevents SQL injection if applications use the [strongly
531
+ discouraged] form `Article.order(params[:my_order])`, under the
532
+ mistaken belief that only column names will be accepted.
438
533
 
439
- * PostgreSQL & MySQL: Use big integer as primary key type for new tables.
534
+ Raw SQL strings will now cause a deprecation warning, which will
535
+ become an UnknownAttributeReference error in Rails 6.0. Applications
536
+ can opt in to the future behavior by setting `allow_unsafe_raw_sql`
537
+ to `:disabled`.
440
538
 
441
- *Jon McCartie*, *Pavel Pravosud*
539
+ Common and judged-safe string values (such as simple column
540
+ references) are unaffected:
541
+ ```
542
+ Article.order("title DESC")
543
+ ```
442
544
 
443
- * Change the type argument of `ActiveRecord::Base#attribute` to be optional.
444
- The default is now `ActiveRecord::Type::Value.new`, which provides no type
445
- casting behavior.
545
+ *Ben Toews*
446
546
 
447
- *Sean Griffin*
547
+ * `update_all` will now pass its values to `Type#cast` before passing them to
548
+ `Type#serialize`. This means that `update_all(foo: 'true')` will properly
549
+ persist a boolean.
448
550
 
449
- * Don't treat unsigned integers with zerofill as signed.
551
+ *Sean Griffin*
450
552
 
451
- Fixes #27125.
553
+ * Add new error class `StatementTimeout` which will be raised
554
+ when statement timeout exceeded.
452
555
 
453
556
  *Ryuta Kamizono*
454
557
 
455
- * Fix the uniqueness validation scope with a polymorphic association.
558
+ * Fix `bin/rails db:migrate` with specified `VERSION`.
559
+ `bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
560
+ Check a format of `VERSION`: Allow a migration version number
561
+ or name of a migration file. Raise error if format of `VERSION` is invalid.
562
+ Raise error if target migration doesn't exist.
456
563
 
457
- *Sergey Alekseev*
564
+ *bogdanvlviv*
458
565
 
459
- * Raise `ActiveRecord::RecordNotFound` from collection `*_ids` setters
460
- for unknown IDs with a better error message.
566
+ * Fixed a bug where column orders for an index weren't written to
567
+ `db/schema.rb` when using the sqlite adapter.
461
568
 
462
- Changes the collection `*_ids` setters to cast provided IDs the data
463
- type of the primary key set in the association, not the model
464
- primary key.
569
+ Fixes #30902.
465
570
 
466
- *Dominic Cleal*
571
+ *Paul Kuruvilla*
467
572
 
468
- * For PostgreSQL >= 9.4 use `pgcrypto`'s `gen_random_uuid()` instead of
469
- `uuid-ossp`'s UUID generation function.
573
+ * Remove deprecated method `#sanitize_conditions`.
470
574
 
471
- *Yuji Yaginuma*, *Yaw Boakye*
575
+ *Rafael Mendonça França*
472
576
 
473
- * Introduce `Model#reload_<association>` to bring back the behavior
474
- of `Article.category(true)` where `category` is a singular
475
- association.
577
+ * Remove deprecated method `#scope_chain`.
476
578
 
477
- The force reloading of the association reader was deprecated
478
- in #20888. Unfortunately the suggested alternative of
479
- `article.reload.category` does not expose the same behavior.
579
+ *Rafael Mendonça França*
480
580
 
481
- This patch adds a reader method with the prefix `reload_` for
482
- singular associations. This method has the same semantics as
483
- passing true to the association reader used to have.
581
+ * Remove deprecated configuration `.error_on_ignored_order_or_limit`.
484
582
 
485
- *Yves Senn*
583
+ *Rafael Mendonça França*
486
584
 
487
- * Make sure eager loading `ActiveRecord::Associations` also loads
488
- constants defined in `ActiveRecord::Associations::Preloader`.
585
+ * Remove deprecated arguments from `#verify!`.
489
586
 
490
- *Yves Senn*
587
+ *Rafael Mendonça França*
491
588
 
492
- * Allow `ActionController::Parameters`-like objects to be passed as
493
- values for Postgres HStore columns.
589
+ * Remove deprecated argument `name` from `#indexes`.
494
590
 
495
- Fixes #26904.
591
+ *Rafael Mendonça França*
496
592
 
497
- *Jon Moss*
593
+ * Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
498
594
 
499
- * Added `stat` method to `ActiveRecord::ConnectionAdapters::ConnectionPool`.
595
+ *Rafael Mendonça França*
500
596
 
501
- Example:
597
+ * Remove deprecated method `supports_primary_key?`.
502
598
 
503
- ActiveRecord::Base.connection_pool.stat # =>
504
- { size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
599
+ *Rafael Mendonça França*
505
600
 
506
- *Pavel Evstigneev*
601
+ * Remove deprecated method `supports_migrations?`.
507
602
 
508
- * Avoid `unscope(:order)` when `limit_value` is presented for `count`
509
- and `exists?`.
603
+ *Rafael Mendonça França*
510
604
 
511
- If `limit_value` is presented, records fetching order is very important
512
- for performance. We should not unscope the order in the case.
605
+ * Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
513
606
 
514
- *Ryuta Kamizono*
607
+ *Rafael Mendonça França*
515
608
 
516
- * Fix an Active Record `DateTime` field `NoMethodError` caused by incomplete
517
- datetime.
609
+ * Raises when calling `lock!` in a dirty record.
518
610
 
519
- Fixes #24195.
611
+ *Rafael Mendonça França*
520
612
 
521
- *Sen Zhang*
613
+ * Remove deprecated support to passing a class to `:class_name` on associations.
522
614
 
523
- * Allow `slice` to take an array of methods(without the need for splatting).
615
+ *Rafael Mendonça França*
524
616
 
525
- *Cohen Carlisle*
617
+ * Remove deprecated argument `default` from `index_name_exists?`.
526
618
 
527
- * Improved partial writes with HABTM and has many through associations
528
- to fire database query only if relation has been changed.
619
+ *Rafael Mendonça França*
529
620
 
530
- Fixes #19663.
621
+ * Remove deprecated support to `quoted_id` when typecasting an Active Record object.
531
622
 
532
- *Mehmet Emin İNAÇ*
623
+ *Rafael Mendonça França*
533
624
 
534
- * Deprecate passing arguments and block at the same time to
535
- `ActiveRecord::QueryMethods#select`.
625
+ * Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
626
+ ar_internal_metadata's data for a test database.
536
627
 
537
- *Prathamesh Sonpatki*
628
+ Before:
629
+ ```
630
+ $ RAILS_ENV=test rails dbconsole
631
+ > SELECT * FROM ar_internal_metadata;
632
+ key|value|created_at|updated_at
633
+ environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
634
+ ```
538
635
 
539
- * Fixed: Optimistic locking does not work well with `null` in the database.
636
+ After:
637
+ ```
638
+ $ RAILS_ENV=test rails dbconsole
639
+ > SELECT * FROM ar_internal_metadata;
640
+ key|value|created_at|updated_at
641
+ environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
642
+ ```
540
643
 
541
- Fixes #26024.
644
+ Fixes #26731.
542
645
 
543
646
  *bogdanvlviv*
544
647
 
545
- * Fixed support for case insensitive comparisons of `text` columns in
546
- PostgreSQL.
547
-
548
- *Edho Arief*
549
-
550
- * Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`.
648
+ * Fix longer sequence name detection for serial columns.
551
649
 
552
- *Trung Duc Tran*
650
+ Fixes #28332.
553
651
 
554
- * Return `true` from `update_attribute` when the value of the attribute
555
- to be updated is unchanged.
652
+ *Ryuta Kamizono*
556
653
 
557
- Fixes #26593.
654
+ * MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
558
655
 
559
- *Prathamesh Sonpatki*
656
+ Fixes #30894.
560
657
 
561
- * Always store errors details information with symbols.
658
+ *Ryuta Kamizono*
562
659
 
563
- When the association is autosaved we were storing the details with
564
- string keys. This was creating inconsistency with other details that are
565
- added using the `Errors#add` method. It was also inconsistent with the
566
- `Errors#messages` storage.
660
+ * Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
567
661
 
568
- To fix this inconsistency we are always storing with symbols. This will
569
- cause a small breaking change because in those cases the details could
570
- be accessed as strings keys but now it can not.
662
+ Fixes #30886.
571
663
 
572
- Fix #26499.
664
+ *Ryuta Kamizono*
573
665
 
574
- *Rafael Mendonça França*, *Marcus Vieira*
666
+ * PostgreSQL `tsrange` now preserves subsecond precision.
575
667
 
576
- * Calling `touch` on a model using optimistic locking will now leave the model
577
- in a non-dirty state with no attribute changes.
668
+ PostgreSQL 9.1+ introduced range types, and Rails added support for using
669
+ this datatype in Active Record. However, the serialization of
670
+ `PostgreSQL::OID::Range` was incomplete, because it did not properly
671
+ cast the bounds that make up the range. This led to subseconds being
672
+ dropped in SQL commands:
578
673
 
579
- Fixes #26496.
674
+ Before:
580
675
 
581
- *Jakob Skjerning*
676
+ connection.type_cast(tsrange.serialize(range_value))
677
+ # => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
582
678
 
583
- * Using a mysql2 connection after it fails to reconnect will now have an error message
584
- saying the connection is closed rather than an undefined method error message.
679
+ Now:
585
680
 
586
- *Dylan Thacker-Smith*
681
+ connection.type_cast(tsrange.serialize(range_value))
682
+ # => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
587
683
 
588
- * PostgreSQL array columns will now respect the encoding of strings contained
589
- in the array.
684
+ *Thomas Cannon*
590
685
 
591
- Fixes #26326.
686
+ * Passing a `Set` to `Relation#where` now behaves the same as passing an
687
+ array.
592
688
 
593
689
  *Sean Griffin*
594
690
 
595
- * Inverse association instances will now be set before `after_find` or
596
- `after_initialize` callbacks are run.
691
+ * Use given algorithm while removing index from database.
597
692
 
598
- Fixes #26320.
693
+ Fixes #24190.
599
694
 
600
- *Sean Griffin*
695
+ *Mehmet Emin İNAÇ*
601
696
 
602
- * Remove unnecessarily association load when a `belongs_to` association has already been
603
- loaded then the foreign key is changed directly and the record saved.
697
+ * Update payload names for `sql.active_record` instrumentation to be
698
+ more descriptive.
604
699
 
605
- *James Coleman*
700
+ Fixes #30586.
606
701
 
607
- * Remove standardized column types/arguments spaces in schema dump.
702
+ *Jeremy Green*
608
703
 
609
- *Tim Petricola*
704
+ * Add new error class `LockWaitTimeout` which will be raised
705
+ when lock wait timeout exceeded.
610
706
 
611
- * Avoid loading records from database when they are already loaded using
612
- the `pluck` method on a collection.
707
+ *Gabriel Courtemanche*
613
708
 
614
- Fixes #25921.
709
+ * Remove deprecated `#migration_keys`.
615
710
 
616
711
  *Ryuta Kamizono*
617
712
 
618
- * Remove text default treated as an empty string in non-strict mode for
619
- consistency with other types.
713
+ * Automatically guess the inverse associations for STI.
620
714
 
621
- Strict mode controls how MySQL handles invalid or missing values in
622
- data-change statements such as INSERT or UPDATE. If strict mode is not
623
- in effect, MySQL inserts adjusted values for invalid or missing values
624
- and produces warnings.
715
+ *Yuichiro Kaneko*
625
716
 
626
- def test_mysql_not_null_defaults_non_strict
627
- using_strict(false) do
628
- with_mysql_not_null_table do |klass|
629
- record = klass.new
630
- assert_nil record.non_null_integer
631
- assert_nil record.non_null_string
632
- assert_nil record.non_null_text
633
- assert_nil record.non_null_blob
717
+ * Ensure `sum` honors `distinct` on `has_many :through` associations.
634
718
 
635
- record.save!
636
- record.reload
719
+ Fixes #16791.
637
720
 
638
- assert_equal 0, record.non_null_integer
639
- assert_equal "", record.non_null_string
640
- assert_equal "", record.non_null_text
641
- assert_equal "", record.non_null_blob
642
- end
643
- end
644
- end
721
+ *Aaron Wortham*
645
722
 
646
- https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
723
+ * Add `binary` fixture helper method.
647
724
 
648
- *Ryuta Kamizono*
725
+ *Atsushi Yoshida*
726
+
727
+ * When using `Relation#or`, extract the common conditions and put them before the OR condition.
728
+
729
+ *Maxime Handfield Lapointe*
730
+
731
+ * `Relation#or` now accepts two relations who have different values for
732
+ `references` only, as `references` can be implicitly called by `where`.
733
+
734
+ Fixes #29411.
649
735
 
650
- * SQLite3 migrations to add a column to an existing table can now be
651
- successfully rolled back when the column was given and invalid column
652
- type.
736
+ *Sean Griffin*
653
737
 
654
- Fixes #26087.
738
+ * `ApplicationRecord` is no longer generated when generating models. If you
739
+ need to generate it, it can be created with `rails g application_record`.
655
740
 
656
- *Travis O'Neill*
741
+ *Lisa Ugray*
657
742
 
658
- * Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.
743
+ * Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
659
744
 
660
745
  *Ryuta Kamizono*
661
746
 
662
- * Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
663
- force a DISTINCT. This solves issues when using count after a left_joins.
747
+ * When a `has_one` association is destroyed by `dependent: destroy`,
748
+ `destroyed_by_association` will now be set to the reflection, matching the
749
+ behaviour of `has_many` associations.
750
+
751
+ *Lisa Ugray*
752
+
753
+ * Fix `unscoped(where: [columns])` removing the wrong bind values.
754
+
755
+ When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
756
+ bind values used by the `or` instead. (possibly other cases too)
757
+
758
+ ```
759
+ Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
760
+ # Currently:
761
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
762
+ # With fix:
763
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
764
+ ```
664
765
 
665
766
  *Maxime Handfield Lapointe*
666
767
 
667
- * RecordNotFound raised by association.find exposes `id`, `primary_key` and
668
- `model` methods to be consistent with RecordNotFound raised by Record.find.
768
+ * Values constructed using multi-parameter assignment will now use the
769
+ post-type-cast value for rendering in single-field form inputs.
669
770
 
670
- *Michel Pigassou*
771
+ *Sean Griffin*
671
772
 
672
- * Hashes can once again be passed to setters of `composed_of`, if all of the
673
- mapping methods are methods implemented on `Hash`.
773
+ * `Relation#joins` is no longer affected by the target model's
774
+ `current_scope`, with the exception of `unscoped`.
674
775
 
675
- Fixes #25978.
776
+ Fixes #29338.
676
777
 
677
778
  *Sean Griffin*
678
779
 
679
- * Fix the SELECT statement in `#table_comment` for MySQL.
780
+ * Change sqlite3 boolean serialization to use 1 and 0.
680
781
 
681
- *Takeshi Akima*
782
+ SQLite natively recognizes 1 and 0 as true and false, but does not natively
783
+ recognize 't' and 'f' as was previously serialized.
682
784
 
683
- * Virtual attributes will no longer raise when read on models loaded from the
684
- database.
785
+ This change in serialization requires a migration of stored boolean data
786
+ for SQLite databases, so it's implemented behind a configuration flag
787
+ whose default false value is deprecated.
685
788
 
686
- *Sean Griffin*
789
+ *Lisa Ugray*
687
790
 
688
- * Support calling the method `merge` in `scope`'s lambda.
791
+ * Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
792
+ `in_batches`).
689
793
 
690
- *Yasuhiro Sugino*
794
+ Previously, records would be fetched in batches, but all records would be retained in memory
795
+ until the end of the request or job.
691
796
 
692
- * Fixes multi-parameter attributes conversion with invalid params.
797
+ *Eugene Kenny*
693
798
 
694
- *Hiroyuki Ishii*
799
+ * Prevent errors raised by `sql.active_record` notification subscribers from being converted into
800
+ `ActiveRecord::StatementInvalid` exceptions.
695
801
 
696
- * Add newline between each migration in `structure.sql`.
802
+ *Dennis Taylor*
697
803
 
698
- Keeps schema migration inserts as a single commit, but allows for easier
699
- git diffing.
804
+ * Fix eager loading/preloading association with scope including joins.
700
805
 
701
- Fixes #25504.
806
+ Fixes #28324.
702
807
 
703
- *Grey Baker*, *Norberto Lopes*
808
+ *Ryuta Kamizono*
704
809
 
705
- * The flag `error_on_ignored_order_or_limit` has been deprecated in favor of
706
- the current `error_on_ignored_order`.
810
+ * Fix transactions to apply state to child transactions.
707
811
 
708
- *Xavier Noria*
812
+ Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
813
+ inner transaction would still be marked as persisted.
709
814
 
710
- * Batch processing methods support `limit`:
815
+ This change fixes that by applying the state of the parent transaction to the child transaction when the
816
+ parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
711
817
 
712
- Post.limit(10_000).find_each do |post|
713
- # ...
714
- end
818
+ *Eileen M. Uchitelle*, *Aaron Patterson*
715
819
 
716
- It also works in `find_in_batches` and `in_batches`.
820
+ * Deprecate `set_state` method in `TransactionState`.
717
821
 
718
- *Xavier Noria*
822
+ Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
823
+ state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
824
+ `set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
719
825
 
720
- * Using `group` with an attribute that has a custom type will properly cast
721
- the hash keys after calling a calculation method like `count`.
826
+ *Eileen M. Uchitelle*, *Aaron Patterson*
722
827
 
723
- Fixes #25595.
828
+ * Deprecate delegating to `arel` in `Relation`.
724
829
 
725
- *Sean Griffin*
830
+ *Ryuta Kamizono*
726
831
 
727
- * Fix the generated `#to_param` method to use `omission: ''` so that
728
- the resulting output is actually up to 20 characters, not
729
- effectively 17 to leave room for the default "...".
730
- Also call `#parameterize` before `#truncate` and make the
731
- `separator: /-/` to maximize the information included in the
732
- output.
832
+ * Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
833
+ without being connected.
733
834
 
734
- Fixes #23635.
835
+ *Tsukasa Oishi*
735
836
 
736
- *Rob Biedenharn*
837
+ * Previously, when building records using a `has_many :through` association,
838
+ if the child records were deleted before the parent was saved, they would
839
+ still be persisted. Now, if child records are deleted before the parent is saved
840
+ on a `has_many :through` association, the child records will not be persisted.
737
841
 
738
- * Ensure concurrent invocations of the connection reaper cannot allocate the
739
- same connection to two threads.
842
+ *Tobias Kraze*
740
843
 
741
- Fixes #25585.
844
+ * Merging two relations representing nested joins no longer transforms the joins of
845
+ the merged relation into LEFT OUTER JOIN.
742
846
 
743
- *Matthew Draper*
847
+ Example:
744
848
 
745
- * Inspecting an object with an associated array of over 10 elements no longer
746
- truncates the array, preventing `inspect` from looping infinitely in some
747
- cases.
849
+ ```
850
+ Author.joins(:posts).merge(Post.joins(:comments))
851
+ # Before the change:
852
+ #=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
748
853
 
749
- *Kevin McPhillips*
854
+ # After the change:
855
+ #=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
856
+ ```
750
857
 
751
- * Removed the unused methods `ActiveRecord::Base.connection_id` and
752
- `ActiveRecord::Base.connection_id=`.
858
+ *Maxime Handfield Lapointe*
753
859
 
754
- *Sean Griffin*
860
+ * `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
861
+ `locking_column`, without default value, is null in the database.
755
862
 
756
- * Ensure hashes can be assigned to attributes created using `composed_of`.
863
+ *bogdanvlviv*
757
864
 
758
- Fixes #25210.
865
+ * Fix destroying existing object does not work well when optimistic locking enabled and
866
+ `locking_column` is null in the database.
759
867
 
760
- *Sean Griffin*
868
+ *bogdanvlviv*
869
+
870
+ * Use bulk INSERT to insert fixtures for better performance.
871
+
872
+ *Kir Shatrov*
873
+
874
+ * Prevent creation of bind param if casted value is nil.
875
+
876
+ *Ryuta Kamizono*
877
+
878
+ * Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.
879
+
880
+ *Ryuta Kamizono*
761
881
 
762
- * Fix logging edge case where if an attribute was of the binary type and
763
- was provided as a Hash.
882
+ * Loading model schema from database is now thread-safe.
883
+
884
+ Fixes #28589.
885
+
886
+ *Vikrant Chaudhary*, *David Abdemoulaie*
887
+
888
+ * Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
889
+ in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
890
+ that does not include a timestamp any more.
891
+
892
+ NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
893
+ until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
894
+
895
+ *DHH*
896
+
897
+ * Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump.
898
+
899
+ *Rusty Geldmacher*, *Guillermo Iguaran*
900
+
901
+ * Add type caster to `RuntimeReflection#alias_name`.
902
+
903
+ Fixes #28959.
764
904
 
765
905
  *Jon Moss*
766
906
 
767
- * Handle JSON deserialization correctly if the column default from database
768
- adapter returns `''` instead of `nil`.
907
+ * Deprecate `supports_statement_cache?`.
769
908
 
770
- *Johannes Opper*
909
+ *Ryuta Kamizono*
771
910
 
772
- * Introduce new Active Record transaction error classes for catching
773
- transaction serialization failures or deadlocks.
911
+ * Raise error `UnknownMigrationVersionError` on the movement of migrations
912
+ when the current migration does not exist.
774
913
 
775
- *Erol Fornoles*
914
+ *bogdanvlviv*
776
915
 
777
- * PostgreSQL: Fix `db:structure:load` silent failure on SQL error.
916
+ * Fix `bin/rails db:forward` first migration.
778
917
 
779
- The command line flag `-v ON_ERROR_STOP=1` should be used
780
- when invoking `psql` to make sure errors are not suppressed.
918
+ *bogdanvlviv*
781
919
 
782
- Example:
920
+ * Support Descending Indexes for MySQL.
783
921
 
784
- psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db
922
+ MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
923
+ See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
924
+
925
+ *Ryuta Kamizono*
785
926
 
786
- Fixes #23818.
927
+ * Fix inconsistency with changed attributes when overriding Active Record attribute reader.
787
928
 
788
- *Ralin Chimev*
929
+ *bogdanvlviv*
930
+
931
+ * When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
932
+ Previously this method always returned an empty array.
933
+
934
+ *Kevin McPhillips*
789
935
 
790
936
 
791
- Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activerecord/CHANGELOG.md) for previous changes.
937
+ Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.