activerecord 4.2.6 → 5.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 (246) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1307 -1105
  3. data/MIT-LICENSE +2 -2
  4. data/README.rdoc +7 -8
  5. data/examples/performance.rb +2 -3
  6. data/examples/simple.rb +0 -1
  7. data/lib/active_record/aggregations.rb +37 -23
  8. data/lib/active_record/association_relation.rb +3 -3
  9. data/lib/active_record/associations/alias_tracker.rb +19 -16
  10. data/lib/active_record/associations/association.rb +11 -9
  11. data/lib/active_record/associations/association_scope.rb +73 -102
  12. data/lib/active_record/associations/belongs_to_association.rb +21 -32
  13. data/lib/active_record/associations/builder/association.rb +28 -34
  14. data/lib/active_record/associations/builder/belongs_to.rb +43 -18
  15. data/lib/active_record/associations/builder/collection_association.rb +7 -19
  16. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +14 -11
  17. data/lib/active_record/associations/builder/has_many.rb +4 -4
  18. data/lib/active_record/associations/builder/has_one.rb +11 -6
  19. data/lib/active_record/associations/builder/singular_association.rb +3 -10
  20. data/lib/active_record/associations/collection_association.rb +50 -31
  21. data/lib/active_record/associations/collection_proxy.rb +69 -29
  22. data/lib/active_record/associations/foreign_association.rb +1 -1
  23. data/lib/active_record/associations/has_many_association.rb +20 -71
  24. data/lib/active_record/associations/has_many_through_association.rb +8 -47
  25. data/lib/active_record/associations/has_one_association.rb +12 -5
  26. data/lib/active_record/associations/join_dependency/join_association.rb +20 -8
  27. data/lib/active_record/associations/join_dependency.rb +29 -19
  28. data/lib/active_record/associations/preloader/association.rb +46 -52
  29. data/lib/active_record/associations/preloader/collection_association.rb +0 -6
  30. data/lib/active_record/associations/preloader/has_many_through.rb +1 -1
  31. data/lib/active_record/associations/preloader/has_one.rb +0 -8
  32. data/lib/active_record/associations/preloader/through_association.rb +27 -14
  33. data/lib/active_record/associations/preloader.rb +14 -4
  34. data/lib/active_record/associations/singular_association.rb +7 -1
  35. data/lib/active_record/associations/through_association.rb +11 -3
  36. data/lib/active_record/associations.rb +317 -209
  37. data/lib/active_record/attribute/user_provided_default.rb +28 -0
  38. data/lib/active_record/attribute.rb +68 -18
  39. data/lib/active_record/attribute_assignment.rb +20 -141
  40. data/lib/active_record/attribute_decorators.rb +6 -5
  41. data/lib/active_record/attribute_methods/before_type_cast.rb +1 -1
  42. data/lib/active_record/attribute_methods/dirty.rb +46 -86
  43. data/lib/active_record/attribute_methods/primary_key.rb +2 -2
  44. data/lib/active_record/attribute_methods/query.rb +2 -2
  45. data/lib/active_record/attribute_methods/read.rb +31 -59
  46. data/lib/active_record/attribute_methods/serialization.rb +13 -16
  47. data/lib/active_record/attribute_methods/time_zone_conversion.rb +61 -14
  48. data/lib/active_record/attribute_methods/write.rb +14 -38
  49. data/lib/active_record/attribute_methods.rb +70 -45
  50. data/lib/active_record/attribute_mutation_tracker.rb +70 -0
  51. data/lib/active_record/attribute_set/builder.rb +6 -4
  52. data/lib/active_record/attribute_set.rb +30 -3
  53. data/lib/active_record/attributes.rb +199 -80
  54. data/lib/active_record/autosave_association.rb +49 -16
  55. data/lib/active_record/base.rb +32 -23
  56. data/lib/active_record/callbacks.rb +39 -43
  57. data/lib/active_record/coders/json.rb +1 -1
  58. data/lib/active_record/coders/yaml_column.rb +20 -8
  59. data/lib/active_record/collection_cache_key.rb +40 -0
  60. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +452 -182
  61. data/lib/active_record/connection_adapters/abstract/database_limits.rb +3 -3
  62. data/lib/active_record/connection_adapters/abstract/database_statements.rb +65 -61
  63. data/lib/active_record/connection_adapters/abstract/query_cache.rb +2 -2
  64. data/lib/active_record/connection_adapters/abstract/quoting.rb +74 -9
  65. data/lib/active_record/connection_adapters/abstract/savepoints.rb +3 -3
  66. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +61 -39
  67. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +236 -185
  68. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +72 -17
  69. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +378 -140
  70. data/lib/active_record/connection_adapters/abstract/transaction.rb +51 -34
  71. data/lib/active_record/connection_adapters/abstract_adapter.rb +153 -59
  72. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +405 -362
  73. data/lib/active_record/connection_adapters/column.rb +28 -43
  74. data/lib/active_record/connection_adapters/connection_specification.rb +15 -27
  75. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +22 -0
  76. data/lib/active_record/connection_adapters/mysql/column.rb +50 -0
  77. data/lib/active_record/connection_adapters/mysql/database_statements.rb +125 -0
  78. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +70 -0
  79. data/lib/active_record/connection_adapters/mysql/quoting.rb +51 -0
  80. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +67 -0
  81. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +93 -0
  82. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +54 -0
  83. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +32 -0
  84. data/lib/active_record/connection_adapters/mysql2_adapter.rb +25 -176
  85. data/lib/active_record/connection_adapters/postgresql/column.rb +5 -10
  86. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +10 -72
  87. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +42 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +27 -56
  89. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -2
  90. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +1 -1
  91. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -1
  92. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +7 -22
  93. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +3 -3
  94. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +1 -26
  95. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +2 -2
  96. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +0 -4
  97. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +4 -4
  98. data/lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb +50 -0
  99. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +31 -17
  100. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +0 -4
  101. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +2 -2
  102. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +1 -1
  103. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +1 -1
  104. data/lib/active_record/connection_adapters/postgresql/oid.rb +1 -6
  105. data/lib/active_record/connection_adapters/postgresql/quoting.rb +26 -18
  106. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +29 -10
  107. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +107 -79
  108. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +47 -0
  109. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +234 -148
  110. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +35 -0
  111. data/lib/active_record/connection_adapters/postgresql_adapter.rb +248 -160
  112. data/lib/active_record/connection_adapters/schema_cache.rb +36 -23
  113. data/lib/active_record/connection_adapters/sql_type_metadata.rb +32 -0
  114. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +19 -0
  115. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +48 -0
  116. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +22 -0
  117. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +148 -203
  118. data/lib/active_record/connection_adapters/statement_pool.rb +31 -12
  119. data/lib/active_record/connection_handling.rb +37 -14
  120. data/lib/active_record/core.rb +89 -107
  121. data/lib/active_record/counter_cache.rb +13 -24
  122. data/lib/active_record/dynamic_matchers.rb +1 -20
  123. data/lib/active_record/enum.rb +113 -76
  124. data/lib/active_record/errors.rb +87 -48
  125. data/lib/active_record/explain_registry.rb +1 -1
  126. data/lib/active_record/explain_subscriber.rb +1 -1
  127. data/lib/active_record/fixture_set/file.rb +26 -5
  128. data/lib/active_record/fixtures.rb +76 -40
  129. data/lib/active_record/gem_version.rb +3 -3
  130. data/lib/active_record/inheritance.rb +32 -40
  131. data/lib/active_record/integration.rb +4 -4
  132. data/lib/active_record/internal_metadata.rb +56 -0
  133. data/lib/active_record/legacy_yaml_adapter.rb +18 -2
  134. data/lib/active_record/locale/en.yml +3 -2
  135. data/lib/active_record/locking/optimistic.rb +15 -15
  136. data/lib/active_record/locking/pessimistic.rb +1 -1
  137. data/lib/active_record/log_subscriber.rb +43 -21
  138. data/lib/active_record/migration/command_recorder.rb +59 -18
  139. data/lib/active_record/migration/compatibility.rb +126 -0
  140. data/lib/active_record/migration.rb +364 -109
  141. data/lib/active_record/model_schema.rb +128 -38
  142. data/lib/active_record/nested_attributes.rb +58 -29
  143. data/lib/active_record/null_relation.rb +16 -8
  144. data/lib/active_record/persistence.rb +121 -80
  145. data/lib/active_record/query_cache.rb +15 -18
  146. data/lib/active_record/querying.rb +10 -9
  147. data/lib/active_record/railtie.rb +27 -18
  148. data/lib/active_record/railties/controller_runtime.rb +1 -1
  149. data/lib/active_record/railties/databases.rake +58 -45
  150. data/lib/active_record/readonly_attributes.rb +1 -1
  151. data/lib/active_record/reflection.rb +282 -115
  152. data/lib/active_record/relation/batches/batch_enumerator.rb +67 -0
  153. data/lib/active_record/relation/batches.rb +139 -34
  154. data/lib/active_record/relation/calculations.rb +80 -102
  155. data/lib/active_record/relation/delegation.rb +7 -20
  156. data/lib/active_record/relation/finder_methods.rb +163 -81
  157. data/lib/active_record/relation/from_clause.rb +32 -0
  158. data/lib/active_record/relation/merger.rb +16 -42
  159. data/lib/active_record/relation/predicate_builder/array_handler.rb +11 -15
  160. data/lib/active_record/relation/predicate_builder/association_query_handler.rb +88 -0
  161. data/lib/active_record/relation/predicate_builder/base_handler.rb +17 -0
  162. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +17 -0
  163. data/lib/active_record/relation/predicate_builder/class_handler.rb +27 -0
  164. data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +57 -0
  165. data/lib/active_record/relation/predicate_builder/range_handler.rb +33 -0
  166. data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -1
  167. data/lib/active_record/relation/predicate_builder.rb +120 -107
  168. data/lib/active_record/relation/query_attribute.rb +19 -0
  169. data/lib/active_record/relation/query_methods.rb +308 -244
  170. data/lib/active_record/relation/record_fetch_warning.rb +49 -0
  171. data/lib/active_record/relation/spawn_methods.rb +4 -7
  172. data/lib/active_record/relation/where_clause.rb +174 -0
  173. data/lib/active_record/relation/where_clause_factory.rb +38 -0
  174. data/lib/active_record/relation.rb +176 -116
  175. data/lib/active_record/result.rb +4 -3
  176. data/lib/active_record/runtime_registry.rb +1 -1
  177. data/lib/active_record/sanitization.rb +95 -66
  178. data/lib/active_record/schema.rb +26 -22
  179. data/lib/active_record/schema_dumper.rb +62 -38
  180. data/lib/active_record/schema_migration.rb +11 -17
  181. data/lib/active_record/scoping/default.rb +23 -9
  182. data/lib/active_record/scoping/named.rb +49 -28
  183. data/lib/active_record/scoping.rb +32 -15
  184. data/lib/active_record/secure_token.rb +38 -0
  185. data/lib/active_record/serialization.rb +2 -4
  186. data/lib/active_record/statement_cache.rb +16 -14
  187. data/lib/active_record/store.rb +8 -3
  188. data/lib/active_record/suppressor.rb +58 -0
  189. data/lib/active_record/table_metadata.rb +68 -0
  190. data/lib/active_record/tasks/database_tasks.rb +58 -41
  191. data/lib/active_record/tasks/mysql_database_tasks.rb +16 -20
  192. data/lib/active_record/tasks/postgresql_database_tasks.rb +11 -2
  193. data/lib/active_record/tasks/sqlite_database_tasks.rb +5 -1
  194. data/lib/active_record/timestamp.rb +20 -9
  195. data/lib/active_record/touch_later.rb +58 -0
  196. data/lib/active_record/transactions.rb +138 -56
  197. data/lib/active_record/type/adapter_specific_registry.rb +130 -0
  198. data/lib/active_record/type/date.rb +2 -41
  199. data/lib/active_record/type/date_time.rb +2 -49
  200. data/lib/active_record/type/internal/abstract_json.rb +29 -0
  201. data/lib/active_record/type/internal/timezone.rb +15 -0
  202. data/lib/active_record/type/serialized.rb +15 -14
  203. data/lib/active_record/type/time.rb +10 -16
  204. data/lib/active_record/type/type_map.rb +4 -4
  205. data/lib/active_record/type.rb +66 -17
  206. data/lib/active_record/type_caster/connection.rb +29 -0
  207. data/lib/active_record/type_caster/map.rb +19 -0
  208. data/lib/active_record/type_caster.rb +7 -0
  209. data/lib/active_record/validations/absence.rb +23 -0
  210. data/lib/active_record/validations/associated.rb +10 -3
  211. data/lib/active_record/validations/length.rb +24 -0
  212. data/lib/active_record/validations/presence.rb +11 -12
  213. data/lib/active_record/validations/uniqueness.rb +30 -29
  214. data/lib/active_record/validations.rb +33 -32
  215. data/lib/active_record.rb +7 -2
  216. data/lib/rails/generators/active_record/migration/migration_generator.rb +7 -4
  217. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +8 -3
  218. data/lib/rails/generators/active_record/migration/templates/migration.rb +8 -1
  219. data/lib/rails/generators/active_record/migration.rb +7 -0
  220. data/lib/rails/generators/active_record/model/model_generator.rb +32 -15
  221. data/lib/rails/generators/active_record/model/templates/application_record.rb +5 -0
  222. data/lib/rails/generators/active_record/model/templates/model.rb +3 -0
  223. metadata +58 -34
  224. data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -491
  225. data/lib/active_record/connection_adapters/postgresql/array_parser.rb +0 -93
  226. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +0 -11
  227. data/lib/active_record/connection_adapters/postgresql/oid/float.rb +0 -21
  228. data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +0 -13
  229. data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +0 -11
  230. data/lib/active_record/connection_adapters/postgresql/oid/time.rb +0 -11
  231. data/lib/active_record/serializers/xml_serializer.rb +0 -193
  232. data/lib/active_record/type/big_integer.rb +0 -13
  233. data/lib/active_record/type/binary.rb +0 -50
  234. data/lib/active_record/type/boolean.rb +0 -31
  235. data/lib/active_record/type/decimal.rb +0 -50
  236. data/lib/active_record/type/decimal_without_scale.rb +0 -11
  237. data/lib/active_record/type/decorator.rb +0 -14
  238. data/lib/active_record/type/float.rb +0 -19
  239. data/lib/active_record/type/integer.rb +0 -59
  240. data/lib/active_record/type/mutable.rb +0 -16
  241. data/lib/active_record/type/numeric.rb +0 -36
  242. data/lib/active_record/type/string.rb +0 -40
  243. data/lib/active_record/type/text.rb +0 -11
  244. data/lib/active_record/type/time_value.rb +0 -38
  245. data/lib/active_record/type/unsigned_integer.rb +0 -15
  246. data/lib/active_record/type/value.rb +0 -105
data/CHANGELOG.md CHANGED
@@ -1,1918 +1,2120 @@
1
- ## Rails 4.2.6 (March 07, 2016) ##
1
+ ## Rails 5.0.0 (June 30, 2016) ##
2
2
 
3
- * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
4
- the same table definition would only create one foreign key.
3
+ * Ensure hashes can be assigned to attributes created using `composed_of`.
4
+ Fixes #25210.
5
5
 
6
- *George Millo*
6
+ *Sean Griffin*
7
7
 
8
- * Fix regression in dirty attribute tracking after #dup. Changes to the
9
- clone no longer show as changed attributes in the original object.
8
+ * Fix logging edge case where if an attribute was of the binary type and
9
+ was provided as a Hash.
10
10
 
11
- *Dominic Cleal*
11
+ *Jon Moss*
12
12
 
13
- * Fix regression when loading fixture files with symbol keys.
13
+ * Handle JSON deserialization correctly if the column default from database
14
+ adapter returns `''` instead of `nil`.
14
15
 
15
- Closes #22584.
16
+ *Johannes Opper*
16
17
 
17
- *Yves Senn*
18
+ * PostgreSQL: Support Expression Indexes and Operator Classes.
18
19
 
19
- * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
20
+ Example:
20
21
 
21
- Fixes #22346.
22
+ create_table :users do |t|
23
+ t.string :name
24
+ t.index 'lower(name) varchar_pattern_ops'
25
+ end
22
26
 
23
- *Nick Muerdter*, *ckoenig*
27
+ Fixes #19090, #21765, #21819, #24359.
24
28
 
25
- * Introduce `connection.data_sources` and `connection.data_source_exists?`.
26
- These methods determine what relations can be used to back Active Record
27
- models (usually tables and views).
29
+ *Ryuta Kamizono*
28
30
 
29
- *Yves Senn*, *Matthew Draper*
31
+ * MySQL: Prepared statements support.
30
32
 
33
+ To enable, set `prepared_statements: true` in config/database.yml.
34
+ Requires mysql2 0.4.4+.
31
35
 
32
- ## Rails 4.2.5.2 (February 26, 2016) ##
36
+ *Ryuta Kamizono*
33
37
 
34
- * No changes.
38
+ * Schema dumper: Indexes are now included in the `create_table` block
39
+ instead of listed afterward as separate `add_index` lines.
35
40
 
41
+ This tidies up schema.rb and makes it easy to read as a list of tables.
36
42
 
37
- ## Rails 4.2.5.1 (January 25, 2015) ##
43
+ Bonus: Allows databases that support it (MySQL) to perform as single
44
+ `CREATE TABLE` query, no additional query per index.
38
45
 
39
- * No changes.
46
+ *Ryuta Kamizono*
40
47
 
48
+ * SQLite: Fix uniqueness validation when values exceed the column limit.
41
49
 
42
- ## Rails 4.2.5 (November 12, 2015) ##
50
+ SQLite doesn't impose length restrictions on strings, BLOBs, or numeric
51
+ values. It treats them as helpful metadata. When we truncate strings
52
+ before checking uniqueness, we'd miss values that exceed the column limit.
43
53
 
44
- * No longer pass deprecated option `-i` to `pg_dump`.
54
+ Other databases enforce length limits. A large value will pass uniqueness
55
+ validation since the column limit guarantees no value that long exists.
56
+ When we insert the row, it'll raise `ActiveRecord::ValueTooLong` as we
57
+ expect.
45
58
 
46
- *Paul Sadauskas*
59
+ This fixes edge-case incorrect validation failures for values that exceed
60
+ the column limit but are identical to an existing value *when truncated*.
61
+ Now these will pass validation and raise an exception.
47
62
 
48
- * Set `scope.reordering_value` to `true` if :reordering values are specified.
63
+ *Ryuta Kamizono*
49
64
 
50
- Fixes #21886.
65
+ * Raise `ActiveRecord::ValueTooLong` when column limits are exceeded.
66
+ Supported by MySQL and PostgreSQL adapters.
51
67
 
52
- *Hiroaki Izu*
68
+ *Ryuta Kamizono*
53
69
 
54
- * Avoid disabling errors on the PostgreSQL connection when enabling the
55
- standard_conforming_strings setting. Errors were previously disabled because
56
- the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
57
- versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
58
- setting exists. Disabling errors caused problems when using a connection
59
- pooling tool like PgBouncer because it's not guaranteed to have the same
60
- connection between calls to `execute` and it could leave the connection
61
- with errors disabled.
70
+ * Migrations: `#foreign_key` respects `table_name_prefix` and `_suffix`.
62
71
 
63
- Fixes #22101.
72
+ *Ryuta Kamizono*
64
73
 
65
- *Harry Marr*
74
+ * SQLite: Force NOT NULL primary keys.
66
75
 
67
- * Includes HABTM returns correct size now. It's caused by the join dependency
68
- only instantiates one HABTM object because the join table hasn't a primary key.
76
+ From SQLite docs: https://www.sqlite.org/lang_createtable.html
77
+ According to the SQL standard, PRIMARY KEY should always imply NOT
78
+ NULL. Unfortunately, due to a bug in some early versions, this is not
79
+ the case in SQLite. Unless the column is an INTEGER PRIMARY KEY or the
80
+ table is a WITHOUT ROWID table or the column is declared NOT NULL,
81
+ SQLite allows NULL values in a PRIMARY KEY column. SQLite could be
82
+ fixed to conform to the standard, but doing so might break legacy
83
+ applications. Hence, it has been decided to merely document the fact
84
+ that SQLite allowing NULLs in most PRIMARY KEY columns.
69
85
 
70
- Fixes #16032.
86
+ Now we override column options to explicitly set NOT NULL rather than rely
87
+ on implicit NOT NULL like MySQL and PostgreSQL adapters.
71
88
 
72
- Examples:
89
+ *Ryuta Kamizono*
73
90
 
74
- before:
91
+ * Added notice when a database is successfully created or dropped.
75
92
 
76
- Project.first.salaried_developers.size # => 3
77
- Project.includes(:salaried_developers).first.salaried_developers.size # => 1
93
+ Example:
78
94
 
79
- after:
95
+ $ bin/rails db:create
96
+ Created database 'blog_development'
97
+ Created database 'blog_test'
80
98
 
81
- Project.first.salaried_developers.size # => 3
82
- Project.includes(:salaried_developers).first.salaried_developers.size # => 3
99
+ $ bin/rails db:drop
100
+ Dropped database 'blog_development'
101
+ Dropped database 'blog_test'
83
102
 
84
- *Bigxiang*
103
+ Changed older notices
104
+ `blog_development already exists` to `Database 'blog_development' already exists`.
105
+ and
106
+ `Couldn't drop blog_development` to `Couldn't drop database 'blog_development'`.
85
107
 
86
- * Descriptive error message when fixtures contain a missing column.
108
+ *bogdanvlviv*
87
109
 
88
- Closes #21201.
110
+ * Database comments. Annotate database objects (tables, columns, indexes)
111
+ with comments stored in database metadata. PostgreSQL & MySQL support.
89
112
 
90
- *Yves Senn*
113
+ create_table :pages, force: :cascade, comment: 'CMS content pages' do |t|
114
+ t.string :path, comment: 'Path fragment of page URL used for routing'
115
+ t.string :locale, comment: 'RFC 3066 locale code of website language section'
116
+ t.index [:path, :locale], comment: 'Look up pages by URI'
117
+ end
91
118
 
92
- * `bin/rake db:migrate` uses
93
- `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
94
- `Migrator.migrations_paths`.
119
+ *Andrey Novikov*
95
120
 
96
- *Tobias Bielohlawek*
121
+ * Add `quoted_time` for truncating the date part of a TIME column value.
122
+ This fixes queries on TIME column on MariaDB, as it doesn't ignore the
123
+ date part of the string when it coerces to time.
97
124
 
98
- * Fix `rewhere` in a `has_many` association.
125
+ *Ryuta Kamizono*
99
126
 
100
- Fixes #21955.
127
+ * Properly accept all valid JSON primitives in the JSON data type.
101
128
 
102
- *Josh Branchaud*, *Kal*
129
+ Fixes #24234
103
130
 
104
- * Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
105
- drying up Kernel.system() calls within this namespace and to avoid
106
- shell expansion by using a paramter list instead of string as arguments
107
- for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
108
- test units passing.
131
+ *Sean Griffin*
109
132
 
110
- *Bryan Paxton*
133
+ * MariaDB 5.3+ supports microsecond datetime precision.
111
134
 
112
- * Avoid leaking the first relation we call `first` on, per model.
135
+ *Jeremy Daer*
113
136
 
114
- Fixes #21921.
137
+ * Delegate `none?` and `one?`. Now they can be invoked as model class methods.
115
138
 
116
- *Matthew Draper*, *Jean Boussier*
139
+ Example:
140
+
141
+ # When no record is found on the table
142
+ Topic.none? # => true
143
+
144
+ # When only one record is found on the table
145
+ Topic.one? # => true
146
+
147
+ *Kenta Shirai*
148
+
149
+ * The form builder now properly displays values when passing a proc form
150
+ default to the attributes API.
117
151
 
118
- * Allow deserialization of Active Record models that were YAML encoded prior
119
- to Rails 4.2
152
+ Fixes #24249.
120
153
 
121
154
  *Sean Griffin*
122
155
 
123
- * Correctly apply `unscope` when preloading through associations.
156
+ * The schema cache is now cleared after the `db:migrate` task is run.
124
157
 
125
- *Jimmy Bourassa*
158
+ Closes #24273.
126
159
 
127
- * Ensure `select` quotes aliased attributes, even when using `from`.
160
+ *Chris Arcand*
128
161
 
129
- Fixes #21488
162
+ * MySQL: strict mode respects other SQL modes rather than overwriting them.
163
+ Setting `strict: true` adds `STRICT_ALL_TABLES` to `sql_mode`. Setting
164
+ `strict: false` removes `STRICT_TRANS_TABLES`, `STRICT_ALL_TABLES`, and
165
+ `TRADITIONAL` from `sql_mode`.
130
166
 
131
- *Sean Griffin & @johanlunds*
167
+ *Ryuta Kamizono*
132
168
 
133
- * Correct query for PostgreSQL 8.2 compatibility.
169
+ * Execute default_scope defined by abstract class in the context of subclass.
134
170
 
135
- *Ben Murphy*, *Matthew Draper*
171
+ Fixes #23413.
172
+ Fixes #10658.
136
173
 
137
- * Uniqueness validator raises descriptive error when running on a persisted
138
- record without primary key.
174
+ *Mehmet Emin İNAÇ*
139
175
 
140
- Closes #21304.
176
+ * Fix an issue when preloading associations with extensions.
177
+ Previously every association with extension methods was transformed into an
178
+ instance dependent scope. This is no longer the case.
179
+
180
+ Fixes #23934.
141
181
 
142
182
  *Yves Senn*
143
183
 
184
+ * Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`.
185
+ Use the `{insert|update|delete}` public methods instead.
144
186
 
145
- ## Rails 4.2.4 (August 24, 2015) ##
187
+ *Ryuta Kamizono*
146
188
 
147
- * Skip statement cache on through association reader.
189
+ * Added a configuration option to have active record raise an ArgumentError
190
+ if the order or limit is ignored in a batch query, rather than logging a
191
+ warning message.
148
192
 
149
- If the through class has default scopes we should skip the statement
150
- cache.
193
+ *Scott Ringwelski*
151
194
 
152
- Closes #20745.
195
+ * Honour the order of the joining model in a `has_many :through` association when eager loading.
153
196
 
154
- *Rafael Mendonça França*
197
+ Example:
155
198
 
156
- * Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
157
- the limit: 8 was not coming through. This caused it to become Int[] data type
158
- after doing a rebuild off of schema.rb.
199
+ The below will now follow the order of `by_lines` when eager loading `authors`.
159
200
 
160
- *Jake Waller*
201
+ class Article < ActiveRecord::Base
202
+ has_many :by_lines, -> { order(:position) }
203
+ has_many :authors, through: :by_lines
204
+ end
161
205
 
162
- * Fix state being carried over from previous transaction.
206
+ Fixes #17864.
163
207
 
164
- Considering the following example where `name` is a required attribute.
165
- Before we had `new_record?` returning `true` for a persisted record:
208
+ *Yasyf Mohamedali*, *Joel Turkel*
166
209
 
167
- author = Author.create! name: 'foo'
168
- author.name = nil
169
- author.save # => false
170
- author.new_record? # => true
210
+ * Ensure that the Suppressor runs before validations.
171
211
 
172
- Fixes #20824.
212
+ This moves the suppressor up to be run before validations rather than after
213
+ validations. There's no reason to validate a record you aren't planning on saving.
173
214
 
174
- *Roque Pinel*
215
+ *Eileen M. Uchitelle*
175
216
 
176
- * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
177
- when validating associations.
217
+ * Save many-to-many objects based on association primary key.
178
218
 
179
- Fixes #20882.
219
+ Fixes #20995.
180
220
 
181
- *Sean Griffin*
221
+ *himesh-r*
182
222
 
183
- * Fix through associations using scopes having the scope merged multiple
184
- times.
223
+ * Ensure that mutations of the array returned from `ActiveRecord::Relation#to_a`
224
+ do not affect the original relation, by returning a duplicate array each time.
185
225
 
186
- Fixes #20721.
187
- Fixes #20727.
226
+ This brings the behavior in line with `CollectionProxy#to_a`, which was
227
+ already more careful.
188
228
 
189
- *Sean Griffin*
229
+ *Matthew Draper*
190
230
 
191
- * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
192
- other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
231
+ * Fixed `where` for polymorphic associations when passed an array containing different types.
193
232
 
194
- Fixes #20743.
233
+ Fixes #17011.
195
234
 
196
- *Yves Senn*
235
+ Example:
197
236
 
198
- * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
199
- a wrong type to a namespaced association.
237
+ PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
238
+ # => SELECT "price_estimates".* FROM "price_estimates"
239
+ WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
240
+ OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
200
241
 
201
- Fixes #20545.
242
+ *Philippe Huibonhoa*
202
243
 
203
- *Diego Carrion*
244
+ * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
245
+ the same table definition would only create one foreign key.
204
246
 
205
- * Prevent error when using `force_reload: true` on an unassigned polymorphic
206
- belongs_to association.
247
+ *George Millo*
207
248
 
208
- Fixes #20426.
249
+ * Fix a regression on has many association, where calling a child from parent in child's callback
250
+ results in same child records getting added repeatedly to target.
209
251
 
210
- *James Dabbs*
252
+ Fixes #13387.
211
253
 
254
+ *Bogdan Gusiev*, *Jon Hinson*
212
255
 
213
- ## Rails 4.2.3 (June 25, 2015) ##
256
+ * Rework `ActiveRecord::Relation#last`.
214
257
 
215
- * Let `WITH` queries (Common Table Expressions) be explainable.
258
+ 1. Never perform additional SQL on loaded relation
259
+ 2. Use SQL reverse order instead of loading relation if relation doesn't have limit
260
+ 3. Deprecated relation loading when SQL order can not be automatically reversed
216
261
 
217
- *Vladimir Kochnev*
262
+ Topic.order("title").load.last(3)
263
+ # before: SELECT ...
264
+ # after: No SQL
218
265
 
219
- * Fix n+1 query problem when eager loading nil associations (fixes #18312)
266
+ Topic.order("title").last
267
+ # before: SELECT * FROM `topics`
268
+ # after: SELECT * FROM `topics` ORDER BY `topics`.`title` DESC LIMIT 1
220
269
 
221
- *Sammy Larbi*
270
+ Topic.order("coalesce(author, title)").last
271
+ # before: SELECT * FROM `topics`
272
+ # after: Deprecation Warning for irreversible order
222
273
 
223
- * Fixed an error which would occur in dirty checking when calling
224
- `update_attributes` from a getter.
274
+ *Bogdan Gusiev*
225
275
 
226
- Fixes #20531.
276
+ * Allow `joins` to be unscoped.
227
277
 
228
- *Sean Griffin*
278
+ Fixes #13775.
229
279
 
230
- * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
231
- as columns.
280
+ *Takashi Kokubun*
232
281
 
233
- Fixes #20360.
282
+ * Add ActiveRecord `#second_to_last` and `#third_to_last` methods.
234
283
 
235
- *Sean Griffin*
284
+ *Brian Christian*
236
285
 
237
- * Clear query cache when `ActiveRecord::Base#reload` is called.
286
+ * Added `numeric` helper into migrations.
238
287
 
239
- *Shane Hender*
288
+ Example:
240
289
 
241
- * Pass `:extend` option for `has_and_belongs_to_many` associations to the
242
- underlying `has_many :through`.
290
+ create_table(:numeric_types) do |t|
291
+ t.numeric :numeric_type, precision: 10, scale: 2
292
+ end
243
293
 
244
- *Jaehyun Shin*
294
+ *Mehmet Emin İNAÇ*
245
295
 
246
- * Make `unscope` aware of "less than" and "greater than" conditions.
296
+ * Bumped the minimum supported version of PostgreSQL to >= 9.1.
297
+ Both PG 9.0 and 8.4 are past their end of life date:
298
+ http://www.postgresql.org/support/versioning/
247
299
 
248
- *TAKAHASHI Kazuaki*
300
+ *Remo Mueller*
249
301
 
250
- * Revert behavior of `db:schema:load` back to loading the full
251
- environment. This ensures that initializers are run.
302
+ * `ActiveRecord::Relation#reverse_order` throws `ActiveRecord::IrreversibleOrderError`
303
+ when the order can not be reversed using current trivial algorithm.
304
+ Also raises the same error when `#reverse_order` is called on
305
+ relation without any order and table has no primary key:
252
306
 
253
- Fixes #19545.
307
+ Topic.order("concat(author_name, title)").reverse_order
308
+ # Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC
309
+ # After: raises ActiveRecord::IrreversibleOrderError
310
+ Edge.all.reverse_order
311
+ # Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC
312
+ # After: raises ActiveRecord::IrreversibleOrderError
254
313
 
255
- *Yves Senn*
314
+ *Bogdan Gusiev*
256
315
 
257
- * Fix missing index when using `timestamps` with the `index` option.
316
+ * Improve schema_migrations insertion performance by inserting all versions
317
+ in one INSERT SQL.
258
318
 
259
- The `index` option used with `timestamps` should be passed to both
260
- `column` definitions for `created_at` and `updated_at` rather than just
261
- the first.
319
+ *Akira Matsuda*, *Naoto Koshikawa*
262
320
 
263
- *Paul Mucur*
321
+ * Using `references` or `belongs_to` in migrations will always add index
322
+ for the referenced column by default, without adding `index: true` option
323
+ to generated migration file. Users can opt out of this by passing
324
+ `index: false`.
264
325
 
265
- * Rename `:class` to `:anonymous_class` in association options.
326
+ Fixes #18146.
266
327
 
267
- Fixes #19659.
328
+ *Matthew Draper*, *Prathamesh Sonpatki*
268
329
 
269
- *Andrew White*
330
+ * Run `type` attributes through attributes API type-casting before
331
+ instantiating the corresponding subclass. This makes it possible to define
332
+ custom STI mappings.
270
333
 
271
- * Fixed a bug where uniqueness validations would error on out of range values,
272
- even if an validation should have prevented it from hitting the database.
334
+ Fixes #21986.
273
335
 
274
- *Andrey Voronkov*
336
+ *Yves Senn*
275
337
 
276
- * Foreign key related methods in the migration DSL respect
277
- `ActiveRecord::Base.pluralize_table_names = false`.
338
+ * Don't try to quote functions or expressions passed to `:default` option if
339
+ they are passed as procs.
278
340
 
279
- Fixes #19643.
341
+ This will generate proper query with the passed function or expression for
342
+ the default option, instead of trying to quote it in incorrect fashion.
280
343
 
281
- *Mehmet Emin İNAÇ*
344
+ Example:
282
345
 
283
- * Reduce memory usage from loading types on pg.
346
+ create_table :posts do |t|
347
+ t.datetime :published_at, default: -> { 'NOW()' }
348
+ end
284
349
 
285
- Fixes #19578.
350
+ *Ryuta Kamizono*
286
351
 
287
- *Sean Griffin*
352
+ * Fix regression when loading fixture files with symbol keys.
288
353
 
289
- * Fix referencing wrong table aliases while joining tables of has many through
290
- association (only when calling calculation methods).
354
+ Fixes #22584.
291
355
 
292
- Fixes #19276.
356
+ *Yves Senn*
293
357
 
294
- *pinglamb*
358
+ * Use `version` column as primary key for schema_migrations table because
359
+ `schema_migrations` versions are guaranteed to be unique.
295
360
 
296
- * Don't attempt to update counter caches, when the column wasn't selected.
361
+ This makes it possible to use `update_attributes` on models that do
362
+ not have a primary key.
297
363
 
298
- Fixes #19437.
364
+ *Richard Schneeman*
299
365
 
300
- *Sean Griffin*
366
+ * Add short-hand methods for text and blob types in MySQL.
301
367
 
302
- * Correctly persist a serialized attribute that has been returned to
303
- its default value by an in-place modification.
368
+ In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
369
+ But in MySQL, these have limited length for each types (ref #21591, #21619).
370
+ This change adds short-hand methods for each text and blob types.
304
371
 
305
- Fixes #19467.
372
+ Example:
306
373
 
307
- *Matthew Draper*
374
+ create_table :foos do |t|
375
+ t.tinyblob :tiny_blob
376
+ t.mediumblob :medium_blob
377
+ t.longblob :long_blob
378
+ t.tinytext :tiny_text
379
+ t.mediumtext :medium_text
380
+ t.longtext :long_text
381
+ end
308
382
 
309
- * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
383
+ *Ryuta Kamizono*
310
384
 
311
- *James Cox*
385
+ * Take into account UTC offset when assigning string representation of
386
+ timestamp with offset specified to attribute of time type.
312
387
 
313
- * Dont enroll records in the transaction if they dont have commit callbacks.
314
- That was causing a memory grow problem when creating a lot of records inside a transaction.
388
+ *Andrey Novikov*
315
389
 
316
- Fixes #15549.
390
+ * When calling `first` with a `limit` argument, return directly from the
391
+ `loaded?` records if available.
317
392
 
318
- *Will Bryant*, *Aaron Patterson*
393
+ *Ben Woosley*
319
394
 
320
- * Correctly create through records when created on a has many through
321
- association when using `where`.
395
+ * Deprecate sending the `offset` argument to `find_nth`. Please use the
396
+ `offset` method on relation instead.
322
397
 
323
- Fixes #19073.
398
+ *Ben Woosley*
324
399
 
325
- *Sean Griffin*
400
+ * Limit record touching to once per transaction.
326
401
 
402
+ If you have a parent/grand-parent relation like:
327
403
 
328
- ## Rails 4.2.2 (June 16, 2015) ##
404
+ Comment belongs_to :message, touch: true
405
+ Message belongs_to :project, touch: true
406
+ Project belongs_to :account, touch: true
329
407
 
330
- * No Changes *
408
+ When the lowest entry(`Comment`) is saved, now, it won't repeat the touch
409
+ call multiple times for the parent records.
331
410
 
411
+ Related #18606.
332
412
 
333
- ## Rails 4.2.1 (March 19, 2015) ##
413
+ *arthurnn*
334
414
 
335
- * Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
415
+ * Order the result of `find(ids)` to match the passed array, if the relation
416
+ has no explicit order defined.
336
417
 
337
- Fixes #17139.
418
+ Fixes #20338.
338
419
 
339
- *Miklos Fazekas*
420
+ *Miguel Grazziotin*, *Matthew Draper*
340
421
 
341
- * `remove_reference` with `foreign_key: true` removes the foreign key before
342
- removing the column. This fixes a bug where it was not possible to remove
343
- the column on MySQL.
422
+ * Omit default limit values in dumped schema. It's tidier, and if the defaults
423
+ change in the future, we can address that via Migration API Versioning.
344
424
 
345
- Fixes #18664.
425
+ *Jean Boussier*
346
426
 
347
- *Yves Senn*
427
+ * Support passing the schema name as a prefix to table name in
428
+ `ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
429
+ be considered a full part of the index name, and only the schema in the
430
+ current search path would be considered.
348
431
 
349
- * Add a `:foreign_key` option to `references` and associated migration
350
- methods. The model and migration generators now use this option, rather than
351
- the `add_foreign_key` form.
432
+ *Grey Baker*
352
433
 
353
- *Sean Griffin*
434
+ * Ignore index name in `index_exists?` and `remove_index` when not passed a
435
+ name to check for.
354
436
 
355
- * Fix rounding problem for PostgreSQL timestamp column.
437
+ *Grey Baker*
356
438
 
357
- If timestamp column have the precision, it need to format according to
358
- the precision of timestamp column.
439
+ * Extract support for the legacy `mysql` database adapter from core. It will
440
+ live on in a separate gem for now, but most users should just use `mysql2`.
359
441
 
360
- *Ryuta Kamizono*
442
+ *Abdelkader Boudih*
361
443
 
362
- * Respect the database default charset for `schema_migrations` table.
444
+ * ApplicationRecord is a new superclass for all app models, analogous to app
445
+ controllers subclassing ApplicationController instead of
446
+ ActionController::Base. This gives apps a single spot to configure app-wide
447
+ model behavior.
363
448
 
364
- The charset of `version` column in `schema_migrations` table is depend
365
- on the database default charset and collation rather than the encoding
366
- of the connection.
449
+ Newly generated applications have `app/models/application_record.rb`
450
+ present by default.
367
451
 
368
- *Ryuta Kamizono*
452
+ *Genadi Samokovarov*
369
453
 
370
- * Respect custom primary keys for associations when calling `Relation#where`
454
+ * Version the API presented to migration classes, so we can change parameter
455
+ defaults without breaking existing migrations, or forcing them to be
456
+ rewritten through a deprecation cycle.
371
457
 
372
- Fixes #18813.
458
+ New migrations specify the Rails version they were written for:
373
459
 
374
- *Sean Griffin*
460
+ class AddStatusToOrders < ActiveRecord::Migration[5.0]
461
+ def change
462
+ # ...
463
+ end
464
+ end
375
465
 
376
- * Fixed several edge cases which could result in a counter cache updating
377
- twice or not updating at all for `has_many` and `has_many :through`.
466
+ *Matthew Draper*, *Ravil Bayramgalin*
378
467
 
379
- Fixes #10865.
468
+ * Use bind params for `limit` and `offset`. This will generate significantly
469
+ fewer prepared statements for common tasks like pagination. To support this
470
+ change, passing a string containing a comma to `limit` has been deprecated,
471
+ and passing an Arel node to `limit` is no longer supported.
472
+
473
+ Fixes #22250.
380
474
 
381
475
  *Sean Griffin*
382
476
 
383
- * Foreign keys added by migrations were given random, generated names. This
384
- meant a different `structure.sql` would be generated every time a developer
385
- ran migrations on their machine.
477
+ * Introduce after_{create,update,delete}_commit callbacks.
386
478
 
387
- The generated part of foreign key names is now a hash of the table name and
388
- column name, which is consistent every time you run the migration.
479
+ Before:
389
480
 
390
- *Chris Sinjakli*
481
+ after_commit :add_to_index_later, on: :create
482
+ after_commit :update_in_index_later, on: :update
483
+ after_commit :remove_from_index_later, on: :destroy
391
484
 
392
- * Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
485
+ After:
393
486
 
394
- SplitTest.group(:key).count
395
- Property.group(:value).count
487
+ after_create_commit :add_to_index_later
488
+ after_update_commit :update_in_index_later
489
+ after_destroy_commit :remove_from_index_later
396
490
 
397
- *Bogdan Gusiev*
491
+ Fixes #22515.
398
492
 
399
- * Don't define autosave association callbacks twice from
400
- `accepts_nested_attributes_for`.
493
+ *Genadi Samokovarov*
401
494
 
402
- Fixes #18704.
495
+ * Respect the column default values for `inheritance_column` when
496
+ instantiating records through the base class.
403
497
 
404
- *Sean Griffin*
498
+ Fixes #17121.
405
499
 
406
- * Integer types will no longer raise a `RangeError` when assigning an
407
- attribute, but will instead raise when going to the database.
500
+ Example:
408
501
 
409
- Fixes several vague issues which were never reported directly. See the
410
- commit message from the commit which added this line for some examples.
502
+ # The schema of BaseModel has `t.string :type, default: 'SubType'`
503
+ subtype = BaseModel.new
504
+ assert_equals SubType, subtype.class
411
505
 
412
- *Sean Griffin*
506
+ *Kuldeep Aggarwal*
413
507
 
414
- * Values which would error while being sent to the database (such as an
415
- ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
416
- assignment. They will still error when sent to the database, but you are
417
- given the ability to re-assign it to a valid value.
508
+ * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
418
509
 
419
- Fixes #18580.
510
+ Fixes #22346.
420
511
 
421
- *Sean Griffin*
512
+ *Nick Muerdter*, *ckoenig*
422
513
 
423
- * Don't remove join dependencies in `Relation#exists?`
514
+ * Add schema dumping support for PostgreSQL geometric data types.
424
515
 
425
- Fixes #18632.
516
+ *Ryuta Kamizono*
426
517
 
427
- *Sean Griffin*
518
+ * Except keys of `build_record`'s argument from `create_scope` in `initialize_attributes`.
428
519
 
429
- * Invalid values assigned to a JSON column are assumed to be `nil`.
520
+ Fixes #21893.
430
521
 
431
- Fixes #18629.
522
+ *Yuichiro Kaneko*
432
523
 
433
- *Sean Griffin*
524
+ * Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
525
+ Also deprecate passing arguments to `#tables`.
526
+ And deprecate `table_exists?`.
434
527
 
435
- * No longer issue deprecation warning when including a scope with extensions.
436
- Previously every scope with extension methods was transformed into an
437
- instance dependent scope. Including such a scope would wrongfully issue a
438
- deprecation warning. This is no longer the case.
528
+ The `#tables` method of some adapters (mysql, mysql2, sqlite3) would return
529
+ both tables and views while others (postgresql) just return tables. To make
530
+ their behavior consistent, `#tables` will return only tables in the future.
439
531
 
440
- Fixes #18467.
532
+ The `#table_exists?` method would check both tables and views. To make
533
+ their behavior consistent with `#tables`, `#table_exists?` will check only
534
+ tables in the future.
441
535
 
442
- *Yves Senn*
536
+ *Yuichiro Kaneko*
443
537
 
444
- * Correctly use the type provided by `serialize` when updating records using
445
- optimistic locking.
538
+ * Improve support for non Active Record objects on `validates_associated`
446
539
 
447
- Fixes #18385.
540
+ Skipping `marked_for_destruction?` when the associated object does not responds
541
+ to it make easier to validate virtual associations built on top of Active Model
542
+ objects and/or serialized objects that implement a `valid?` instance method.
448
543
 
449
- *Sean Griffin*
544
+ *Kassio Borges*, *Lucas Mazza*
450
545
 
451
- * `attribute_will_change!` will no longer cause non-persistable attributes to
452
- be sent to the database.
546
+ * Change connection management middleware to return a new response with
547
+ a body proxy, rather than mutating the original.
453
548
 
454
- Fixes #18407.
549
+ *Kevin Buchanan*
455
550
 
456
- *Sean Griffin*
551
+ * Make `db:migrate:status` to render `1_some.rb` format migrate files.
457
552
 
458
- * Format the datetime string according to the precision of the datetime field.
553
+ These files are in `db/migrate`:
459
554
 
460
- Incompatible to rounding behavior between MySQL 5.6 and earlier.
555
+ * 1_valid_people_have_last_names.rb
556
+ * 20150819202140_irreversible_migration.rb
557
+ * 20150823202140_add_admin_flag_to_users.rb
558
+ * 20150823202141_migration_tests.rb
559
+ * 2_we_need_reminders.rb
560
+ * 3_innocent_jointable.rb
461
561
 
462
- In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
463
- is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
562
+ Before:
464
563
 
465
- http://bugs.mysql.com/bug.php?id=68760
564
+ $ bundle exec rake db:migrate:status
565
+ ...
566
+
567
+ Status Migration ID Migration Name
568
+ --------------------------------------------------
569
+ up 001 ********** NO FILE **********
570
+ up 002 ********** NO FILE **********
571
+ up 003 ********** NO FILE **********
572
+ up 20150819202140 Irreversible migration
573
+ up 20150823202140 Add admin flag to users
574
+ up 20150823202141 Migration tests
575
+
576
+ After:
577
+
578
+ $ bundle exec rake db:migrate:status
579
+ ...
580
+
581
+ Status Migration ID Migration Name
582
+ --------------------------------------------------
583
+ up 001 Valid people have last names
584
+ up 002 We need reminders
585
+ up 003 Innocent jointable
586
+ up 20150819202140 Irreversible migration
587
+ up 20150823202140 Add admin flag to users
588
+ up 20150823202141 Migration tests
589
+
590
+ *Yuichiro Kaneko*
591
+
592
+ * Define `ActiveRecord::Sanitization.sanitize_sql_for_order` and use it inside
593
+ `preprocess_order_args`.
594
+
595
+ *Yuichiro Kaneko*
596
+
597
+ * Allow bigint with default nil for avoiding auto increment primary key.
466
598
 
467
599
  *Ryuta Kamizono*
468
600
 
469
- * Allow precision option for MySQL datetimes.
601
+ * Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`.
602
+
603
+ We should omit the collation entirely rather than providing a default.
604
+ Then the choice is the responsibility of the server and MySQL distribution.
470
605
 
471
606
  *Ryuta Kamizono*
472
607
 
473
- * Clear query cache on rollback.
608
+ * Alias `ActiveRecord::Relation#left_joins` to
609
+ `ActiveRecord::Relation#left_outer_joins`.
610
+
611
+ *Takashi Kokubun*
612
+
613
+ * Use advisory locking to raise a `ConcurrentMigrationError` instead of
614
+ attempting to migrate when another migration is currently running.
615
+
616
+ *Sam Davies*
617
+
618
+ * Added `ActiveRecord::Relation#left_outer_joins`.
619
+
620
+ Example:
621
+
622
+ User.left_outer_joins(:posts)
623
+ # => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON
624
+ "posts"."user_id" = "users"."id"
625
+
626
+ *Florian Thomas*
627
+
628
+ * Support passing an array to `order` for SQL parameter sanitization.
629
+
630
+ *Aaron Suggs*
631
+
632
+ * Avoid disabling errors on the PostgreSQL connection when enabling the
633
+ `standard_conforming_strings` setting. Errors were previously disabled because
634
+ the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
635
+ versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
636
+ setting exists. Disabling errors caused problems when using a connection
637
+ pooling tool like PgBouncer because it's not guaranteed to have the same
638
+ connection between calls to `execute` and it could leave the connection
639
+ with errors disabled.
640
+
641
+ Fixes #22101.
642
+
643
+ *Harry Marr*
644
+
645
+ * Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
646
+
647
+ Fixes #21886.
474
648
 
475
- *Florian Weingarten*
649
+ *Hiroaki Izu*
476
650
 
477
- * Fixed setting of foreign_key for through associations while building of new record.
651
+ * Add support for bidirectional destroy dependencies.
478
652
 
479
- Fixes #12698.
653
+ Fixes #13609.
480
654
 
481
- *Ivan Antropov*
655
+ Example:
482
656
 
483
- * Fixed automatic inverse_of for models nested in module.
657
+ class Content < ActiveRecord::Base
658
+ has_one :position, dependent: :destroy
659
+ end
484
660
 
485
- *Andrew McCloud*
661
+ class Position < ActiveRecord::Base
662
+ belongs_to :content, dependent: :destroy
663
+ end
486
664
 
487
- * Fix `reaping_frequency` option when the value is a string.
665
+ *Seb Jacobs*
488
666
 
489
- This usually happens when it is configured using `DATABASE_URL`.
667
+ * Includes HABTM returns correct size now. It's caused by the join dependency
668
+ only instantiates one HABTM object because the join table hasn't a primary key.
490
669
 
491
- *korbin*
670
+ Fixes #16032.
492
671
 
493
- * Fix error message when trying to create an associated record and the foreign
494
- key is missing.
672
+ Examples:
495
673
 
496
- Before this fix the following exception was being raised:
674
+ before:
497
675
 
498
- NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
676
+ Project.first.salaried_developers.size # => 3
677
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 1
499
678
 
500
- Now the message is:
679
+ after:
501
680
 
502
- ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
681
+ Project.first.salaried_developers.size # => 3
682
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 3
503
683
 
504
- *Rafael Mendonça França*
684
+ *Bigxiang*
505
685
 
506
- * Fix change detection problem for PostgreSQL bytea type and
507
- `ArgumentError: string contains null byte` exception with pg-0.18.
686
+ * Add option to index errors in nested attributes.
508
687
 
509
- Fixes #17680.
688
+ For models which have nested attributes, errors within those models will
689
+ now be indexed if `:index_errors` option is set to true when defining a
690
+ `has_many` relationship or by setting the configuration option
691
+ `config.active_record.index_nested_attribute_errors` to true.
510
692
 
511
- *Lars Kanis*
693
+ Example:
512
694
 
513
- * When a table has a composite primary key, the `primary_key` method for
514
- SQLite3 and PostgreSQL adapters was only returning the first field of the key.
515
- Ensures that it will return nil instead, as Active Record doesn't support
516
- composite primary keys.
695
+ class Guitar < ActiveRecord::Base
696
+ has_many :tuning_pegs, index_errors: true
697
+ accepts_nested_attributes_for :tuning_pegs
698
+ end
517
699
 
518
- Fixes #18070.
700
+ class TuningPeg < ActiveRecord::Base
701
+ belongs_to :guitar
702
+ validates_numericality_of :pitch
703
+ end
519
704
 
520
- *arthurnn*
705
+ # Before
706
+ guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
521
707
 
522
- * Ensure `first!` and friends work on loaded associations.
708
+ # After
709
+ guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]
523
710
 
524
- Fixes #18237.
711
+ *Michael Probber*, *Terence Sun*
525
712
 
526
- *Sean Griffin*
713
+ * Exit with non-zero status for failed database rake tasks.
527
714
 
528
- * Dump the default `nil` for PostgreSQL UUID primary key.
715
+ *Jay Hayes*
529
716
 
530
- *Ryuta Kamizono*
717
+ * Queries such as `Computer.joins(:monitor).group(:status).count` will now be
718
+ interpreted as `Computer.joins(:monitor).group('computers.status').count`
719
+ so that when `Computer` and `Monitor` have both `status` columns we don't
720
+ have conflicts in projection.
531
721
 
532
- * Don't raise when writing an attribute with an out-of-range datetime passed
533
- by the user.
722
+ *Rafael Sales*
534
723
 
535
- *Grey Baker*
724
+ * Add ability to default to `uuid` as primary key when generating database migrations.
536
725
 
537
- * Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
538
- be marked as having changed when set to the same negative value.
726
+ Example:
539
727
 
540
- Fixes #18161.
728
+ config.generators do |g|
729
+ g.orm :active_record, primary_key_type: :uuid
730
+ end
541
731
 
542
- *Daniel Fox*
732
+ *Jon McCartie*
543
733
 
734
+ * Don't cache arguments in `#find_by` if they are an `ActiveRecord::Relation`.
544
735
 
545
- ## Rails 4.2.0 (December 20, 2014) ##
736
+ Fixes #20817.
546
737
 
547
- * Introduce `force: :cascade` option for `create_table`. Using this option
548
- will recreate tables even if they have dependent objects (like foreign keys).
549
- `db/schema.rb` now uses `force: :cascade`. This makes it possible to
550
- reload the schema when foreign keys are in place.
738
+ *Hiroaki Izu*
551
739
 
552
- *Matthew Draper*, *Yves Senn*
740
+ * Qualify column name inserted by `group` in calculation.
553
741
 
554
- * `db:schema:load` and `db:structure:load` no longer purge the database
555
- before loading the schema. This is left for the user to do.
556
- `db:test:prepare` will still purge the database.
742
+ Giving `group` an unqualified column name now works, even if the relation
743
+ has `JOIN` with another table which also has a column of the name.
557
744
 
558
- Fixes #17945.
745
+ *Soutaro Matsumoto*
559
746
 
560
- *Yves Senn*
747
+ * Don't cache prepared statements containing an IN clause or a SQL literal, as
748
+ these queries will change often and are unlikely to have a cache hit.
561
749
 
562
- * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
750
+ *Sean Griffin*
563
751
 
564
- *Ryuta Kamizono*
752
+ * Fix `rewhere` in a `has_many` association.
565
753
 
566
- * Add `foreign_type` option to `has_one` and `has_many` association macros.
754
+ Fixes #21955.
567
755
 
568
- This option enables to define the column name of associated object's type for polymorphic associations.
756
+ *Josh Branchaud*, *Kal*
569
757
 
570
- *Ulisses Almeida, Kassio Borges*
758
+ * `where` raises ArgumentError on unsupported types.
571
759
 
572
- * `add_timestamps` and `remove_timestamps` now properly reversible with
573
- options.
760
+ Fixes #20473.
574
761
 
575
- *Noam Gagliardi-Rabinovich*
762
+ *Jake Worth*
576
763
 
577
- * Bring back `db:test:prepare` to synchronize the test database schema.
764
+ * Add an immutable string type to help reduce memory usage for apps which do
765
+ not need mutation detection on strings.
578
766
 
579
- Manual synchronization using `bin/rake db:test:prepare` is required
580
- when a migration is rolled-back, edited and reapplied.
767
+ *Sean Griffin*
581
768
 
582
- `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
583
- to synchronize the schema. Plugins can use this task as a hook to
584
- provide custom behavior after the schema has been loaded.
769
+ * Give `ActiveRecord::Relation#update` its own deprecation warning when
770
+ passed an `ActiveRecord::Base` instance.
585
771
 
586
- NOTE: `test:prepare` runs before the schema is synchronized.
772
+ Fixes #21945.
587
773
 
588
- Fixes #17171, #15787.
774
+ *Ted Johansson*
589
775
 
590
- *Yves Senn*
776
+ * Make it possible to pass `:to_table` when adding a foreign key through
777
+ `add_reference`.
591
778
 
592
- * Change `reflections` public api to return the keys as String objects.
779
+ Fixes #21563.
593
780
 
594
- Fixes #16928.
781
+ *Yves Senn*
595
782
 
596
- *arthurnn*
783
+ * No longer pass deprecated option `-i` to `pg_dump`.
597
784
 
598
- * Renaming a table in pg also renames the primary key index.
785
+ *Paul Sadauskas*
599
786
 
600
- Fixes #12856
787
+ * Concurrent `AR::Base#increment!` and `#decrement!` on the same record
788
+ are all reflected in the database rather than overwriting each other.
601
789
 
602
- *Sean Griffin*
790
+ *Bogdan Gusiev*
603
791
 
604
- * Make it possible to access fixtures excluded by a `default_scope`.
792
+ * Avoid leaking the first relation we call `first` on, per model.
605
793
 
606
- *Yves Senn*
794
+ Fixes #21921.
607
795
 
608
- * Fix preloading of associations with a scope containing joins along with
609
- conditions on the joined association.
796
+ *Matthew Draper*, *Jean Boussier*
610
797
 
611
- *Siddharth Sharma*
798
+ * Remove unused `pk_and_sequence_for` in `AbstractMysqlAdapter`.
612
799
 
613
- * Add `Table#name` to match `TableDefinition#name`.
800
+ *Ryuta Kamizono*
614
801
 
615
- *Cody Cutrer*
802
+ * Allow fixtures files to set the model class in the YAML file itself.
616
803
 
617
- * Cache `CollectionAssociation#reader` proxies separately before and after
618
- the owner has been saved so that the proxy is not cached without the
619
- owner's id.
804
+ To load the fixtures file `accounts.yml` as the `User` model, use:
620
805
 
621
- *Ben Woosley*
806
+ _fixture:
807
+ model_class: User
808
+ david:
809
+ name: David
622
810
 
623
- * `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
811
+ Fixes #9516.
624
812
 
625
- *Franky W.*
813
+ *Roque Pinel*
626
814
 
627
- * Fix preloading of associations which unscope a default scope.
815
+ * Don't require a database connection to load a class which uses acceptance
816
+ validations.
628
817
 
629
- Fixes #11036.
818
+ *Sean Griffin*
630
819
 
631
- *Byron Bischoff*
820
+ * Correctly apply `unscope` when preloading through associations.
632
821
 
633
- * Added SchemaDumper support for tables with jsonb columns.
822
+ *Jimmy Bourassa*
634
823
 
635
- *Ted O'Meara*
824
+ * Fixed taking precision into count when assigning a value to timestamp attribute.
636
825
 
637
- * Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
638
- `Relation` for performing queries and updates is the prefered API.
826
+ Timestamp column can have less precision than ruby timestamp
827
+ In result in how big a fraction of a second can be stored in the
828
+ database.
639
829
 
640
- *Sean Griffin*
641
830
 
642
- * Queries now properly type cast values that are part of a join statement,
643
- even when using type decorators such as `serialize`.
831
+ m = Model.create!
832
+ m.created_at.usec == m.reload.created_at.usec # => false
833
+ # due to different precision in Time.now and database column
644
834
 
645
- *Melanie Gilman & Sean Griffin*
835
+ If the precision is low enough, (mysql default is 0, so it is always low
836
+ enough by default) the value changes when model is reloaded from the
837
+ database. This patch fixes that issue ensuring that any timestamp
838
+ assigned as an attribute is converted to column precision under the
839
+ attribute.
646
840
 
647
- * MySQL enum type lookups, with values matching another type, no longer result
648
- in an endless loop.
841
+ *Bogdan Gusiev*
649
842
 
650
- Fixes #17402.
843
+ * Introduce `connection.data_sources` and `connection.data_source_exists?`.
844
+ These methods determine what relations can be used to back Active Record
845
+ models (usually tables and views).
651
846
 
652
- *Yves Senn*
847
+ Also deprecate `SchemaCache#tables`, `SchemaCache#table_exists?` and
848
+ `SchemaCache#clear_table_cache!` in favor of their new data source
849
+ counterparts.
653
850
 
654
- * Raise `ArgumentError` when the body of a scope is not callable.
851
+ *Yves Senn*, *Matthew Draper*
655
852
 
656
- *Mauro George*
853
+ * Add `ActiveRecord::Base.ignored_columns` to make some columns
854
+ invisible from Active Record.
657
855
 
658
- * Use type column first in multi-column indexes created with `add-reference`.
856
+ *Jean Boussier*
659
857
 
660
- *Derek Prior*
858
+ * `ActiveRecord::Tasks::MySQLDatabaseTasks` fails if shellout to
859
+ mysql commands (like `mysqldump`) is not successful.
661
860
 
662
- * Fix `Relation.rewhere` to work with Range values.
861
+ *Steve Mitchell*
663
862
 
664
- *Dan Olson*
863
+ * Ensure `select` quotes aliased attributes, even when using `from`.
665
864
 
666
- * `AR::UnknownAttributeError` now includes the class name of a record.
865
+ Fixes #21488.
667
866
 
668
- User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
669
- # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
867
+ *Sean Griffin*, *@johanlunds*
670
868
 
671
- *Yuki Nishijima*
869
+ * MySQL: support `unsigned` numeric data types.
672
870
 
673
- * Fix a regression causing `after_create` callbacks to run before associated
674
- records are autosaved.
871
+ Example:
675
872
 
676
- Fixes #17209.
873
+ create_table :foos do |t|
874
+ t.unsigned_integer :quantity
875
+ t.unsigned_bigint :total
876
+ t.unsigned_float :percentage
877
+ t.unsigned_decimal :price, precision: 10, scale: 2
878
+ end
677
879
 
678
- *Agis Anastasopoulos*
880
+ The `unsigned: true` option may be used for the primary key:
679
881
 
680
- * Honor overridden `rack.test` in Rack environment for the connection
681
- management middleware.
882
+ create_table :foos, id: :bigint, unsigned: true do |t|
883
+
884
+ end
682
885
 
683
- *Simon Eskildsen*
886
+ *Ryuta Kamizono*
684
887
 
685
- * Add a truncate method to the connection.
888
+ * Add `#views` and `#view_exists?` methods on connection adapters.
686
889
 
687
- *Aaron Patterson*
890
+ *Ryuta Kamizono*
688
891
 
689
- * Don't autosave unchanged has_one through records.
892
+ * Correctly dump composite primary key.
690
893
 
691
- *Alan Kennedy*, *Steve Parrington*
894
+ Example:
692
895
 
693
- * Do not dump foreign keys for ignored tables.
896
+ create_table :barcodes, primary_key: ["region", "code"] do |t|
897
+ t.string :region
898
+ t.integer :code
899
+ end
694
900
 
695
- *Yves Senn*
901
+ *Ryuta Kamizono*
696
902
 
697
- * PostgreSQL adapter correctly dumps foreign keys targeting tables
698
- outside the schema search path.
903
+ * Lookup the attribute name for `restrict_with_error` messages on the
904
+ model class that defines the association.
699
905
 
700
- Fixes #16907.
906
+ *kuboon*, *Ronak Jangir*
701
907
 
702
- *Matthew Draper*, *Yves Senn*
908
+ * Correct query for PostgreSQL 8.2 compatibility.
703
909
 
704
- * When a thread is killed, rollback the active transaction, instead of
705
- committing it during the stack unwind. Previously, we could commit half-
706
- completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
707
- distinguish a thread kill from an ordinary non-local (block) return, so must
708
- default to committing.
910
+ *Ben Murphy*, *Matthew Draper*
709
911
 
710
- *Chris Hanks*
912
+ * `bin/rails db:migrate` uses
913
+ `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
914
+ `Migrator.migrations_paths`.
711
915
 
712
- * A `NullRelation` should represent nothing. This fixes a bug where
713
- `Comment.where(post_id: Post.none)` returned a non-empty result.
916
+ *Tobias Bielohlawek*
714
917
 
715
- Fixes #15176.
918
+ * Support dropping indexes concurrently in PostgreSQL.
716
919
 
717
- *Matthew Draper*, *Yves Senn*
920
+ See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more
921
+ details.
718
922
 
719
- * Include default column limits in schema.rb. Allows defaults to be changed
720
- in the future without affecting old migrations that assumed old defaults.
923
+ *Grey Baker*
721
924
 
722
- *Jeremy Kemper*
925
+ * Deprecate passing conditions to `ActiveRecord::Relation#delete_all`
926
+ and `ActiveRecord::Relation#destroy_all`.
723
927
 
724
- * MySQL: schema.rb now includes TEXT and BLOB column limits.
928
+ *Wojciech Wnętrzak*
725
929
 
726
- *Jeremy Kemper*
930
+ * Instantiating an AR model with `ActionController::Parameters` now raises
931
+ an `ActiveModel::ForbiddenAttributesError` if the parameters include a
932
+ `type` field that has not been explicitly permitted. Previously, the
933
+ `type` field was simply ignored in the same situation.
727
934
 
728
- * MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
935
+ *Prem Sichanugrist*
729
936
 
730
- *Jeremy Kemper*
937
+ * PostgreSQL, `create_schema`, `drop_schema` and `rename_table` now quote
938
+ schema names.
731
939
 
732
- * SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
940
+ Fixes #21418.
733
941
 
734
- *Girish Sonawane*
942
+ Example:
735
943
 
736
- * Introduce `connection.supports_views?` to check whether the current adapter
737
- has support for SQL views. Connection adapters should define this method.
944
+ create_schema("my.schema")
945
+ # CREATE SCHEMA "my.schema";
738
946
 
739
947
  *Yves Senn*
740
948
 
741
- * Allow included modules to override association methods.
742
-
743
- Fixes #16684.
949
+ * PostgreSQL, add `:if_exists` option to `#drop_schema`. This makes it
950
+ possible to drop a schema that might exist without raising an exception if
951
+ it doesn't.
744
952
 
745
953
  *Yves Senn*
746
954
 
747
- * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
748
- the database connection to the current environment.
955
+ * Only try to nullify has_one target association if the record is persisted.
749
956
 
750
- Fixes #16757.
957
+ Fixes #21223.
751
958
 
752
- *Joshua Cody*, *Yves Senn*
959
+ *Agis Anastasopoulos*
753
960
 
754
- * MySQL: set the connection collation along with the charset.
961
+ * Uniqueness validator raises descriptive error when running on a persisted
962
+ record without primary key.
755
963
 
756
- Sets the connection collation to the database collation configured in
757
- database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
758
- collation for that charset (utf8mb4_general_ci) when you may have chosen
759
- a different collation, like utf8mb4_unicode_ci.
964
+ Fixes #21304.
760
965
 
761
- This only applies to literal string comparisons, not column values, so it
762
- is unlikely to affect you.
966
+ *Yves Senn*
763
967
 
764
- *Jeremy Kemper*
968
+ * Add a native JSON data type support in MySQL.
765
969
 
766
- * `default_sequence_name` from the PostgreSQL adapter returns a `String`.
970
+ Example:
767
971
 
768
- *Yves Senn*
972
+ create_table :json_data_type do |t|
973
+ t.json :settings
974
+ end
769
975
 
770
- * Fix a regression where whitespaces were stripped from DISTINCT queries in
771
- PostgreSQL.
976
+ *Ryuta Kamizono*
772
977
 
773
- *Agis Anastasopoulos*
978
+ * Descriptive error message when fixtures contain a missing column.
774
979
 
775
- Fixes #16623.
980
+ Fixes #21201.
776
981
 
777
- * Fix has_many :through relation merging failing when dynamic conditions are
778
- passed as a lambda with an arity of one.
982
+ *Yves Senn*
779
983
 
780
- Fixes #16128.
984
+ * `ActiveRecord::Tasks::PostgreSQLDatabaseTasks` fail if shellout to
985
+ postgresql commands (like `pg_dump`) is not successful.
781
986
 
782
- *Agis Anastasopoulos*
987
+ *Bryan Paxton*, *Nate Berkopec*
783
988
 
784
- * Fix `Relation#exists?` to work with polymorphic associations.
989
+ * Add `ActiveRecord::Relation#in_batches` to work with records and relations
990
+ in batches.
785
991
 
786
- Fixes #15821.
992
+ Available options are `of` (batch size), `load`, `start`, and `finish`.
787
993
 
788
- *Kassio Borges*
994
+ Examples:
789
995
 
790
- * Currently, Active Record rescues any errors raised within
791
- `after_rollback`/`after_create` callbacks and prints them to the logs.
792
- Future versions of Rails will not rescue these errors anymore and
793
- just bubble them up like the other callbacks.
996
+ Person.in_batches.each_record(&:party_all_night!)
997
+ Person.in_batches.update_all(awesome: true)
998
+ Person.in_batches.delete_all
999
+ Person.in_batches.each do |relation|
1000
+ relation.delete_all
1001
+ sleep 10 # Throttles the delete queries
1002
+ end
794
1003
 
795
- This commit adds an opt-in flag to enable not rescuing the errors.
1004
+ Fixes #20933.
796
1005
 
797
- Example:
1006
+ *Sina Siadat*
798
1007
 
799
- # Do not swallow errors in after_commit/after_rollback callbacks.
800
- config.active_record.raise_in_transactional_callbacks = true
1008
+ * Added methods for PostgreSQL geometric data types to use in migrations.
801
1009
 
802
- Fixes #13460.
1010
+ Example:
803
1011
 
804
- *arthurnn*
1012
+ create_table :foo do |t|
1013
+ t.line :foo_line
1014
+ t.lseg :foo_lseg
1015
+ t.box :foo_box
1016
+ t.path :foo_path
1017
+ t.polygon :foo_polygon
1018
+ t.circle :foo_circle
1019
+ end
805
1020
 
806
- * Fix an issue where custom accessor methods (such as those generated by
807
- `enum`) with the same name as a global method are incorrectly overridden
808
- when subclassing.
1021
+ *Mehmet Emin İNAÇ*
809
1022
 
810
- Fixes #16288.
1023
+ * Add `cache_key` to ActiveRecord::Relation.
811
1024
 
812
- *Godfrey Chan*
1025
+ Example:
813
1026
 
814
- * `*_was` and `changes` now work correctly for in-place attribute changes as
815
- well.
1027
+ @users = User.where("name like ?", "%Alberto%")
1028
+ @users.cache_key
1029
+ # => "/users/query-5942b155a43b139f2471b872ac54251f-3-20150714212107656125000"
816
1030
 
817
- *Sean Griffin*
1031
+ *Alberto Fernández-Capel*
818
1032
 
819
- * Fix regression on `after_commit` that did not fire with nested transactions.
1033
+ * Properly allow uniqueness validations on primary keys.
820
1034
 
821
- Fixes #16425.
1035
+ Fixes #20966.
822
1036
 
823
- *arthurnn*
1037
+ *Sean Griffin*, *presskey*
824
1038
 
825
- * Do not try to write timestamps when a table has no timestamps columns.
1039
+ * Don't raise an error if an association failed to destroy when `destroy` was
1040
+ called on the parent (as opposed to `destroy!`).
826
1041
 
827
- Fixes #8813.
1042
+ Fixes #20991.
828
1043
 
829
- *Sergey Potapov*
1044
+ *Sean Griffin*
830
1045
 
831
- * `index_exists?` with `:name` option does verify specified columns.
1046
+ * `ActiveRecord::RecordNotFound` modified to store model name, primary_key and
1047
+ id of the caller model. It allows the catcher of this exception to make
1048
+ a better decision to what to do with it.
832
1049
 
833
1050
  Example:
834
1051
 
835
- add_index :articles, :title, name: "idx_title"
836
-
837
- # Before:
838
- index_exists? :articles, :title, name: "idx_title" # => `true`
839
- index_exists? :articles, :body, name: "idx_title" # => `true`
1052
+ class SomeAbstractController < ActionController::Base
1053
+ rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
840
1054
 
841
- # After:
842
- index_exists? :articles, :title, name: "idx_title" # => `true`
843
- index_exists? :articles, :body, name: "idx_title" # => `false`
1055
+ private def redirect_to_404(e)
1056
+ return redirect_to(posts_url) if e.model == 'Post'
1057
+ raise
1058
+ end
1059
+ end
844
1060
 
845
- *Yves Senn*, *Matthew Draper*
1061
+ *Sameer Rahmani*
846
1062
 
847
- * `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
848
- Not passing the option is deprecated but the default is still `null: true`.
849
- With Rails 5 this will change to `null: false`.
1063
+ * Deprecate the keys for association `restrict_dependent_destroy` errors in favor
1064
+ of new key names.
850
1065
 
851
- *Sean Griffin*
1066
+ Previously `has_one` and `has_many` associations were using the
1067
+ `one` and `many` keys respectively. Both of these keys have special
1068
+ meaning in I18n (they are considered to be pluralizations) so by
1069
+ renaming them to `has_one` and `has_many` we make the messages more explicit
1070
+ and most importantly they don't clash with linguistical systems that need to
1071
+ validate translation keys (and their pluralizations).
852
1072
 
853
- * When calling `update_columns` on a record that is not persisted, the error
854
- message now reflects whether that object is a new record or has been
855
- destroyed.
1073
+ The `:'restrict_dependent_destroy.one'` key should be replaced with
1074
+ `:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'`
1075
+ with `:'restrict_dependent_destroy.has_many'`.
856
1076
 
857
- *Lachlan Sylvester*
1077
+ *Roque Pinel*, *Christopher Dell*
858
1078
 
859
- * Define `id_was` to get the previous value of the primary key.
1079
+ * Fix state being carried over from previous transaction.
860
1080
 
861
- Currently when we call `id_was` and we have a custom primary key name,
862
- Active Record will return the current value of the primary key. This
863
- makes it impossible to correctly do an update operation if you change the
864
- id.
1081
+ Considering the following example where `name` is a required attribute.
1082
+ Before we had `new_record?` returning `true` for a persisted record:
865
1083
 
866
- Fixes #16413.
1084
+ author = Author.create! name: 'foo'
1085
+ author.name = nil
1086
+ author.save # => false
1087
+ author.new_record? # => true
867
1088
 
868
- *Rafael Mendonça França*
1089
+ Fixes #20824.
869
1090
 
870
- * Deprecate `DatabaseTasks.load_schema` to act on the current connection.
871
- Use `.load_schema_current` instead. In the future `load_schema` will
872
- require the `configuration` to act on as an argument.
1091
+ *Roque Pinel*
873
1092
 
874
- *Yves Senn*
1093
+ * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
1094
+ when validating associations.
875
1095
 
876
- * Fix automatic maintaining test schema to properly handle sql structure
877
- schema format.
1096
+ Fixes #20882.
878
1097
 
879
- Fixes #15394.
1098
+ *Sean Griffin*
880
1099
 
881
- *Wojciech Wnętrzak*
1100
+ * Fix a bug where counter_cache doesn't always work with polymorphic
1101
+ relations.
882
1102
 
883
- * Fix type casting to Decimal from Float with large precision.
1103
+ Fixes #16407.
884
1104
 
885
- *Tomohiro Hashidate*
1105
+ *Stefan Kanev*, *Sean Griffin*
886
1106
 
887
- * Deprecate `Reflection#source_macro`
1107
+ * Ensure that cyclic associations with autosave don't cause duplicate errors
1108
+ to be added to the parent record.
888
1109
 
889
- `Reflection#source_macro` is no longer needed in Active Record
890
- source so it has been deprecated. Code that used `source_macro`
891
- was removed in #16353.
1110
+ Fixes #20874.
892
1111
 
893
- *Eileen M. Uchtitelle*, *Aaron Patterson*
1112
+ *Sean Griffin*
894
1113
 
895
- * No verbose backtrace by `db:drop` when database does not exist.
1114
+ * Ensure that `ActionController::Parameters` can still be passed to nested
1115
+ attributes.
896
1116
 
897
- Fixes #16295.
1117
+ Fixes #20922.
898
1118
 
899
- *Kenn Ejima*
1119
+ *Sean Griffin*
900
1120
 
901
- * Add support for PostgreSQL JSONB.
1121
+ * Deprecate force association reload by passing a truthy argument to
1122
+ association method.
902
1123
 
903
- Example:
1124
+ For collection association, you can call `#reload` on association proxy to
1125
+ force a reload:
904
1126
 
905
- create_table :posts do |t|
906
- t.jsonb :meta_data
907
- end
1127
+ @user.posts.reload # Instead of @user.posts(true)
908
1128
 
909
- *Philippe Creux*, *Chris Teague*
1129
+ For singular association, you can call `#reload` on the parent object to
1130
+ clear its association cache then call the association method:
910
1131
 
911
- * `db:purge` with MySQL respects `Rails.env`.
1132
+ @user.reload.profile # Instead of @user.profile(true)
912
1133
 
913
- *Yves Senn*
1134
+ Passing a truthy argument to force association to reload will be removed in
1135
+ Rails 5.1.
914
1136
 
915
- * `change_column_default :table, :column, nil` with PostgreSQL will issue a
916
- `DROP DEFAULT` instead of a `DEFAULT NULL` query.
1137
+ *Prem Sichanugrist*
917
1138
 
918
- Fixes #16261.
1139
+ * Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
1140
+ from the concurrent-ruby gem.
919
1141
 
920
- *Matthew Draper*, *Yves Senn*
1142
+ *Jerry D'Antonio*
921
1143
 
922
- * Allow to specify a type for the foreign key column in `references`
923
- and `add_reference`.
1144
+ * Fix through associations using scopes having the scope merged multiple
1145
+ times.
924
1146
 
925
- Example:
1147
+ Fixes #20721.
1148
+ Fixes #20727.
926
1149
 
927
- change_table :vehicle do |t|
928
- t.references :station, type: :uuid
929
- end
1150
+ *Sean Griffin*
930
1151
 
931
- *Andrey Novikov*, *Łukasz Sarnacki*
1152
+ * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
1153
+ other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
932
1154
 
933
- * `create_join_table` removes a common prefix when generating the join table.
934
- This matches the existing behavior of HABTM associations.
1155
+ Fixes #20743.
935
1156
 
936
- Fixes #13683.
1157
+ *Yves Senn*
937
1158
 
938
- *Stefan Kanev*
1159
+ * Add alternate syntax to make `change_column_default` reversible.
939
1160
 
940
- * Do not swallow errors on `compute_type` when having a bad `alias_method` on
941
- a class.
1161
+ User can pass in `:from` and `:to` to make `change_column_default` command
1162
+ become reversible.
942
1163
 
943
- *arthurnn*
1164
+ Example:
944
1165
 
945
- * PostgreSQL invalid `uuid` are convert to nil.
1166
+ change_column_default :posts, :status, from: nil, to: "draft"
1167
+ change_column_default :users, :authorized, from: true, to: false
946
1168
 
947
- *Abdelkader Boudih*
1169
+ *Prem Sichanugrist*
948
1170
 
949
- * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
1171
+ * Prevent error when using `force_reload: true` on an unassigned polymorphic
1172
+ belongs_to association.
950
1173
 
951
- With 4.1.x, `serialize` started returning a string when `JSON` was passed as
952
- the second attribute. It will now return a hash as per previous versions.
1174
+ Fixes #20426.
953
1175
 
954
- Example:
1176
+ *James Dabbs*
955
1177
 
956
- class Post < ActiveRecord::Base
957
- serialize :comment, JSON
958
- end
1178
+ * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
1179
+ a wrong type to a namespaced association.
959
1180
 
960
- class Comment
961
- include ActiveModel::Model
962
- attr_accessor :category, :text
963
- end
1181
+ Fixes #20545.
964
1182
 
965
- post = Post.create!
966
- post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
967
- post.save!
1183
+ *Diego Carrion*
968
1184
 
969
- # 4.0
970
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1185
+ * `validates_absence_of` respects `marked_for_destruction?`.
971
1186
 
972
- # 4.1 before
973
- post.comment # => "#<Comment:0x007f80ab48ff98>"
1187
+ Fixes #20449.
974
1188
 
975
- # 4.1 after
976
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1189
+ *Yves Senn*
977
1190
 
978
- When using `JSON` as the coder in `serialize`, Active Record will use the
979
- new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
980
- `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
981
- correctly using the `#as_json` hook.
1191
+ * Include the `Enumerable` module in `ActiveRecord::Relation`
982
1192
 
983
- To keep the previous behaviour, supply a custom coder instead
984
- ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
1193
+ *Sean Griffin*, *bogdan*
985
1194
 
986
- Fixes #15594.
1195
+ * Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
987
1196
 
988
- *Jenn Cooper*
1197
+ *Sean Griffin*
989
1198
 
990
- * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
1199
+ * Let `WITH` queries (Common Table Expressions) be explainable.
991
1200
 
992
- Fixes #15931.
1201
+ *Vladimir Kochnev*
993
1202
 
994
- *Jeff Browning*
1203
+ * Make `remove_index :table, :column` reversible.
995
1204
 
996
- * Calling `#empty?` on a `has_many` association would use the value from the
997
- counter cache if one exists.
1205
+ *Yves Senn*
998
1206
 
999
- *David Verhasselt*
1207
+ * Fixed an error which would occur in dirty checking when calling
1208
+ `update_attributes` from a getter.
1000
1209
 
1001
- * Fix the schema dump generated for tables without constraints and with
1002
- primary key with default value of custom PostgreSQL function result.
1210
+ Fixes #20531.
1003
1211
 
1004
- Fixes #16111.
1212
+ *Sean Griffin*
1005
1213
 
1006
- *Andrey Novikov*
1214
+ * Make `remove_foreign_key` reversible. Any foreign key options must be
1215
+ specified, similar to `remove_column`.
1007
1216
 
1008
- * Fix the SQL generated when a `delete_all` is run on an association to not
1009
- produce an `IN` statements.
1217
+ *Aster Ryan*
1010
1218
 
1011
- Before:
1219
+ * Add `:_prefix` and `:_suffix` options to `enum` definition.
1012
1220
 
1013
- UPDATE "categorizations" SET "category_id" = NULL WHERE
1014
- "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
1221
+ Fixes #17511, #17415.
1015
1222
 
1016
- After:
1223
+ *Igor Kapkov*
1017
1224
 
1018
- UPDATE "categorizations" SET "category_id" = NULL WHERE
1019
- "categorizations"."category_id" = 1
1225
+ * Correctly handle decimal arrays with defaults in the schema dumper.
1020
1226
 
1021
- *Eileen M. Uchitelle, Aaron Patterson*
1227
+ Fixes #20515.
1022
1228
 
1023
- * Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
1024
- values for string columns. Otherwise, in some database, the string column
1025
- values will be coerced to a numeric allowing false or 0.seconds match any
1026
- string starting with a non-digit.
1229
+ *Sean Griffin*, *jmondo*
1027
1230
 
1028
- Example:
1231
+ * Deprecate the PostgreSQL `:point` type in favor of a new one which will return
1232
+ `Point` objects instead of an `Array`
1029
1233
 
1030
- App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
1234
+ *Sean Griffin*
1031
1235
 
1032
- *Dylan Thacker-Smith*
1236
+ * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
1237
+ as columns.
1033
1238
 
1034
- * Add a `:required` option to singular associations, providing a nicer
1035
- API for presence validations on associations.
1239
+ Fixes #20360.
1036
1240
 
1037
1241
  *Sean Griffin*
1038
1242
 
1039
- * Fix an error in `reset_counters` when associations have `select` scope.
1040
- (Call to `count` generated invalid SQL.)
1041
-
1042
- *Cade Truitt*
1243
+ * Do not set `sql_mode` if `strict: :default` is specified.
1043
1244
 
1044
- * After a successful `reload`, `new_record?` is always false.
1245
+ # config/database.yml
1246
+ production:
1247
+ adapter: mysql2
1248
+ database: foo_prod
1249
+ user: foo
1250
+ strict: :default
1045
1251
 
1046
- Fixes #12101.
1252
+ *Ryuta Kamizono*
1047
1253
 
1048
- *Matthew Draper*
1254
+ * Allow proc defaults to be passed to the attributes API. See documentation
1255
+ for examples.
1049
1256
 
1050
- * PostgreSQL renaming table doesn't attempt to rename non existent sequences.
1257
+ *Sean Griffin*, *Kir Shatrov*
1051
1258
 
1052
- *Abdelkader Boudih*
1259
+ * SQLite: `:collation` support for string and text columns.
1053
1260
 
1054
- * Move 'dependent: :destroy' handling for `belongs_to`
1055
- from `before_destroy` to `after_destroy` callback chain
1261
+ Example:
1056
1262
 
1057
- Fixes #12380.
1263
+ create_table :foo do |t|
1264
+ t.string :string_nocase, collation: 'NOCASE'
1265
+ t.text :text_rtrim, collation: 'RTRIM'
1266
+ end
1058
1267
 
1059
- *Ivan Antropov*
1268
+ add_column :foo, :title, :string, collation: 'RTRIM'
1060
1269
 
1061
- * Detect in-place modifications on String attributes.
1270
+ change_column :foo, :title, :string, collation: 'NOCASE'
1062
1271
 
1063
- Before this change, an attribute modified in-place had to be marked as
1064
- changed in order for it to be persisted in the database. Now it is no longer
1065
- required.
1272
+ *Akshay Vishnoi*
1066
1273
 
1067
- Before:
1274
+ * Allow the use of symbols or strings to specify enum values in test
1275
+ fixtures:
1068
1276
 
1069
- user = User.first
1070
- user.name << ' Griffin'
1071
- user.name_will_change!
1072
- user.save
1073
- user.reload.name # => "Sean Griffin"
1277
+ awdr:
1278
+ title: "Agile Web Development with Rails"
1279
+ status: :proposed
1074
1280
 
1075
- After:
1281
+ *George Claghorn*
1076
1282
 
1077
- user = User.first
1078
- user.name << ' Griffin'
1079
- user.save
1080
- user.reload.name # => "Sean Griffin"
1283
+ * Clear query cache when `ActiveRecord::Base#reload` is called.
1081
1284
 
1082
- *Sean Griffin*
1285
+ *Shane Hender, Pierre Nespo*
1083
1286
 
1084
- * Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
1085
- is invalid.
1287
+ * Include stored procedures and function on the MySQL structure dump.
1086
1288
 
1087
- *Bogdan Gusiev*, *Marc Schütz*
1289
+ *Jonathan Worek*
1088
1290
 
1089
- * Support for adding and removing foreign keys. Foreign keys are now
1090
- a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
1091
- and PostgreSQLAdapter.
1291
+ * Pass `:extend` option for `has_and_belongs_to_many` associations to the
1292
+ underlying `has_many :through`.
1092
1293
 
1093
- Many thanks to *Matthew Higgins* for laying the foundation with his work on
1094
- [foreigner](https://github.com/matthuhiggins/foreigner).
1294
+ *Jaehyun Shin*
1095
1295
 
1096
- Example:
1296
+ * Deprecate `Relation#uniq` use `Relation#distinct` instead.
1097
1297
 
1098
- # within your migrations:
1099
- add_foreign_key :articles, :authors
1100
- remove_foreign_key :articles, :authors
1298
+ See #9683.
1101
1299
 
1102
1300
  *Yves Senn*
1103
1301
 
1104
- * Fix subtle bugs regarding attribute assignment on models with no primary
1105
- key. `'id'` will no longer be part of the attributes hash.
1302
+ * Allow single table inheritance instantiation to work when storing
1303
+ demodulized class names.
1106
1304
 
1107
- *Sean Griffin*
1305
+ *Alex Robbin*
1108
1306
 
1109
- * Deprecate automatic counter caches on `has_many :through`. The behavior was
1110
- broken and inconsistent.
1307
+ * Correctly pass MySQL options when using `structure_dump` or
1308
+ `structure_load`.
1111
1309
 
1112
- *Sean Griffin*
1310
+ Specifically, it fixes an issue when using SSL authentication.
1113
1311
 
1114
- * `preload` preserves readonly flag for associations.
1312
+ *Alex Coomans*
1115
1313
 
1116
- See #15853.
1314
+ * Correctly dump `:options` on `create_table` for MySQL.
1117
1315
 
1118
- *Yves Senn*
1316
+ *Ryuta Kamizono*
1119
1317
 
1120
- * Assume numeric types have changed if they were assigned to a value that
1121
- would fail numericality validation, regardless of the old value. Previously
1122
- this would only occur if the old value was 0.
1318
+ * PostgreSQL: `:collation` support for string and text columns.
1123
1319
 
1124
1320
  Example:
1125
1321
 
1126
- model = Model.create!(number: 5)
1127
- model.number = '5wibble'
1128
- model.number_changed? # => true
1322
+ create_table :foos do |t|
1323
+ t.string :string_en, collation: 'en_US.UTF-8'
1324
+ t.text :text_ja, collation: 'ja_JP.UTF-8'
1325
+ end
1129
1326
 
1130
- Fixes #14731.
1327
+ *Ryuta Kamizono*
1131
1328
 
1132
- *Sean Griffin*
1329
+ * Remove `ActiveRecord::Serialization::XmlSerializer` from core.
1133
1330
 
1134
- * `reload` no longer merges with the existing attributes.
1135
- The attribute hash is fully replaced. The record is put into the same state
1136
- as it would be with `Model.find(model.id)`.
1331
+ *Zachary Scott*
1137
1332
 
1138
- *Sean Griffin*
1333
+ * Make `unscope` aware of "less than" and "greater than" conditions.
1139
1334
 
1140
- * The object returned from `select_all` must respond to `column_types`.
1141
- If this is not the case a `NoMethodError` is raised.
1335
+ *TAKAHASHI Kazuaki*
1142
1336
 
1143
- *Sean Griffin*
1337
+ * `find_by` and `find_by!` raise `ArgumentError` when called without
1338
+ arguments.
1144
1339
 
1145
- * Detect in-place modifications of PG array types
1340
+ *Kohei Suzuki*
1146
1341
 
1147
- *Sean Griffin*
1342
+ * Revert behavior of `db:schema:load` back to loading the full
1343
+ environment. This ensures that initializers are run.
1148
1344
 
1149
- * Add `bin/rake db:purge` task to empty the current database.
1345
+ Fixes #19545.
1150
1346
 
1151
1347
  *Yves Senn*
1152
1348
 
1153
- * Deprecate `serialized_attributes` without replacement.
1349
+ * Fix missing index when using `timestamps` with the `index` option.
1350
+
1351
+ The `index` option used with `timestamps` should be passed to both
1352
+ `column` definitions for `created_at` and `updated_at` rather than just
1353
+ the first.
1354
+
1355
+ *Paul Mucur*
1154
1356
 
1155
- *Sean Griffin*
1357
+ * Rename `:class` to `:anonymous_class` in association options.
1156
1358
 
1157
- * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
1158
- are part of the URI structure, not the actual host.
1359
+ Fixes #19659.
1159
1360
 
1160
- Fixes #15705.
1361
+ *Andrew White*
1161
1362
 
1162
- *Andy Bakun*, *Aaron Stone*
1363
+ * Autosave existing records on a has many through association when the parent
1364
+ is new.
1163
1365
 
1164
- * Ensure both parent IDs are set on join records when both sides of a
1165
- through association are new.
1366
+ Fixes #19782.
1166
1367
 
1167
1368
  *Sean Griffin*
1168
1369
 
1169
- * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
1170
- Serialized attributes on ActiveRecord models will no longer save when
1171
- unchanged.
1172
-
1173
- Fixes #8328.
1370
+ * Fixed a bug where uniqueness validations would error on out of range values,
1371
+ even if an validation should have prevented it from hitting the database.
1174
1372
 
1175
- *Sean Griffin*
1373
+ *Andrey Voronkov*
1176
1374
 
1177
- * `Pluck` now works when selecting columns from different tables with the same
1178
- name.
1375
+ * MySQL: `:charset` and `:collation` support for string and text columns.
1179
1376
 
1180
- Fixes #15649.
1377
+ Example:
1181
1378
 
1182
- *Sean Griffin*
1379
+ create_table :foos do |t|
1380
+ t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
1381
+ t.text :text_ascii, charset: 'ascii'
1382
+ end
1183
1383
 
1184
- * Remove `cache_attributes` and friends. All attributes are cached.
1384
+ *Ryuta Kamizono*
1185
1385
 
1186
- *Sean Griffin*
1386
+ * Foreign key related methods in the migration DSL respect
1387
+ `ActiveRecord::Base.pluralize_table_names = false`.
1187
1388
 
1188
- * Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
1389
+ Fixes #19643.
1189
1390
 
1190
- *Akshay Vishnoi*
1391
+ *Mehmet Emin İNAÇ*
1191
1392
 
1192
- * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
1193
- `Enumerable#find` does.
1393
+ * Reduce memory usage from loading types on PostgreSQL.
1194
1394
 
1195
- Fixes #15382.
1395
+ Fixes #19578.
1196
1396
 
1197
- *James Yang*
1397
+ *Sean Griffin*
1198
1398
 
1199
- * Make timezone aware attributes work with PostgreSQL array columns.
1399
+ * Add `config.active_record.warn_on_records_fetched_greater_than` option.
1200
1400
 
1201
- Fixes #13402.
1401
+ When set to an integer, a warning will be logged whenever a result set
1402
+ larger than the specified size is returned by a query.
1202
1403
 
1203
- *Kuldeep Aggarwal*, *Sean Griffin*
1404
+ Fixes #16463.
1204
1405
 
1205
- * `ActiveRecord::SchemaMigration` has no primary key regardless of the
1206
- `primary_key_prefix_type` configuration.
1406
+ *Jason Nochlin*
1207
1407
 
1208
- Fixes #15051.
1408
+ * Ignore `.psqlrc` when loading database structure.
1209
1409
 
1210
- *JoseLuis Torres*, *Yves Senn*
1410
+ *Jason Weathered*
1211
1411
 
1212
- * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
1412
+ * Fix referencing wrong table aliases while joining tables of has many through
1413
+ association (only when calling calculation methods).
1213
1414
 
1214
- Fixes #15538.
1415
+ Fixes #19276.
1215
1416
 
1216
- *Yves Senn*
1417
+ *pinglamb*
1217
1418
 
1218
- * Baseclass becomes! subclass.
1419
+ * Correctly persist a serialized attribute that has been returned to
1420
+ its default value by an in-place modification.
1219
1421
 
1220
- Before this change, a record which changed its STI type, could not be
1221
- updated.
1422
+ Fixes #19467.
1222
1423
 
1223
- Fixes #14785.
1424
+ *Matthew Draper*
1224
1425
 
1225
- *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
1426
+ * Fix generating the schema file when using PostgreSQL `BigInt[]` data type.
1427
+ Previously the `limit: 8` was not coming through, and this caused it to
1428
+ become `Int[]` data type after rebuilding from the schema.
1226
1429
 
1227
- * Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
1228
- `proper_table_name` instance method on `ActiveRecord::Migration` instead.
1430
+ Fixes #19420.
1229
1431
 
1230
- *Akshay Vishnoi*
1432
+ *Jake Waller*
1231
1433
 
1232
- * Fix regression on eager loading association based on SQL query rather than
1233
- existing column.
1434
+ * Reuse the `CollectionAssociation#reader` cache when the foreign key is
1435
+ available prior to save.
1234
1436
 
1235
- Fixes #15480.
1437
+ *Ben Woosley*
1236
1438
 
1237
- *Lauro Caetano*, *Carlos Antonio da Silva*
1439
+ * Add `config.active_record.dump_schemas` to fix `db:structure:dump`
1440
+ when using schema_search_path and PostgreSQL extensions.
1238
1441
 
1239
- * Deprecate returning `nil` from `column_for_attribute` when no column exists.
1240
- It will return a null object in Rails 5.0
1442
+ Fixes #17157.
1241
1443
 
1242
- *Sean Griffin*
1444
+ *Ryan Wallace*
1243
1445
 
1244
- * Implemented `ActiveRecord::Base#pretty_print` to work with PP.
1446
+ * Renaming `use_transactional_fixtures` to `use_transactional_tests` for clarity.
1245
1447
 
1246
- *Ethan*
1448
+ Fixes #18864.
1247
1449
 
1248
- * Preserve type when dumping PostgreSQL point, bit, bit varying and money
1249
- columns.
1450
+ *Brandon Weiss*
1250
1451
 
1251
- *Yves Senn*
1452
+ * Increase pg gem version requirement to `~> 0.18`. Earlier versions of the
1453
+ pg gem are known to have problems with Ruby 2.2.
1252
1454
 
1253
- * New records remain new after YAML serialization.
1455
+ *Matt Brictson*
1254
1456
 
1255
- *Sean Griffin*
1457
+ * Correctly dump `serial` and `bigserial`.
1256
1458
 
1257
- * PostgreSQL support default values for enum types. Fixes #7814.
1459
+ *Ryuta Kamizono*
1258
1460
 
1259
- *Yves Senn*
1461
+ * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
1260
1462
 
1261
- * PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
1463
+ *James Cox*
1262
1464
 
1263
- *Yves Senn*
1465
+ * Don't enroll records in the transaction if they don't have commit callbacks.
1466
+ This was causing a memory leak when creating many records inside a transaction.
1264
1467
 
1265
- * Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
1266
- with orders without sort direction modifiers.
1468
+ Fixes #15549.
1267
1469
 
1268
- *Nikolay Kondratyev*
1470
+ *Will Bryant*, *Aaron Patterson*
1269
1471
 
1270
- * PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
1472
+ * Correctly create through records when created on a has many through
1473
+ association when using `where`.
1271
1474
 
1272
- *Yves Senn*
1475
+ Fixes #19073.
1273
1476
 
1274
- * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
1275
- Fixes duplication in combination with `store_accessor`.
1477
+ *Sean Griffin*
1276
1478
 
1277
- Fixes #15369.
1479
+ * Add `SchemaMigration.create_table` support for any unicode charsets with MySQL.
1278
1480
 
1279
- *Yves Senn*
1481
+ *Ryuta Kamizono*
1280
1482
 
1281
- * `rake railties:install:migrations` respects the order of railties.
1483
+ * PostgreSQL no longer disables user triggers if system triggers can't be
1484
+ disabled. Disabling user triggers does not fulfill what the method promises.
1485
+ Rails currently requires superuser privileges for this method.
1282
1486
 
1283
- *Arun Agrawal*
1487
+ If you absolutely rely on this behavior, consider patching
1488
+ `disable_referential_integrity`.
1284
1489
 
1285
- * Fix redefine a `has_and_belongs_to_many` inside inherited class
1286
- Fixing regression case, where redefining the same `has_and_belongs_to_many`
1287
- definition into a subclass would raise.
1490
+ *Yves Senn*
1288
1491
 
1289
- Fixes #14983.
1492
+ * Restore aborted transaction state when `disable_referential_integrity` fails
1493
+ due to missing permissions.
1290
1494
 
1291
- *arthurnn*
1495
+ *Toby Ovod-Everett*, *Yves Senn*
1292
1496
 
1293
- * Fix `has_and_belongs_to_many` public reflection.
1294
- When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
1295
- But as `reflections` is a public API, people expect to see the right macro.
1497
+ * In PostgreSQL, print a warning message if `disable_referential_integrity`
1498
+ fails due to missing permissions.
1296
1499
 
1297
- Fixes #14682.
1500
+ *Andrey Nering*, *Yves Senn*
1298
1501
 
1299
- *arthurnn*
1502
+ * Allow a `:limit` option for MySQL bigint primary key support.
1300
1503
 
1301
- * Fix serialization for records with an attribute named `format`.
1504
+ Example:
1302
1505
 
1303
- Fixes #15188.
1506
+ create_table :foos, id: :primary_key, limit: 8 do |t|
1507
+ end
1304
1508
 
1305
- *Godfrey Chan*
1509
+ # or
1306
1510
 
1307
- * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
1308
- on a NullRelation should return a Hash.
1511
+ create_table :foos, id: false do |t|
1512
+ t.primary_key :id, limit: 8
1513
+ end
1309
1514
 
1310
- *Kuldeep Aggarwal*
1515
+ *Ryuta Kamizono*
1311
1516
 
1312
- * Fix serialized fields returning serialized data after being updated with
1313
- `update_column`.
1517
+ * `belongs_to` will now trigger a validation error by default if the association is not present.
1518
+ You can turn this off on a per-association basis with `optional: true`.
1519
+ (Note this new default only applies to new Rails apps that will be generated with
1520
+ `config.active_record.belongs_to_required_by_default = true` in initializer.)
1314
1521
 
1315
- *Simon Hørup Eskildsen*
1522
+ *Josef Šimánek*
1316
1523
 
1317
- * Fix polymorphic eager loading when using a String as foreign key.
1524
+ * Fixed `ActiveRecord::Relation#becomes!` and `changed_attributes` issues for type
1525
+ columns.
1318
1526
 
1319
- Fixes #14734.
1527
+ Fixes #17139.
1320
1528
 
1321
- *Lauro Caetano*
1529
+ *Miklos Fazekas*
1322
1530
 
1323
- * Change belongs_to touch to be consistent with timestamp updates
1531
+ * Format the time string according to the precision of the time column.
1324
1532
 
1325
- If a model is set up with a belongs_to: touch relationship the parent
1326
- record will only be touched if the record was modified. This makes it
1327
- consistent with timestamp updating on the record itself.
1533
+ *Ryuta Kamizono*
1328
1534
 
1329
- *Brock Trappitt*
1535
+ * Allow a `:precision` option for time type columns.
1330
1536
 
1331
- * Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
1332
- table inside a schema.
1537
+ *Ryuta Kamizono*
1333
1538
 
1334
- Fixes #14824.
1539
+ * Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
1540
+ during the given block.
1335
1541
 
1336
- *Eric Chahin*
1542
+ For example, here's a pattern of creating notifications when new comments
1543
+ are posted. (The notification may in turn trigger an email, a push
1544
+ notification, or just appear in the UI somewhere):
1337
1545
 
1338
- * Remove unused `:timestamp` type. Transparently alias it to `:datetime`
1339
- in all cases. Fixes inconsistencies when column types are sent outside of
1340
- `ActiveRecord`, such as for XML Serialization.
1546
+ class Comment < ActiveRecord::Base
1547
+ belongs_to :commentable, polymorphic: true
1548
+ after_create -> { Notification.create! comment: self,
1549
+ recipients: commentable.recipients }
1550
+ end
1341
1551
 
1342
- *Sean Griffin*
1552
+ That's what you want the bulk of the time. A new comment creates a new
1553
+ Notification. There may be edge cases where you don't want that, like
1554
+ when copying a commentable and its comments, in which case write a
1555
+ concern with something like this:
1556
+
1557
+ module Copyable
1558
+ def copy_to(destination)
1559
+ Notification.suppress do
1560
+ # Copy logic that creates new comments that we do not want triggering
1561
+ # notifications.
1562
+ end
1563
+ end
1564
+ end
1343
1565
 
1344
- * Fix bug that added `table_name_prefix` and `table_name_suffix` to
1345
- extension names in PostgreSQL when migrating.
1566
+ *Michael Ryan*
1346
1567
 
1347
- *Joao Carlos*
1568
+ * `:time` option added for `#touch`.
1348
1569
 
1349
- * The `:index` option in migrations, which previously was only available for
1350
- `references`, now works with any column types.
1570
+ Fixes #18905.
1351
1571
 
1352
- *Marc Schütz*
1572
+ *Hyonjee Joo*
1353
1573
 
1354
- * Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
1574
+ * Add `foreign_key_exists?` method.
1355
1575
 
1356
- *jnormore*
1576
+ *Tõnis Simo*
1357
1577
 
1358
- * Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
1359
- or `offset`.
1578
+ * Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods
1579
+ if no block or limit is given, instead of loading the entire
1580
+ collection into memory. This applies to relations (e.g. `User.all`)
1581
+ as well as associations (e.g. `account.users`)
1360
1582
 
1361
- In these cases the generated query ignored them and that caused unintended
1362
- records to be deleted.
1583
+ # Before:
1363
1584
 
1364
- Fixes #11985.
1585
+ users.none?
1586
+ # SELECT "users".* FROM "users"
1365
1587
 
1366
- *Leandro Facchinetti*
1588
+ users.one?
1589
+ # SELECT "users".* FROM "users"
1367
1590
 
1368
- * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
1369
- their limit dropped from the schema.
1591
+ # After:
1370
1592
 
1371
- Fixes #14135.
1593
+ users.none?
1594
+ # SELECT 1 AS one FROM "users" LIMIT 1
1372
1595
 
1373
- *Aaron Nelson*
1596
+ users.one?
1597
+ # SELECT COUNT(*) FROM "users"
1374
1598
 
1375
- * Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
1376
- association.
1599
+ *Eugene Gilburg*
1377
1600
 
1378
- Fixes #14709.
1601
+ * Have `enum` perform type casting consistently with the rest of Active
1602
+ Record, such as `where`.
1379
1603
 
1380
- *Kassio Borges*
1604
+ *Sean Griffin*
1381
1605
 
1382
- * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
1383
- strings in column names as equal.
1606
+ * `scoping` no longer pollutes the current scope of sibling classes when using
1607
+ STI.
1384
1608
 
1385
- This fixes a rare case in which more bind values are passed than there are
1386
- placeholders for them in the generated SQL statement, which can make PostgreSQL
1387
- throw a `StatementInvalid` exception.
1609
+ Fixes #18806.
1388
1610
 
1389
- *Nat Budin*
1611
+ Example:
1390
1612
 
1391
- * Fix `stored_attributes` to correctly merge the details of stored
1392
- attributes defined in parent classes.
1613
+ StiOne.none.scoping do
1614
+ StiTwo.all
1615
+ end
1393
1616
 
1394
- Fixes #14672.
1395
1617
 
1396
- *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
1618
+ *Sean Griffin*
1397
1619
 
1398
- * `change_column_default` allows `[]` as argument to `change_column_default`.
1620
+ * `remove_reference` with `foreign_key: true` removes the foreign key before
1621
+ removing the column. This fixes a bug where it was not possible to remove
1622
+ the column on MySQL.
1399
1623
 
1400
- Fixes #11586.
1624
+ Fixes #18664.
1401
1625
 
1402
1626
  *Yves Senn*
1403
1627
 
1404
- * Handle `name` and `"char"` column types in the PostgreSQL adapter.
1405
-
1406
- `name` and `"char"` are special character types used internally by
1407
- PostgreSQL and are used by internal system catalogs. These field types
1408
- can sometimes show up in structure-sniffing queries that feature internal system
1409
- structures or with certain PostgreSQL extensions.
1628
+ * `find_in_batches` now accepts an `:finish` parameter that complements the `:start`
1629
+ parameter to specify where to stop batch processing.
1410
1630
 
1411
- *J Smith*, *Yves Senn*
1631
+ *Vipul A M*
1412
1632
 
1413
- * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
1414
- NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
1633
+ * Fix a rounding problem for PostgreSQL timestamp columns.
1415
1634
 
1416
- Before:
1417
-
1418
- Point.create(value: 1.0/0)
1419
- Point.last.value # => 0.0
1635
+ If a timestamp column has a precision specified, it needs to
1636
+ format according to that.
1420
1637
 
1421
- After:
1638
+ *Ryuta Kamizono*
1422
1639
 
1423
- Point.create(value: 1.0/0)
1424
- Point.last.value # => Infinity
1640
+ * Respect the database default charset for `schema_migrations` table.
1425
1641
 
1426
- *Innokenty Mikhailov*
1642
+ The charset of `version` column in `schema_migrations` table depends
1643
+ on the database default charset and collation rather than the encoding
1644
+ of the connection.
1427
1645
 
1428
- * Allow the PostgreSQL adapter to handle bigserial primary key types again.
1646
+ *Ryuta Kamizono*
1429
1647
 
1430
- Fixes #10410.
1648
+ * Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
1431
1649
 
1432
- *Patrick Robertson*
1650
+ These are not valid values to merge in a relation, so it should warn users
1651
+ early.
1433
1652
 
1434
- * Deprecate joining, eager loading and preloading of instance dependent
1435
- associations without replacement. These operations happen before instances
1436
- are created. The current behavior is unexpected and can result in broken
1437
- behavior.
1653
+ *Rafael Mendonça França*
1438
1654
 
1439
- Fixes #15024.
1655
+ * Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
1440
1656
 
1441
- *Yves Senn*
1657
+ This makes the `db:structure` tasks consistent with `test:load_structure`.
1442
1658
 
1443
- * Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
1659
+ *Dieter Komendera*
1444
1660
 
1445
- `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
1446
- size calculation if the collection is not cached or loaded.
1661
+ * Respect custom primary keys for associations when calling `Relation#where`
1447
1662
 
1448
- Fixes #14913, #14914.
1663
+ Fixes #18813.
1449
1664
 
1450
- *Fred Wu*
1665
+ *Sean Griffin*
1451
1666
 
1452
- * Return a non zero status when running `rake db:migrate:status` and migration table does
1453
- not exist.
1667
+ * Fix several edge cases which could result in a counter cache updating
1668
+ twice or not updating at all for `has_many` and `has_many :through`.
1454
1669
 
1455
- *Paul B.*
1670
+ Fixes #10865.
1456
1671
 
1457
- * Add support for module-level `table_name_suffix` in models.
1672
+ *Sean Griffin*
1458
1673
 
1459
- This makes `table_name_suffix` work the same way as `table_name_prefix` when
1460
- using namespaced models.
1674
+ * Foreign keys added by migrations were given random, generated names. This
1675
+ meant a different `structure.sql` would be generated every time a developer
1676
+ ran migrations on their machine.
1461
1677
 
1462
- *Jenner LaFave*
1678
+ The generated part of foreign key names is now a hash of the table name and
1679
+ column name, which is consistent every time you run the migration.
1463
1680
 
1464
- * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
1681
+ *Chris Sinjakli*
1465
1682
 
1466
- In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
1467
- In 4.0 series it is delegated to `Array#join`.
1683
+ * Fix n+1 query problem when eager loading nil associations (fixes #18312)
1468
1684
 
1469
- *Bogdan Gusiev*
1685
+ *Sammy Larbi*
1470
1686
 
1471
- * Log nil binary column values correctly.
1687
+ * Change the default error message from `can't be blank` to `must exist` for
1688
+ the presence validator of the `:required` option on `belongs_to`/`has_one`
1689
+ associations.
1472
1690
 
1473
- When an object with a binary column is updated with a nil value
1474
- in that column, the SQL logger would throw an exception when trying
1475
- to log that nil value. This only occurs when updating a record
1476
- that already has a non-nil value in that column since an initial nil
1477
- value isn't included in the SQL anyway (at least, when dirty checking
1478
- is enabled.) The column's new value will now be logged as `<NULL binary data>`
1479
- to parallel the existing `<N bytes of binary data>` for non-nil values.
1691
+ *Henrik Nygren*
1480
1692
 
1481
- *James Coleman*
1693
+ * Fixed `ActiveRecord::Relation#group` method when an argument is an SQL
1694
+ reserved keyword:
1482
1695
 
1483
- * Rails will now pass a custom validation context through to autosave associations
1484
- in order to validate child associations with the same context.
1696
+ Example:
1485
1697
 
1486
- Fixes #13854.
1698
+ SplitTest.group(:key).count
1699
+ Property.group(:value).count
1487
1700
 
1488
- *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
1701
+ *Bogdan Gusiev*
1489
1702
 
1490
- * Stringify all variables keys of MySQL connection configuration.
1703
+ * Added the `#or` method on `ActiveRecord::Relation`, allowing use of the OR
1704
+ operator to combine WHERE or HAVING clauses.
1491
1705
 
1492
- When `sql_mode` variable for MySQL adapters set in configuration as `String`
1493
- was ignored and overwritten by strict mode option.
1706
+ Example:
1494
1707
 
1495
- Fixes #14895.
1708
+ Post.where('id = 1').or(Post.where('id = 2'))
1709
+ # => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
1496
1710
 
1497
- *Paul Nikitochkin*
1711
+ *Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
1498
1712
 
1499
- * Ensure SQLite3 statements are closed on errors.
1713
+ * Don't define autosave association callbacks twice from
1714
+ `accepts_nested_attributes_for`.
1500
1715
 
1501
- Fixes #13631.
1716
+ Fixes #18704.
1502
1717
 
1503
- *Timur Alperovich*
1718
+ *Sean Griffin*
1504
1719
 
1505
- * Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
1720
+ * Integer types will no longer raise a `RangeError` when assigning an
1721
+ attribute, but will instead raise when going to the database.
1506
1722
 
1507
- *Hector Satre*
1723
+ Fixes several vague issues which were never reported directly. See the
1724
+ commit message from the commit which added this line for some examples.
1508
1725
 
1509
- * When using a custom `join_table` name on a `habtm`, rails was not saving it
1510
- on Reflections. This causes a problem when rails loads fixtures, because it
1511
- uses the reflections to set database with fixtures.
1726
+ *Sean Griffin*
1512
1727
 
1513
- Fixes #14845.
1728
+ * Values which would error while being sent to the database (such as an
1729
+ ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
1730
+ assignment. They will still error when sent to the database, but you are
1731
+ given the ability to re-assign it to a valid value.
1514
1732
 
1515
- *Kassio Borges*
1733
+ Fixes #18580.
1516
1734
 
1517
- * Reset the cache when modifying a Relation with cached Arel.
1518
- Additionally display a warning message to make the user aware.
1735
+ *Sean Griffin*
1519
1736
 
1520
- *Yves Senn*
1737
+ * Don't remove join dependencies in `Relation#exists?`
1521
1738
 
1522
- * PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
1523
- different spellings of timestamps are treated the same.
1739
+ Fixes #18632.
1524
1740
 
1525
- Example:
1741
+ *Sean Griffin*
1526
1742
 
1527
- mytimestamp.simplified_type('timestamp without time zone')
1528
- # => :datetime
1529
- mytimestamp.simplified_type('timestamp(6) without time zone')
1530
- # => also :datetime (previously would be :timestamp)
1743
+ * Invalid values assigned to a JSON column are assumed to be `nil`.
1531
1744
 
1532
- See #14513.
1745
+ Fixes #18629.
1533
1746
 
1534
- *Jefferson Lai*
1747
+ *Sean Griffin*
1535
1748
 
1536
- * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
1749
+ * Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
1750
+ discover which fields were read from a model when you are looking to only
1751
+ select the data you need from the database.
1537
1752
 
1538
- Fixes #14841.
1753
+ *Sean Griffin*
1539
1754
 
1540
- *Lucas Mazza*
1755
+ * Introduce the `:if_exists` option for `drop_table`.
1541
1756
 
1542
- * Fix name collision with `Array#select!` with `Relation#select!`.
1757
+ Example:
1543
1758
 
1544
- Fixes #14752.
1759
+ drop_table(:posts, if_exists: true)
1545
1760
 
1546
- *Earl St Sauver*
1761
+ That would execute:
1547
1762
 
1548
- * Fix unexpected behavior for `has_many :through` associations going through
1549
- a scoped `has_many`.
1763
+ DROP TABLE IF EXISTS posts
1550
1764
 
1551
- If a `has_many` association is adjusted using a scope, and another
1552
- `has_many :through` uses this association, then the scope adjustment is
1553
- unexpectedly neglected.
1765
+ If the table doesn't exist, `if_exists: false` (the default) raises an
1766
+ exception whereas `if_exists: true` does nothing.
1554
1767
 
1555
- Fixes #14537.
1768
+ *Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
1556
1769
 
1557
- *Jan Habermann*
1770
+ * Don't run SQL if attribute value is not changed for update_attribute method.
1558
1771
 
1559
- * `@destroyed` should always be set to `false` when an object is duped.
1772
+ *Prathamesh Sonpatki*
1560
1773
 
1561
- *Kuldeep Aggarwal*
1774
+ * `time` columns can now get affected by `time_zone_aware_attributes`. If you have
1775
+ set `config.time_zone` to a value other than `'UTC'`, they will be treated
1776
+ as in that time zone by default in Rails 5.1. If this is not the desired
1777
+ behavior, you can set
1562
1778
 
1563
- * Enable `has_many` associations to support irregular inflections.
1779
+ ActiveRecord::Base.time_zone_aware_types = [:datetime]
1564
1780
 
1565
- Fixes #8928.
1781
+ A deprecation warning will be emitted if you have a `:time` column, and have
1782
+ not explicitly opted out.
1566
1783
 
1567
- *arthurnn*, *Javier Goizueta*
1784
+ Fixes #3145.
1568
1785
 
1569
- * Fix `count` used with a grouping not returning a Hash.
1786
+ *Sean Griffin*
1570
1787
 
1571
- Fixes #14721.
1788
+ * Tests now run after_commit callbacks. You no longer have to declare
1789
+ `uses_transaction ‘test name’` to test the results of an after_commit.
1572
1790
 
1573
- *Eric Chahin*
1791
+ after_commit callbacks run after committing a transaction whose parent
1792
+ is not `joinable?`: un-nested transactions, transactions within test cases,
1793
+ and transactions in `console --sandbox`.
1574
1794
 
1575
- * `sanitize_sql_like` helper method to escape a string for safe use in an SQL
1576
- LIKE statement.
1795
+ *arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
1577
1796
 
1578
- Example:
1797
+ * `nil` as a value for a binary column in a query no longer logs as
1798
+ "<NULL binary data>", and instead logs as just "nil".
1579
1799
 
1580
- class Article
1581
- def self.search(term)
1582
- where("title LIKE ?", sanitize_sql_like(term))
1583
- end
1584
- end
1800
+ *Sean Griffin*
1585
1801
 
1586
- Article.search("20% _reduction_")
1587
- # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
1802
+ * `attribute_will_change!` will no longer cause non-persistable attributes to
1803
+ be sent to the database.
1588
1804
 
1589
- *Rob Gilson*, *Yves Senn*
1805
+ Fixes #18407.
1590
1806
 
1591
- * Do not quote uuid default value on `change_column`.
1807
+ *Sean Griffin*
1592
1808
 
1593
- Fixes #14604.
1809
+ * Remove support for the `protected_attributes` gem.
1594
1810
 
1595
- *Eric Chahin*
1811
+ *Carlos Antonio da Silva*, *Roberto Miranda*
1596
1812
 
1597
- * The comparison between `Relation` and `CollectionProxy` should be consistent.
1813
+ * Fix accessing of fixtures having non-string labels like Fixnum.
1598
1814
 
1599
- Example:
1815
+ *Prathamesh Sonpatki*
1600
1816
 
1601
- author.posts == Post.where(author_id: author.id)
1602
- # => true
1603
- Post.where(author_id: author.id) == author.posts
1604
- # => true
1817
+ * Remove deprecated support to preload instance-dependent associations.
1605
1818
 
1606
- Fixes #13506.
1819
+ *Yves Senn*
1607
1820
 
1608
- *Lauro Caetano*
1821
+ * Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
1609
1822
 
1610
- * Calling `delete_all` on an unloaded `CollectionProxy` no longer
1611
- generates an SQL statement containing each id of the collection:
1823
+ *Yves Senn*
1612
1824
 
1613
- Before:
1825
+ * Remove deprecation when modifying a relation with cached Arel.
1826
+ This raises an `ImmutableRelation` error instead.
1614
1827
 
1615
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
1616
- AND `model`.`id` IN (1, 2, 3...)
1828
+ *Yves Senn*
1617
1829
 
1618
- After:
1830
+ * Added `ActiveRecord::SecureToken` in order to encapsulate generation of
1831
+ unique tokens for attributes in a model using `SecureRandom`.
1619
1832
 
1620
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
1833
+ *Roberto Miranda*
1621
1834
 
1622
- *Eileen M. Uchitelle*, *Aaron Patterson*
1835
+ * Change the behavior of boolean columns to be closer to Ruby's semantics.
1623
1836
 
1624
- * Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
1625
- with `select`.
1837
+ Before this change we had a small set of "truthy", and all others are "falsy".
1626
1838
 
1627
- Fixes #13648.
1839
+ Now, we have a small set of "falsy" values and all others are "truthy" matching
1840
+ Ruby's semantics.
1628
1841
 
1629
- *Simon Woker*
1842
+ *Rafael Mendonça França*
1630
1843
 
1631
- * PostgreSQL adapter only warns once for every missing OID per connection.
1844
+ * Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
1632
1845
 
1633
- Fixes #14275.
1846
+ *Rafael Mendonça França*
1634
1847
 
1635
- *Matthew Draper*, *Yves Senn*
1848
+ * Change transaction callbacks to not swallow errors.
1636
1849
 
1637
- * PostgreSQL adapter automatically reloads it's type map when encountering
1638
- unknown OIDs.
1850
+ Before this change any errors raised inside a transaction callback
1851
+ were getting rescued and printed in the logs.
1639
1852
 
1640
- Fixes #14678.
1853
+ Now these errors are not rescued anymore and just bubble up, as the other callbacks.
1641
1854
 
1642
- *Matthew Draper*, *Yves Senn*
1855
+ *Rafael Mendonça França*
1643
1856
 
1644
- * Fix insertion of records via `has_many :through` association with scope.
1857
+ * Remove deprecated `sanitize_sql_hash_for_conditions`.
1645
1858
 
1646
- Fixes #3548.
1859
+ *Rafael Mendonça França*
1647
1860
 
1648
- *Ivan Antropov*
1861
+ * Remove deprecated `Reflection#source_macro`.
1649
1862
 
1650
- * Auto-generate stable fixture UUIDs on PostgreSQL.
1863
+ *Rafael Mendonça França*
1651
1864
 
1652
- Fixes #11524.
1865
+ * Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
1653
1866
 
1654
- *Roderick van Domburg*
1867
+ *Rafael Mendonça França*
1655
1868
 
1656
- * Fix a problem where an enum would overwrite values of another enum with the
1657
- same name in an unrelated class.
1869
+ * Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
1658
1870
 
1659
- Fixes #14607.
1871
+ *Rafael Mendonça França*
1660
1872
 
1661
- *Evan Whalen*
1873
+ * Remove deprecated access to connection specification using a string accessor.
1662
1874
 
1663
- * PostgreSQL and SQLite string columns no longer have a default limit of 255.
1875
+ Now all strings will be handled as a URL.
1664
1876
 
1665
- Fixes #13435, #9153.
1877
+ *Rafael Mendonça França*
1666
1878
 
1667
- *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
1879
+ * Change the default `null` value for `timestamps` to `false`.
1668
1880
 
1669
- * Make possible to have an association called `records`.
1881
+ *Rafael Mendonça França*
1670
1882
 
1671
- Fixes #11645.
1883
+ * Return an array of pools from `connection_pools`.
1672
1884
 
1673
- *prathamesh-sonpatki*
1885
+ *Rafael Mendonça França*
1674
1886
 
1675
- * `to_sql` on an association now matches the query that is actually executed, where it
1676
- could previously have incorrectly accrued additional conditions (e.g. as a result of
1677
- a previous query). `CollectionProxy` now always defers to the association scope's
1678
- `arel` method so the (incorrect) inherited one should be entirely concealed.
1887
+ * Return a null column from `column_for_attribute` when no column exists.
1679
1888
 
1680
- Fixes #14003.
1889
+ *Rafael Mendonça França*
1681
1890
 
1682
- *Jefferson Lai*
1891
+ * Remove deprecated `serialized_attributes`.
1683
1892
 
1684
- * Block a few default Class methods as scope name.
1893
+ *Rafael Mendonça França*
1685
1894
 
1686
- For instance, this will raise:
1895
+ * Remove deprecated automatic counter caches on `has_many :through`.
1687
1896
 
1688
- scope :public, -> { where(status: 1) }
1897
+ *Rafael Mendonça França*
1689
1898
 
1690
- *arthurnn*
1899
+ * Change the way in which callback chains can be halted.
1691
1900
 
1692
- * Fix error when using `with_options` with lambda.
1901
+ The preferred method to halt a callback chain from now on is to explicitly
1902
+ `throw(:abort)`.
1903
+ In the past, returning `false` in an Active Record `before_` callback had the
1904
+ side effect of halting the callback chain.
1905
+ This is not recommended anymore and, depending on the value of the
1906
+ `ActiveSupport.halt_callback_chains_on_return_false` option, will
1907
+ either not work at all or display a deprecation warning.
1693
1908
 
1694
- Fixes #9805.
1909
+ *claudiob*
1695
1910
 
1696
- *Lauro Caetano*
1911
+ * Clear query cache on rollback.
1697
1912
 
1698
- * Switch `sqlite3:///` URLs (which were temporarily
1699
- deprecated in 4.1) from relative to absolute.
1913
+ *Florian Weingarten*
1700
1914
 
1701
- If you still want the previous interpretation, you should replace
1702
- `sqlite3:///my/path` with `sqlite3:my/path`.
1915
+ * Fix setting of foreign_key for through associations when building a new record.
1703
1916
 
1704
- *Matthew Draper*
1917
+ Fixes #12698.
1705
1918
 
1706
- * Treat blank UUID values as `nil`.
1919
+ *Ivan Antropov*
1707
1920
 
1708
- Example:
1921
+ * Improve dumping of the primary key. If it is not a default primary key,
1922
+ correctly dump the type and options.
1709
1923
 
1710
- Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
1924
+ Fixes #14169, #16599.
1711
1925
 
1712
- *Dmitry Lavrov*
1926
+ *Ryuta Kamizono*
1713
1927
 
1714
- * Enable support for materialized views on PostgreSQL >= 9.3.
1928
+ * Format the datetime string according to the precision of the datetime field.
1715
1929
 
1716
- *Dave Lee*
1930
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
1717
1931
 
1718
- * The PostgreSQL adapter supports custom domains. Fixes #14305.
1932
+ In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
1933
+ is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
1719
1934
 
1720
- *Yves Senn*
1935
+ http://bugs.mysql.com/bug.php?id=68760
1721
1936
 
1722
- * PostgreSQL `Column#type` is now determined through the corresponding OID.
1723
- The column types stay the same except for enum columns. They no longer have
1724
- `nil` as type but `enum`.
1937
+ *Ryuta Kamizono*
1725
1938
 
1726
- See #7814.
1939
+ * Allow a precision option for MySQL datetimes.
1727
1940
 
1728
- *Yves Senn*
1941
+ *Ryuta Kamizono*
1729
1942
 
1730
- * Fix error when specifying a non-empty default value on a PostgreSQL array
1731
- column.
1943
+ * Fixed automatic `inverse_of` for models nested in a module.
1732
1944
 
1733
- Fixes #10613.
1945
+ *Andrew McCloud*
1734
1946
 
1735
- *Luke Steensen*
1947
+ * Change `ActiveRecord::Relation#update` behavior so that it can
1948
+ be called without passing ids of the records to be updated.
1736
1949
 
1737
- * Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
1738
- custom primary key that did not save due to validation error.
1950
+ This change allows updating multiple records returned by
1951
+ `ActiveRecord::Relation` with callbacks and validations.
1739
1952
 
1740
- Fixes #14393.
1953
+ # Before
1954
+ # ArgumentError: wrong number of arguments (1 for 2)
1955
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
1741
1956
 
1742
- *Chris Finne*
1957
+ # After
1958
+ # Comments with group expert updated with body "Group of Rails Experts"
1959
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
1743
1960
 
1744
- * Introduce `validate` as an alias for `valid?`.
1961
+ *Prathamesh Sonpatki*
1745
1962
 
1746
- This is more intuitive when you want to run validations but don't care about the return value.
1963
+ * Fix `reaping_frequency` option when the value is a string.
1747
1964
 
1748
- *Henrik Nyh*
1965
+ This usually happens when it is configured using `DATABASE_URL`.
1749
1966
 
1750
- * Create indexes inline in CREATE TABLE for MySQL.
1967
+ *korbin*
1751
1968
 
1752
- This is important, because adding an index on a temporary table after it has been created
1753
- would commit the transaction.
1969
+ * Fix error message when trying to create an associated record and the foreign
1970
+ key is missing.
1754
1971
 
1755
- It also allows creating and dropping indexed tables with fewer queries and fewer permissions
1756
- required.
1972
+ Before this fix the following exception was being raised:
1757
1973
 
1758
- Example:
1974
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
1759
1975
 
1760
- create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
1761
- t.index :zip
1762
- end
1763
- # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
1976
+ Now the message is:
1764
1977
 
1765
- *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
1978
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
1766
1979
 
1767
- * Use singular table name in generated migrations when
1768
- `ActiveRecord::Base.pluralize_table_names` is `false`.
1980
+ *Rafael Mendonça França*
1769
1981
 
1770
- Fixes #13426.
1982
+ * Fix change detection problem for PostgreSQL bytea type and
1983
+ `ArgumentError: string contains null byte` exception with pg-0.18.
1771
1984
 
1772
- *Kuldeep Aggarwal*
1985
+ Fixes #17680.
1773
1986
 
1774
- * `touch` accepts many attributes to be touched at once.
1987
+ *Lars Kanis*
1775
1988
 
1776
- Example:
1989
+ * When a table has a composite primary key, the `primary_key` method for
1990
+ SQLite3 and PostgreSQL adapters was only returning the first field of the key.
1991
+ Ensures that it will return nil instead, as Active Record doesn't support
1992
+ composite primary keys.
1777
1993
 
1778
- # touches :signed_at, :sealed_at, and :updated_at/on attributes.
1779
- Photo.last.touch(:signed_at, :sealed_at)
1994
+ Fixes #18070.
1780
1995
 
1781
- *James Pinto*
1996
+ *arthurnn*
1782
1997
 
1783
- * `rake db:structure:dump` only dumps schema information if the schema
1784
- migration table exists.
1998
+ * `validates_size_of` / `validates_length_of` do not count records
1999
+ which are `marked_for_destruction?`.
1785
2000
 
1786
- Fixes #14217.
2001
+ Fixes #7247.
1787
2002
 
1788
2003
  *Yves Senn*
1789
2004
 
1790
- * Reap connections that were checked out by now-dead threads, instead
1791
- of waiting until they disconnect by themselves. Before this change,
1792
- a suitably constructed series of short-lived threads could starve
1793
- the connection pool, without ever having more than a couple alive at
1794
- the same time.
1795
-
1796
- *Matthew Draper*
1797
-
1798
- * `pk_and_sequence_for` now ensures that only the pg_depend entries
1799
- pointing to pg_class, and thus only sequence objects, are considered.
1800
-
1801
- *Josh Williams*
2005
+ * Ensure `first!` and friends work on loaded associations.
1802
2006
 
1803
- * `where.not` adds `references` for `includes` like normal `where` calls do.
2007
+ Fixes #18237.
1804
2008
 
1805
- Fixes #14406.
2009
+ *Sean Griffin*
1806
2010
 
1807
- *Yves Senn*
2011
+ * `eager_load` preserves readonly flag for associations.
1808
2012
 
1809
- * Extend fixture `$LABEL` replacement to allow string interpolation.
2013
+ Fixes #15853.
1810
2014
 
1811
- Example:
2015
+ *Takashi Kokubun*
1812
2016
 
1813
- martin:
1814
- email: $LABEL@email.com
2017
+ * Provide `:touch` option to `save()` to accommodate saving without updating
2018
+ timestamps.
1815
2019
 
1816
- users(:martin).email # => martin@email.com
2020
+ Fixes #18202.
1817
2021
 
1818
- *Eric Steele*
2022
+ *Dan Olson*
1819
2023
 
1820
- * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
2024
+ * Provide a more helpful error message when an unsupported class is passed to
2025
+ `serialize`.
1821
2026
 
1822
- Fixes #14361.
2027
+ Fixes #18224.
1823
2028
 
1824
- *arthurnn*
2029
+ *Sean Griffin*
1825
2030
 
1826
- * Passing an Active Record object to `find` or `exists?` is now deprecated.
1827
- Call `.id` on the object first.
2031
+ * Add bigint primary key support for MySQL.
1828
2032
 
1829
- *Aaron Patterson*
2033
+ Example:
1830
2034
 
1831
- * Only use BINARY for MySQL case sensitive uniqueness check when column
1832
- has a case insensitive collation.
2035
+ create_table :foos, id: :bigint do |t|
2036
+ end
1833
2037
 
1834
2038
  *Ryuta Kamizono*
1835
2039
 
1836
- * Support for MySQL 5.6 fractional seconds.
2040
+ * Support for any type of primary key.
1837
2041
 
1838
- *arthurnn*, *Tatsuhiko Miyagawa*
2042
+ Fixes #14194.
1839
2043
 
1840
- * Support for PostgreSQL `citext` data type enabling case-insensitive
1841
- `where` values without needing to wrap in UPPER/LOWER sql functions.
2044
+ *Ryuta Kamizono*
1842
2045
 
1843
- *Troy Kruthoff*, *Lachlan Sylvester*
2046
+ * Dump the default `nil` for PostgreSQL UUID primary key.
1844
2047
 
1845
- * Only save has_one associations if record has changes.
1846
- Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
1847
- object did not get saved to the db.
2048
+ *Ryuta Kamizono*
1848
2049
 
1849
- *Alan Kennedy*
2050
+ * Add a `:foreign_key` option to `references` and associated migration
2051
+ methods. The model and migration generators now use this option, rather than
2052
+ the `add_foreign_key` form.
1850
2053
 
1851
- * Allow strings to specify the `#order` value.
2054
+ *Sean Griffin*
1852
2055
 
1853
- Example:
2056
+ * Don't raise when writing an attribute with an out-of-range datetime passed
2057
+ by the user.
1854
2058
 
1855
- Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
2059
+ *Grey Baker*
1856
2060
 
1857
- *Marcelo Casiraghi*, *Robin Dupret*
2061
+ * Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
2062
+ `ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
1858
2063
 
1859
- * Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
1860
- warnings on enum columns.
2064
+ *Yves Senn*
1861
2065
 
1862
- *Dieter Komendera*
2066
+ * Fix bug with `ActiveRecord::Type::Numeric` that caused negative values to
2067
+ be marked as having changed when set to the same negative value.
1863
2068
 
1864
- * `includes` is able to detect the right preloading strategy when string
1865
- joins are involved.
2069
+ Fixes #18161.
1866
2070
 
1867
- Fixes #14109.
2071
+ *Daniel Fox*
1868
2072
 
1869
- *Aaron Patterson*, *Yves Senn*
2073
+ * Introduce `force: :cascade` option for `create_table`. Using this option
2074
+ will recreate tables even if they have dependent objects (like foreign keys).
2075
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
2076
+ reload the schema when foreign keys are in place.
1870
2077
 
1871
- * Fix error with validation with enum fields for records where the value for
1872
- any enum attribute is always evaluated as 0 during uniqueness validation.
2078
+ *Matthew Draper*, *Yves Senn*
1873
2079
 
1874
- Fixes #14172.
2080
+ * `db:schema:load` and `db:structure:load` no longer purge the database
2081
+ before loading the schema. This is left for the user to do.
2082
+ `db:test:prepare` will still purge the database.
1875
2083
 
1876
- *Vilius Luneckas* *Ahmed AbouElhamayed*
2084
+ Fixes #17945.
1877
2085
 
1878
- * `before_add` callbacks are fired before the record is saved on
1879
- `has_and_belongs_to_many` associations *and* on `has_many :through`
1880
- associations. Before this change, `before_add` callbacks would be fired
1881
- before the record was saved on `has_and_belongs_to_many` associations, but
1882
- *not* on `has_many :through` associations.
2086
+ *Yves Senn*
1883
2087
 
1884
- Fixes #14144.
2088
+ * Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
1885
2089
 
1886
- * Fix STI classes not defining an attribute method if there is a conflicting
1887
- private method defined on its ancestors.
2090
+ *Ryuta Kamizono*
1888
2091
 
1889
- Fixes #11569.
2092
+ * Add `foreign_type` option to `has_one` and `has_many` association macros.
1890
2093
 
1891
- *Godfrey Chan*
2094
+ This option enables to define the column name of associated object's type for polymorphic associations.
1892
2095
 
1893
- * Coerce strings when reading attributes. Fixes #10485.
2096
+ *Ulisses Almeida*, *Kassio Borges*
1894
2097
 
1895
- Example:
2098
+ * Remove deprecated behavior allowing nested arrays to be passed as query
2099
+ values.
1896
2100
 
1897
- book = Book.new(title: 12345)
1898
- book.save!
1899
- book.title # => "12345"
2101
+ *Melanie Gilman*
1900
2102
 
1901
- *Yves Senn*
2103
+ * Deprecate passing a class as a value in a query. Users should pass strings
2104
+ instead.
1902
2105
 
1903
- * Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
1904
- We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
1905
- possible because the Ruby range does not support excluded beginnings.
2106
+ *Melanie Gilman*
1906
2107
 
1907
- The current solution of incrementing the beginning is not correct and is now
1908
- deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
1909
- is not defined) it will raise an `ArgumentException` for ranges with excluding
1910
- beginnings.
2108
+ * `add_timestamps` and `remove_timestamps` now properly reversible with
2109
+ options.
1911
2110
 
1912
- *Yves Senn*
2111
+ *Noam Gagliardi-Rabinovich*
1913
2112
 
1914
- * Support for user created range types in PostgreSQL.
2113
+ * `ActiveRecord::ConnectionAdapters::ColumnDumper#column_spec` and
2114
+ `ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
2115
+ longer have a `types` argument. They should access
2116
+ `connection#native_database_types` directly.
1915
2117
 
1916
2118
  *Yves Senn*
1917
2119
 
1918
- Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.
2120
+ Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.