activerecord 5.0.7.2 → 5.1.0.beta1

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 (216) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +389 -2252
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/examples/performance.rb +28 -28
  6. data/examples/simple.rb +3 -3
  7. data/lib/active_record.rb +20 -20
  8. data/lib/active_record/aggregations.rb +244 -244
  9. data/lib/active_record/association_relation.rb +5 -5
  10. data/lib/active_record/associations.rb +1579 -1569
  11. data/lib/active_record/associations/alias_tracker.rb +1 -1
  12. data/lib/active_record/associations/association.rb +23 -15
  13. data/lib/active_record/associations/association_scope.rb +83 -81
  14. data/lib/active_record/associations/belongs_to_association.rb +0 -1
  15. data/lib/active_record/associations/builder/belongs_to.rb +16 -14
  16. data/lib/active_record/associations/builder/collection_association.rb +1 -2
  17. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +27 -27
  18. data/lib/active_record/associations/collection_association.rb +74 -241
  19. data/lib/active_record/associations/collection_proxy.rb +144 -70
  20. data/lib/active_record/associations/has_many_association.rb +15 -19
  21. data/lib/active_record/associations/has_many_through_association.rb +12 -5
  22. data/lib/active_record/associations/has_one_association.rb +22 -28
  23. data/lib/active_record/associations/has_one_through_association.rb +5 -1
  24. data/lib/active_record/associations/join_dependency.rb +117 -115
  25. data/lib/active_record/associations/join_dependency/join_association.rb +16 -13
  26. data/lib/active_record/associations/join_dependency/join_base.rb +1 -1
  27. data/lib/active_record/associations/join_dependency/join_part.rb +1 -1
  28. data/lib/active_record/associations/preloader.rb +94 -94
  29. data/lib/active_record/associations/preloader/association.rb +87 -64
  30. data/lib/active_record/associations/preloader/belongs_to.rb +0 -2
  31. data/lib/active_record/associations/preloader/collection_association.rb +6 -6
  32. data/lib/active_record/associations/preloader/has_many.rb +0 -2
  33. data/lib/active_record/associations/preloader/singular_association.rb +6 -8
  34. data/lib/active_record/associations/preloader/through_association.rb +34 -41
  35. data/lib/active_record/associations/singular_association.rb +8 -25
  36. data/lib/active_record/associations/through_association.rb +3 -6
  37. data/lib/active_record/attribute.rb +98 -71
  38. data/lib/active_record/attribute/user_provided_default.rb +4 -2
  39. data/lib/active_record/attribute_assignment.rb +61 -61
  40. data/lib/active_record/attribute_decorators.rb +35 -13
  41. data/lib/active_record/attribute_methods.rb +56 -65
  42. data/lib/active_record/attribute_methods/before_type_cast.rb +7 -7
  43. data/lib/active_record/attribute_methods/dirty.rb +216 -34
  44. data/lib/active_record/attribute_methods/primary_key.rb +78 -73
  45. data/lib/active_record/attribute_methods/read.rb +39 -35
  46. data/lib/active_record/attribute_methods/serialization.rb +7 -7
  47. data/lib/active_record/attribute_methods/time_zone_conversion.rb +35 -58
  48. data/lib/active_record/attribute_methods/write.rb +36 -30
  49. data/lib/active_record/attribute_mutation_tracker.rb +53 -10
  50. data/lib/active_record/attribute_set.rb +9 -6
  51. data/lib/active_record/attribute_set/builder.rb +41 -49
  52. data/lib/active_record/attribute_set/yaml_encoder.rb +41 -0
  53. data/lib/active_record/attributes.rb +21 -21
  54. data/lib/active_record/autosave_association.rb +13 -13
  55. data/lib/active_record/base.rb +24 -22
  56. data/lib/active_record/callbacks.rb +52 -14
  57. data/lib/active_record/coders/yaml_column.rb +9 -11
  58. data/lib/active_record/collection_cache_key.rb +6 -17
  59. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +320 -278
  60. data/lib/active_record/connection_adapters/abstract/database_limits.rb +1 -3
  61. data/lib/active_record/connection_adapters/abstract/database_statements.rb +22 -34
  62. data/lib/active_record/connection_adapters/abstract/query_cache.rb +31 -27
  63. data/lib/active_record/connection_adapters/abstract/quoting.rb +44 -57
  64. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +9 -19
  65. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +78 -79
  66. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +53 -41
  67. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +99 -93
  68. data/lib/active_record/connection_adapters/abstract/transaction.rb +1 -5
  69. data/lib/active_record/connection_adapters/abstract_adapter.rb +156 -128
  70. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +424 -382
  71. data/lib/active_record/connection_adapters/column.rb +27 -5
  72. data/lib/active_record/connection_adapters/connection_specification.rb +128 -118
  73. data/lib/active_record/connection_adapters/mysql/column.rb +6 -31
  74. data/lib/active_record/connection_adapters/mysql/database_statements.rb +45 -43
  75. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +22 -22
  76. data/lib/active_record/connection_adapters/mysql/quoting.rb +6 -12
  77. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +49 -45
  78. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +16 -19
  79. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +49 -31
  80. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +5 -6
  81. data/lib/active_record/connection_adapters/mysql2_adapter.rb +24 -26
  82. data/lib/active_record/connection_adapters/postgresql/column.rb +1 -28
  83. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +46 -35
  84. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +3 -3
  85. data/lib/active_record/connection_adapters/postgresql/oid.rb +22 -21
  86. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +9 -9
  87. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +5 -3
  88. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +1 -1
  89. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +1 -1
  90. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +2 -2
  91. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +3 -3
  92. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +16 -16
  93. data/lib/active_record/connection_adapters/postgresql/oid/{rails_5_1_point.rb → legacy_point.rb} +9 -16
  94. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  95. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +13 -0
  96. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +28 -8
  97. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +28 -30
  98. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -1
  99. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +51 -51
  100. data/lib/active_record/connection_adapters/postgresql/quoting.rb +38 -36
  101. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +15 -0
  102. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +37 -24
  103. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +19 -23
  104. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +161 -170
  105. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +4 -4
  106. data/lib/active_record/connection_adapters/postgresql/utils.rb +9 -7
  107. data/lib/active_record/connection_adapters/postgresql_adapter.rb +179 -152
  108. data/lib/active_record/connection_adapters/schema_cache.rb +16 -7
  109. data/lib/active_record/connection_adapters/sql_type_metadata.rb +3 -3
  110. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +1 -1
  111. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +16 -20
  112. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +1 -8
  113. data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +28 -0
  114. data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +17 -0
  115. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +187 -130
  116. data/lib/active_record/connection_adapters/statement_pool.rb +7 -7
  117. data/lib/active_record/connection_handling.rb +14 -26
  118. data/lib/active_record/core.rb +110 -93
  119. data/lib/active_record/counter_cache.rb +62 -13
  120. data/lib/active_record/define_callbacks.rb +20 -0
  121. data/lib/active_record/dynamic_matchers.rb +80 -79
  122. data/lib/active_record/enum.rb +8 -6
  123. data/lib/active_record/errors.rb +58 -15
  124. data/lib/active_record/explain.rb +1 -2
  125. data/lib/active_record/explain_registry.rb +1 -1
  126. data/lib/active_record/explain_subscriber.rb +7 -4
  127. data/lib/active_record/fixture_set/file.rb +11 -8
  128. data/lib/active_record/fixtures.rb +66 -53
  129. data/lib/active_record/gem_version.rb +3 -3
  130. data/lib/active_record/inheritance.rb +93 -79
  131. data/lib/active_record/integration.rb +7 -7
  132. data/lib/active_record/internal_metadata.rb +3 -16
  133. data/lib/active_record/legacy_yaml_adapter.rb +1 -1
  134. data/lib/active_record/locking/optimistic.rb +64 -56
  135. data/lib/active_record/locking/pessimistic.rb +10 -1
  136. data/lib/active_record/log_subscriber.rb +29 -29
  137. data/lib/active_record/migration.rb +155 -172
  138. data/lib/active_record/migration/command_recorder.rb +94 -94
  139. data/lib/active_record/migration/compatibility.rb +76 -37
  140. data/lib/active_record/migration/join_table.rb +6 -6
  141. data/lib/active_record/model_schema.rb +85 -119
  142. data/lib/active_record/nested_attributes.rb +200 -199
  143. data/lib/active_record/null_relation.rb +10 -33
  144. data/lib/active_record/persistence.rb +45 -38
  145. data/lib/active_record/query_cache.rb +4 -8
  146. data/lib/active_record/querying.rb +2 -3
  147. data/lib/active_record/railtie.rb +16 -17
  148. data/lib/active_record/railties/controller_runtime.rb +6 -2
  149. data/lib/active_record/railties/databases.rake +125 -140
  150. data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
  151. data/lib/active_record/readonly_attributes.rb +2 -2
  152. data/lib/active_record/reflection.rb +79 -96
  153. data/lib/active_record/relation.rb +72 -115
  154. data/lib/active_record/relation/batches.rb +87 -58
  155. data/lib/active_record/relation/batches/batch_enumerator.rb +1 -1
  156. data/lib/active_record/relation/calculations.rb +154 -160
  157. data/lib/active_record/relation/delegation.rb +30 -29
  158. data/lib/active_record/relation/finder_methods.rb +195 -226
  159. data/lib/active_record/relation/merger.rb +58 -62
  160. data/lib/active_record/relation/predicate_builder.rb +92 -89
  161. data/lib/active_record/relation/predicate_builder/array_handler.rb +7 -5
  162. data/lib/active_record/relation/predicate_builder/association_query_handler.rb +23 -23
  163. data/lib/active_record/relation/predicate_builder/base_handler.rb +3 -1
  164. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +0 -8
  165. data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +12 -10
  166. data/lib/active_record/relation/predicate_builder/range_handler.rb +0 -8
  167. data/lib/active_record/relation/query_attribute.rb +1 -1
  168. data/lib/active_record/relation/query_methods.rb +247 -295
  169. data/lib/active_record/relation/record_fetch_warning.rb +3 -3
  170. data/lib/active_record/relation/spawn_methods.rb +4 -5
  171. data/lib/active_record/relation/where_clause.rb +79 -65
  172. data/lib/active_record/relation/where_clause_factory.rb +47 -8
  173. data/lib/active_record/result.rb +29 -31
  174. data/lib/active_record/runtime_registry.rb +3 -3
  175. data/lib/active_record/sanitization.rb +182 -197
  176. data/lib/active_record/schema.rb +3 -3
  177. data/lib/active_record/schema_dumper.rb +14 -37
  178. data/lib/active_record/schema_migration.rb +3 -3
  179. data/lib/active_record/scoping.rb +9 -10
  180. data/lib/active_record/scoping/default.rb +87 -91
  181. data/lib/active_record/scoping/named.rb +16 -28
  182. data/lib/active_record/secure_token.rb +2 -2
  183. data/lib/active_record/statement_cache.rb +13 -15
  184. data/lib/active_record/store.rb +31 -32
  185. data/lib/active_record/suppressor.rb +2 -1
  186. data/lib/active_record/table_metadata.rb +9 -5
  187. data/lib/active_record/tasks/database_tasks.rb +72 -65
  188. data/lib/active_record/tasks/mysql_database_tasks.rb +75 -72
  189. data/lib/active_record/tasks/postgresql_database_tasks.rb +53 -48
  190. data/lib/active_record/tasks/sqlite_database_tasks.rb +18 -16
  191. data/lib/active_record/timestamp.rb +39 -25
  192. data/lib/active_record/touch_later.rb +1 -2
  193. data/lib/active_record/transactions.rb +98 -110
  194. data/lib/active_record/type.rb +17 -13
  195. data/lib/active_record/type/adapter_specific_registry.rb +46 -42
  196. data/lib/active_record/type/decimal_without_scale.rb +9 -0
  197. data/lib/active_record/type/hash_lookup_type_map.rb +3 -3
  198. data/lib/active_record/type/serialized.rb +8 -8
  199. data/lib/active_record/type/text.rb +9 -0
  200. data/lib/active_record/type/time.rb +0 -1
  201. data/lib/active_record/type/type_map.rb +11 -15
  202. data/lib/active_record/type/unsigned_integer.rb +15 -0
  203. data/lib/active_record/type_caster.rb +2 -2
  204. data/lib/active_record/type_caster/connection.rb +8 -6
  205. data/lib/active_record/type_caster/map.rb +3 -1
  206. data/lib/active_record/validations.rb +4 -4
  207. data/lib/active_record/validations/associated.rb +1 -1
  208. data/lib/active_record/validations/presence.rb +2 -2
  209. data/lib/active_record/validations/uniqueness.rb +8 -39
  210. data/lib/active_record/version.rb +1 -1
  211. data/lib/rails/generators/active_record.rb +4 -4
  212. data/lib/rails/generators/active_record/migration.rb +2 -2
  213. data/lib/rails/generators/active_record/migration/migration_generator.rb +37 -34
  214. data/lib/rails/generators/active_record/model/model_generator.rb +9 -9
  215. metadata +22 -13
  216. data/lib/active_record/relation/predicate_builder/class_handler.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 235a713e47ff9449c9c0ccceb33b51cfddf8aac53284ca0693c4a57d7578502a
4
- data.tar.gz: 0a106230b5c2b5f05a9e64cdab3a084b1c6c406c2a2adb7f703d59a27ae376a4
2
+ SHA1:
3
+ metadata.gz: bd07c0f82a72c8cbf4c63768b7dbe9616b603c33
4
+ data.tar.gz: 4ad0f6c9b287b3a286f9c6663fd95d73592c33bf
5
5
  SHA512:
6
- metadata.gz: c585c0592c49ebe5ee2d6c1ccf1e0f3cd37f0b41ca26cb49246c1f8e99ee07a508bbc24c519114c5fe3dcd09960ca54d71af8ecbdb7cb13ee371e9054a842080
7
- data.tar.gz: b7b18c7ccb0c602aa135e9420a1f9e7fc60dee5a1b81912c0fb936dcf7a3f3abf4e7ac857c9e061e80d033e245c5b2203078356635f1f2a87a5e8848201347c1
6
+ metadata.gz: 2fa5d70bb93030107254cf60cafa091b242b721517306afb16c4168cee02a989419a75fc84c774ab1ca8aaa01f639daf12d9e4137bcc3edc4fa48a9120fd373b
7
+ data.tar.gz: 912c2dfb632f8d0488c9cf3f06cf0b9f5d2a8dee2a0b26416b60c06016112383bf248a5ad1d2bdda082f3a3365ebd944b80e1484761b1d415814aba11e8b6b39
@@ -1,229 +1,290 @@
1
- ## Rails 5.0.7.2 (March 11, 2019) ##
1
+ ## Rails 5.1.0.beta1 (February 23, 2017) ##
2
2
 
3
- * No changes.
3
+ * Correctly dump native timestamp types for MySQL.
4
4
 
5
+ The native timestamp type in MySQL is different from datetime type.
6
+ Internal representation of the timestamp type is UNIX time, This means
7
+ that timestamp columns are affected by time zone.
5
8
 
6
- ## Rails 5.0.7.1 (November 27, 2018) ##
9
+ > SET time_zone = '+00:00';
10
+ Query OK, 0 rows affected (0.00 sec)
7
11
 
8
- * No changes.
12
+ > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW());
13
+ Query OK, 1 row affected (0.02 sec)
9
14
 
15
+ > SELECT * FROM time_with_zone;
16
+ +---------------------+---------------------+
17
+ | ts | dt |
18
+ +---------------------+---------------------+
19
+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 |
20
+ +---------------------+---------------------+
21
+ 1 row in set (0.00 sec)
10
22
 
11
- ## Rails 5.0.7 (March 29, 2018) ##
23
+ > SET time_zone = '-08:00';
24
+ Query OK, 0 rows affected (0.00 sec)
12
25
 
13
- * Apply time column precision on assignment.
26
+ > SELECT * FROM time_with_zone;
27
+ +---------------------+---------------------+
28
+ | ts | dt |
29
+ +---------------------+---------------------+
30
+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 |
31
+ +---------------------+---------------------+
32
+ 1 row in set (0.00 sec)
14
33
 
15
- PR #20317 changed the behavior of datetime columns so that when they
16
- have a specified precision then on assignment the value is rounded to
17
- that precision. This behavior is now applied to time columns as well.
34
+ *Ryuta Kamizono*
35
+
36
+ * All integer-like PKs are autoincrement unless they have an explicit default.
37
+
38
+ *Matthew Draper*
18
39
 
19
- Fixes #30301.
40
+ * Omit redundant `using: :btree` for schema dumping.
20
41
 
21
- *Andrew White*
42
+ *Ryuta Kamizono*
22
43
 
23
- * Normalize time column values for SQLite database.
44
+ * Deprecate passing `default` to `index_name_exists?`.
24
45
 
25
- For legacy reasons, time columns in SQLite are stored as full datetimes
26
- because until #24542 the quoting for time columns didn't remove the date
27
- component. To ensure that values are consistent we now normalize the
28
- date component to 2001-01-01 on reading and writing.
46
+ *Ryuta Kamizono*
29
47
 
30
- *Andrew White*
48
+ * PostgreSQL: schema dumping support for interval and OID columns.
31
49
 
32
- * Ensure that the date component is removed when quoting times.
50
+ *Ryuta Kamizono*
33
51
 
34
- PR #24542 altered the quoting for time columns so that the date component
35
- was removed however it only removed it when it was 2001-01-01. Now the
36
- date component is removed irrespective of what the date is.
52
+ * Deprecate `supports_primary_key?` on connection adapters since it's
53
+ been long unused and unsupported.
37
54
 
38
- *Andrew White*
55
+ *Ryuta Kamizono*
39
56
 
40
- * Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
41
- without being connected.
57
+ * Make `table_name=` reset current statement cache,
58
+ so queries are not run against the previous table name.
42
59
 
43
- *Tsukasa Oishi*
60
+ *namusyaka*
44
61
 
45
- * Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
46
- ar_internal_metadata's data for a test database.
62
+ * Allow `ActiveRecord::Base#as_json` to be passed a frozen Hash.
47
63
 
48
- Before:
49
- ```
50
- $ RAILS_ENV=test rails dbconsole
51
- > SELECT * FROM ar_internal_metadata;
52
- key|value|created_at|updated_at
53
- environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
54
- ```
64
+ *Isaac Betesh*
55
65
 
56
- After:
57
- ```
58
- $ RAILS_ENV=test rails dbconsole
59
- > SELECT * FROM ar_internal_metadata;
60
- key|value|created_at|updated_at
61
- environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
62
- ```
66
+ * Fix inspection behavior when the :id column is not primary key.
63
67
 
64
- Fixes #26731.
68
+ *namusyaka*
65
69
 
66
- *bogdanvlviv*
70
+ * Deprecate locking records with unpersisted changes.
67
71
 
68
- * Fix longer sequence name detection for serial columns.
72
+ *Marc Schütz*
69
73
 
70
- Fixes #28332.
74
+ * Remove deprecated behavior that halts callbacks when the return is false.
71
75
 
72
- *Ryuta Kamizono*
76
+ *Rafael Mendonça França*
73
77
 
74
- * Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
78
+ * Deprecate `ColumnDumper#migration_keys`.
75
79
 
76
80
  *Ryuta Kamizono*
77
81
 
82
+ * Fix `association_primary_key_type` for reflections with symbol primary key.
83
+
84
+ Fixes #27864.
85
+
86
+ *Daniel Colson*
87
+
88
+ * Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+.
78
89
 
79
- ## Rails 5.0.6 (September 07, 2017) ##
90
+ MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html
91
+ MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
80
92
 
81
- * No changes.
93
+ Declare virtual columns with `t.virtual name, type: …, as: "expression"`.
94
+ Pass `stored: true` to persist the generated value (false by default).
82
95
 
96
+ Example:
83
97
 
84
- ## Rails 5.0.6.rc1 (August 24, 2017) ##
98
+ create_table :generated_columns do |t|
99
+ t.string :name
100
+ t.virtual :upper_name, type: :string, as: "UPPER(name)"
101
+ t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
102
+ t.index :name_length # May be indexed, too!
103
+ end
85
104
 
86
- * Ensure `sum` honors `distinct` on `has_many :through` associations
105
+ *Ryuta Kamizono*
87
106
 
88
- Fixes #16791
107
+ * Deprecate `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
89
108
 
90
- *Aaron Wortham
109
+ *Ryuta Kamizono*
91
110
 
111
+ * Support foreign key creation for SQLite3.
92
112
 
93
- ## Rails 5.0.5 (July 31, 2017) ##
113
+ *Ryuta Kamizono*
94
114
 
95
- * No changes.
115
+ * Place generated migrations into the path set by `config.paths["db/migrate"]`.
96
116
 
117
+ *Kevin Glowacz*
97
118
 
98
- ## Rails 5.0.5.rc2 (July 25, 2017) ##
119
+ * Raise `ActiveRecord::InvalidForeignKey` when a foreign key constraint fails on SQLite3.
99
120
 
100
- * No changes.
121
+ *Ryuta Kamizono*
101
122
 
123
+ * Add the touch option to `#increment!` and `#decrement!`.
102
124
 
103
- ## Rails 5.0.5.rc1 (July 19, 2017) ##
125
+ *Hiroaki Izu*
104
126
 
105
- * `Relation#joins` is no longer affected by the target model's
106
- `current_scope`, with the exception of `unscoped`.
127
+ * Deprecate passing a class to the `class_name` because it eagerloads more classes than
128
+ necessary and potentially creates circular dependencies.
107
129
 
108
- Fixes #29338.
130
+ *Kir Shatrov*
109
131
 
110
- *Sean Griffin*
132
+ * Raise error when has_many through is defined before through association.
111
133
 
134
+ Fixes #26834.
112
135
 
113
- ## Rails 5.0.4 (June 19, 2017) ##
136
+ *Chris Holmes*
114
137
 
115
- * Restore previous behavior of collection proxies: their values can have
116
- methods stubbed, and they respect extension modules applied by a default
117
- scope.
138
+ * Deprecate passing `name` to `indexes`.
118
139
 
119
140
  *Ryuta Kamizono*
120
141
 
121
- * Loading model schema from database is now thread-safe.
142
+ * Remove deprecated tasks: `db:test:clone`, `db:test:clone_schema`, `db:test:clone_structure`.
143
+
144
+ *Rafel Mendonça França*
145
+
146
+ * Compare deserialized values for `PostgreSQL::OID::Hstore` types when
147
+ calling `ActiveRecord::Dirty#changed_in_place?`.
122
148
 
123
- Fixes #28589.
149
+ Fixes #27502.
124
150
 
125
- *Vikrant Chaudhary*, *David Abdemoulaie*
151
+ *Jon Moss*
126
152
 
153
+ * Raise `ArgumentError` when passing an `ActiveRecord::Base` instance to `.find`,
154
+ `.exists?` and `.update`.
127
155
 
128
- ## Rails 5.0.3 (May 12, 2017) ##
156
+ *Rafael Mendonça França*
129
157
 
130
- * Check whether `Rails.application` defined before calling it
158
+ * Respect precision option for arrays of timestamps.
131
159
 
132
- In #27674 we changed the migration generator to generate migrations at the
133
- path defined in `Rails.application.config.paths` however the code checked
134
- for the presence of the `Rails` constant but not the `Rails.application`
135
- method which caused problems when using Active Record and generators outside
136
- of the context of a Rails application.
160
+ Fixes #27514.
137
161
 
138
- Fixes #28325.
162
+ *Sean Griffin*
139
163
 
140
- * Fix `deserialize` with JSON array.
164
+ * Optimize slow model instantiation when using STI and `store_full_sti_class = false` option.
141
165
 
142
- Fixes #28285.
166
+ *Konstantin Lazarev*
143
167
 
144
- *Ryuta Kamizono*
168
+ * Add `touch` option to counter cache modifying methods.
145
169
 
146
- * Fix `rake db:schema:load` with subdirectories.
170
+ Works when updating, resetting, incrementing and decrementing counters:
171
+
172
+ # Touches `updated_at`/`updated_on`.
173
+ Topic.increment_counter(:messages_count, 1, touch: true)
174
+ Topic.decrement_counter(:messages_count, 1, touch: true)
175
+
176
+ # Touches `last_discussed_at`.
177
+ Topic.reset_counters(18, :messages, touch: :last_discussed_at)
178
+
179
+ # Touches `updated_at` and `last_discussed_at`.
180
+ Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
181
+
182
+ Fixes #26724.
183
+
184
+ *Jarred Trost*
185
+
186
+ * Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`.
147
187
 
148
188
  *Ryuta Kamizono*
149
189
 
150
- * Fix `rake db:migrate:status` with subdirectories.
190
+ * Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`.
151
191
 
152
192
  *Ryuta Kamizono*
153
193
 
154
- * Don't share options between reference id and type columns
194
+ * Remove deprecated `#use_transactional_fixtures` configuration.
155
195
 
156
- When using a polymorphic reference column in a migration, sharing options
157
- between the two columns doesn't make sense since they are different types.
158
- The `reference_id` column is usually an integer and the `reference_type`
159
- column a string so options like `unsigned: true` will result in an invalid
160
- table definition.
196
+ *Rafael Mendonça França*
161
197
 
162
- *Ryuta Kamizono*
198
+ * Remove deprecated `#raise_in_transactional_callbacks` configuration.
163
199
 
164
- * Fix regression of #1969 with SELECT aliases in HAVING clause.
200
+ *Rafael Mendonça França*
165
201
 
166
- *Eugene Kenny*
202
+ * Remove deprecated `#load_schema_for`.
167
203
 
204
+ *Rafael Mendonça França*
168
205
 
169
- ## Rails 5.0.2 (March 01, 2017) ##
206
+ * Remove deprecated conditions parameter from `#destroy_all` and `#delete_all`.
170
207
 
171
- * Fix `wait_timeout` to configurable for mysql2 adapter.
208
+ *Rafael Mendonça França*
172
209
 
173
- Fixes #26556.
210
+ * Remove deprecated support to passing arguments to `#select` when a block is provided.
174
211
 
175
- *Ryuta Kamizono*
212
+ *Rafael Mendonça França*
176
213
 
177
- * Make `table_name=` reset current statement cache,
178
- so queries are not run against the previous table name.
214
+ * Remove deprecated support to query using commas on LIMIT.
179
215
 
180
- *namusyaka*
216
+ *Rafael Mendonça França*
181
217
 
182
- * Allow ActiveRecord::Base#as_json to be passed a frozen Hash.
218
+ * Remove deprecated support to passing a class as a value in a query.
183
219
 
184
- *Isaac Betesh*
220
+ *Rafael Mendonça França*
185
221
 
186
- * Fix inspection behavior when the :id column is not primary key.
222
+ * Raise `ActiveRecord::IrreversibleOrderError` when using `last` with an irreversible
223
+ order.
187
224
 
188
- *namusyaka*
225
+ *Rafael Mendonça França*
189
226
 
190
- * Fix `association_primary_key_type` for reflections with symbol primary key
227
+ * Raise when a `has_many :through` association has an ambiguous reflection name.
191
228
 
192
- Fixes #27864
229
+ *Rafael Mendonça França*
193
230
 
194
- *Daniel Colson*
231
+ * Raise when `ActiveRecord::Migration` is inherited from directly.
195
232
 
196
- * Place generated migrations into the path set by `config.paths["db/migrate"]`
233
+ *Rafael Mendonça França*
197
234
 
198
- *Kevin Glowacz*
235
+ * Remove deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize`
236
+ and `ActiveRecord::StatementInvalid#original_exception`.
199
237
 
200
- * Compare deserialized values for `PostgreSQL::OID::Hstore` types when
201
- calling `ActiveRecord::Dirty#changed_in_place?`
238
+ *Rafael Mendonça França*
202
239
 
203
- Fixes #27502.
240
+ * `#tables` and `#table_exists?` return only tables and not views.
204
241
 
205
- *Jon Moss*
242
+ All the deprecations on those methods were removed.
206
243
 
207
- * Respect precision option for arrays of timestamps.
244
+ *Rafael Mendonça França*
208
245
 
209
- Fixes #27514.
246
+ * Remove deprecated `name` argument from `#tables`.
210
247
 
211
- *Sean Griffin*
248
+ *Rafael Mendonça França*
212
249
 
250
+ * Remove deprecated support to passing a column to `#quote`.
213
251
 
214
- ## Rails 5.0.1 (December 21, 2016) ##
252
+ *Rafael Mendonça França*
215
253
 
216
- * No changes.
254
+ * Set `:time` as a timezone aware type and remove deprecation when
255
+ `config.active_record.time_zone_aware_types` is not explicitly set.
217
256
 
257
+ *Rafael Mendonça França*
218
258
 
219
- ## Rails 5.0.1.rc2 (December 10, 2016) ##
259
+ * Remove deprecated force reload argument in singular and collection association readers.
220
260
 
221
- * Correct resolution of associated class in `has_many :through`
222
- associations' `*_ids` setters.
261
+ *Rafael Mendonça França*
223
262
 
224
- Fixes #27297.
263
+ * Remove deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and
264
+ `activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes.
225
265
 
226
- *Matthew Draper*
266
+ *Rafael Mendonça França*
267
+
268
+ * Allow passing extra flags to `db:structure:load` and `db:structure:dump`
269
+
270
+ Introduces `ActiveRecord::Tasks::DatabaseTasks.structure_(load|dump)_flags` to customize the
271
+ eventual commands run against the database, e.g. mysqldump/pg_dump.
272
+
273
+ *Kir Shatrov*
274
+
275
+ * Notifications see frozen SQL string.
276
+
277
+ Fixes #23774.
278
+
279
+ *Richard Monette*
280
+
281
+ * RuntimeErrors are no longer translated to `ActiveRecord::StatementInvalid`.
282
+
283
+ *Richard Monette*
284
+
285
+ * Change the schema cache format to use YAML instead of Marshal.
286
+
287
+ *Kir Shatrov*
227
288
 
228
289
  * Support index length and order options using both string and symbol
229
290
  column names.
@@ -232,10 +293,50 @@
232
293
 
233
294
  *Ryuta Kamizono*
234
295
 
296
+ * Raise `ActiveRecord::RangeError` when values that executed are out of range.
297
+
298
+ *Ryuta Kamizono*
299
+
300
+ * Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted
301
+ or updated because it would violate a not null constraint.
302
+
303
+ *Ryuta Kamizono*
304
+
305
+ * Emulate db trigger behaviour for after_commit :destroy, :update.
235
306
 
236
- ## Rails 5.0.1.rc1 (December 01, 2016) ##
307
+ Race conditions can occur when an ActiveRecord is destroyed
308
+ twice or destroyed and updated. The callbacks should only be
309
+ triggered once, similar to a SQL database trigger.
237
310
 
238
- * Fix that unsigned with zerofill is treated as signed.
311
+ *Stefan Budeanu*
312
+
313
+ * Moved `DecimalWithoutScale`, `Text`, and `UnsignedInteger` from Active Model to Active Record.
314
+
315
+ *Iain Beeston*
316
+
317
+ * Fix `write_attribute` method to check whether an attribute is aliased or not, and
318
+ use the aliased attribute name if needed.
319
+
320
+ *Prathamesh Sonpatki*
321
+
322
+ * Fix `read_attribute` method to check whether an attribute is aliased or not, and
323
+ use the aliased attribute name if needed.
324
+
325
+ Fixes #26417.
326
+
327
+ *Prathamesh Sonpatki*
328
+
329
+ * PostgreSQL & MySQL: Use big integer as primary key type for new tables.
330
+
331
+ *Jon McCartie*, *Pavel Pravosud*
332
+
333
+ * Change the type argument of `ActiveRecord::Base#attribute` to be optional.
334
+ The default is now `ActiveRecord::Type::Value.new`, which provides no type
335
+ casting behavior.
336
+
337
+ *Sean Griffin*
338
+
339
+ * Don't treat unsigned integers with zerofill as signed.
239
340
 
240
341
  Fixes #27125.
241
342
 
@@ -245,7 +346,7 @@
245
346
 
246
347
  *Sergey Alekseev*
247
348
 
248
- * Raise ActiveRecord::RecordNotFound from collection `*_ids` setters
349
+ * Raise `ActiveRecord::RecordNotFound` from collection `*_ids` setters
249
350
  for unknown IDs with a better error message.
250
351
 
251
352
  Changes the collection `*_ids` setters to cast provided IDs the data
@@ -254,6 +355,11 @@
254
355
 
255
356
  *Dominic Cleal*
256
357
 
358
+ * For PostgreSQL >= 9.4 use `pgcrypto`'s `gen_random_uuid()` instead of
359
+ `uuid-ossp`'s UUID generation function.
360
+
361
+ *Yuji Yaginuma*, *Yaw Boakye*
362
+
257
363
  * Introduce `Model#reload_<association>` to bring back the behavior
258
364
  of `Article.category(true)` where `category` is a singular
259
365
  association.
@@ -280,22 +386,66 @@
280
386
 
281
387
  *Jon Moss*
282
388
 
283
- * Configure query caching (per thread) on the connection pool.
389
+ * Added `stat` method to `ActiveRecord::ConnectionAdapters::ConnectionPool`.
390
+
391
+ Example:
392
+
393
+ ActiveRecord::Base.connection_pool.stat # =>
394
+ { size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
395
+
396
+ *Pavel Evstigneev*
397
+
398
+ * Avoid `unscope(:order)` when `limit_value` is presented for `count`
399
+ and `exists?`.
400
+
401
+ If `limit_value` is presented, records fetching order is very important
402
+ for performance. We should not unscope the order in the case.
403
+
404
+ *Ryuta Kamizono*
405
+
406
+ * Fix an Active Record `DateTime` field `NoMethodError` caused by incomplete
407
+ datetime.
408
+
409
+ Fixes #24195.
410
+
411
+ *Sen Zhang*
412
+
413
+ * Allow `slice` to take an array of methods(without the need for splatting).
414
+
415
+ *Cohen Carlisle*
416
+
417
+ * Improved partial writes with HABTM and has many through associations
418
+ to fire database query only if relation has been changed.
419
+
420
+ Fixes #19663.
284
421
 
285
- Moving the configuration to the pool means we don't allocate a connection
286
- until it's actually needed.
422
+ *Mehmet Emin İNAÇ*
423
+
424
+ * Deprecate passing arguments and block at the same time to
425
+ `ActiveRecord::QueryMethods#select`.
426
+
427
+ *Prathamesh Sonpatki*
428
+
429
+ * Optimistic locking: Added ability to update `locking_column` value.
430
+ Ignore optimistic locking if trying to update with new `locking_column` value.
431
+
432
+ *bogdanvlviv*
433
+
434
+ * Fixed: Optimistic locking does not work well with `null` in the database.
287
435
 
288
- Applications that manually interact with the connection pool and/or query
289
- cache may notice that the connection's cache is now cleared and disabled
290
- when it gets returned to the pool, even if the request is not yet completed.
436
+ Fixes #26024.
291
437
 
292
- *Samuel Cochran*, *Matthew Draper*
438
+ *bogdanvlviv*
293
439
 
294
440
  * Fixed support for case insensitive comparisons of `text` columns in
295
441
  PostgreSQL.
296
442
 
297
443
  *Edho Arief*
298
444
 
445
+ * Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`.
446
+
447
+ *Trung Duc Tran*
448
+
299
449
  * Return `true` from `update_attribute` when the value of the attribute
300
450
  to be updated is unchanged.
301
451
 
@@ -303,10 +453,6 @@
303
453
 
304
454
  *Prathamesh Sonpatki*
305
455
 
306
- * Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`
307
-
308
- *Trung Duc Tran*
309
-
310
456
  * Always store errors details information with symbols.
311
457
 
312
458
  When the association is autosaved we were storing the details with
@@ -322,16 +468,18 @@
322
468
 
323
469
  *Rafael Mendonça França*, *Marcus Vieira*
324
470
 
471
+ * Calling `touch` on a model using optimistic locking will now leave the model
472
+ in a non-dirty state with no attribute changes.
473
+
474
+ Fixes #26496.
475
+
476
+ *Jakob Skjerning*
477
+
325
478
  * Using a mysql2 connection after it fails to reconnect will now have an error message
326
479
  saying the connection is closed rather than an undefined method error message.
327
480
 
328
481
  *Dylan Thacker-Smith*
329
482
 
330
- * Remove unnecessarily association load when a `belongs_to` association has already been
331
- loaded then the foreign key is changed directly and the record saved.
332
-
333
- *James Coleman*
334
-
335
483
  * PostgreSQL array columns will now respect the encoding of strings contained
336
484
  in the array.
337
485
 
@@ -346,6 +494,15 @@
346
494
 
347
495
  *Sean Griffin*
348
496
 
497
+ * Remove unnecessarily association load when a `belongs_to` association has already been
498
+ loaded then the foreign key is changed directly and the record saved.
499
+
500
+ *James Coleman*
501
+
502
+ * Remove standardized column types/arguments spaces in schema dump.
503
+
504
+ *Tim Petricola*
505
+
349
506
  * Avoid loading records from database when they are already loaded using
350
507
  the `pluck` method on a collection.
351
508
 
@@ -353,20 +510,49 @@
353
510
 
354
511
  *Ryuta Kamizono*
355
512
 
356
- * Sqlite3 migrations to add a column to an existing table can now be
513
+ * Remove text default treated as an empty string in non-strict mode for
514
+ consistency with other types.
515
+
516
+ Strict mode controls how MySQL handles invalid or missing values in
517
+ data-change statements such as INSERT or UPDATE. If strict mode is not
518
+ in effect, MySQL inserts adjusted values for invalid or missing values
519
+ and produces warnings.
520
+
521
+ def test_mysql_not_null_defaults_non_strict
522
+ using_strict(false) do
523
+ with_mysql_not_null_table do |klass|
524
+ record = klass.new
525
+ assert_nil record.non_null_integer
526
+ assert_nil record.non_null_string
527
+ assert_nil record.non_null_text
528
+ assert_nil record.non_null_blob
529
+
530
+ record.save!
531
+ record.reload
532
+
533
+ assert_equal 0, record.non_null_integer
534
+ assert_equal "", record.non_null_string
535
+ assert_equal "", record.non_null_text
536
+ assert_equal "", record.non_null_blob
537
+ end
538
+ end
539
+ end
540
+
541
+ https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
542
+
543
+ *Ryuta Kamizono*
544
+
545
+ * SQLite3 migrations to add a column to an existing table can now be
357
546
  successfully rolled back when the column was given and invalid column
358
547
  type.
359
548
 
360
- Fixes #26087
549
+ Fixes #26087.
361
550
 
362
551
  *Travis O'Neill*
363
552
 
364
- * Hashes can once again be passed to setters of `composed_of`, if all of the
365
- mapping methods are methods implemented on `Hash`.
366
-
367
- Fixes #25978.
553
+ * Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.
368
554
 
369
- *Sean Griffin*
555
+ *Ryuta Kamizono*
370
556
 
371
557
  * Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
372
558
  force a DISTINCT. This solves issues when using count after a left_joins.
@@ -378,15 +564,26 @@
378
564
 
379
565
  *Michel Pigassou*
380
566
 
567
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
568
+ mapping methods are methods implemented on `Hash`.
569
+
570
+ Fixes #25978.
571
+
572
+ *Sean Griffin*
573
+
381
574
  * Fix the SELECT statement in `#table_comment` for MySQL.
382
575
 
383
576
  *Takeshi Akima*
384
577
 
385
578
  * Virtual attributes will no longer raise when read on models loaded from the
386
- database
579
+ database.
387
580
 
388
581
  *Sean Griffin*
389
582
 
583
+ * Support calling the method `merge` in `scope`'s lambda.
584
+
585
+ *Yasuhiro Sugino*
586
+
390
587
  * Fixes multi-parameter attributes conversion with invalid params.
391
588
 
392
589
  *Hiroyuki Ishii*
@@ -394,10 +591,27 @@
394
591
  * Add newline between each migration in `structure.sql`.
395
592
 
396
593
  Keeps schema migration inserts as a single commit, but allows for easier
397
- git diff-ing. Fixes #25504.
594
+ git diffing.
595
+
596
+ Fixes #25504.
398
597
 
399
598
  *Grey Baker*, *Norberto Lopes*
400
599
 
600
+ * The flag `error_on_ignored_order_or_limit` has been deprecated in favor of
601
+ the current `error_on_ignored_order`.
602
+
603
+ *Xavier Noria*
604
+
605
+ * Batch processing methods support `limit`:
606
+
607
+ Post.limit(10_000).find_each do |post|
608
+ # ...
609
+ end
610
+
611
+ It also works in `find_in_batches` and `in_batches`.
612
+
613
+ *Xavier Noria*
614
+
401
615
  * Using `group` with an attribute that has a custom type will properly cast
402
616
  the hash keys after calling a calculation method like `count`.
403
617
 
@@ -405,6 +619,17 @@
405
619
 
406
620
  *Sean Griffin*
407
621
 
622
+ * Fix the generated `#to_param` method to use `omission: ''` so that
623
+ the resulting output is actually up to 20 characters, not
624
+ effectively 17 to leave room for the default "...".
625
+ Also call `#parameterize` before `#truncate` and make the
626
+ `separator: /-/` to maximize the information included in the
627
+ output.
628
+
629
+ Fixes #23635.
630
+
631
+ *Rob Biedenharn*
632
+
408
633
  * Ensure concurrent invocations of the connection reaper cannot allocate the
409
634
  same connection to two threads.
410
635
 
@@ -412,22 +637,17 @@
412
637
 
413
638
  *Matthew Draper*
414
639
 
415
- * Fixed dumping of foreign key's referential actions when MySQL connection
416
- uses `sql_mode = ANSI_QUOTES`.
417
-
418
- Fixes #25300.
419
-
420
- *Ryuta Kamizono*
421
-
422
-
423
- ## Rails 5.0.0 (June 30, 2016) ##
424
-
425
640
  * Inspecting an object with an associated array of over 10 elements no longer
426
641
  truncates the array, preventing `inspect` from looping infinitely in some
427
642
  cases.
428
643
 
429
644
  *Kevin McPhillips*
430
645
 
646
+ * Removed the unused methods `ActiveRecord::Base.connection_id` and
647
+ `ActiveRecord::Base.connection_id=`.
648
+
649
+ *Sean Griffin*
650
+
431
651
  * Ensure hashes can be assigned to attributes created using `composed_of`.
432
652
 
433
653
  Fixes #25210.
@@ -444,2106 +664,23 @@
444
664
 
445
665
  *Johannes Opper*
446
666
 
447
- * PostgreSQL: Support Expression Indexes and Operator Classes.
448
-
449
- Example:
450
-
451
- create_table :users do |t|
452
- t.string :name
453
- t.index 'lower(name) varchar_pattern_ops'
454
- end
455
-
456
- Fixes #19090, #21765, #21819, #24359.
457
-
458
- *Ryuta Kamizono*
459
-
460
- * MySQL: Prepared statements support.
461
-
462
- To enable, set `prepared_statements: true` in config/database.yml.
463
- Requires mysql2 0.4.4+.
464
-
465
- *Ryuta Kamizono*
466
-
467
- * Schema dumper: Indexes are now included in the `create_table` block
468
- instead of listed afterward as separate `add_index` lines.
469
-
470
- This tidies up schema.rb and makes it easy to read as a list of tables.
471
-
472
- Bonus: Allows databases that support it (MySQL) to perform as single
473
- `CREATE TABLE` query, no additional query per index.
474
-
475
- *Ryuta Kamizono*
476
-
477
- * SQLite: Fix uniqueness validation when values exceed the column limit.
478
-
479
- SQLite doesn't impose length restrictions on strings, BLOBs, or numeric
480
- values. It treats them as helpful metadata. When we truncate strings
481
- before checking uniqueness, we'd miss values that exceed the column limit.
482
-
483
- Other databases enforce length limits. A large value will pass uniqueness
484
- validation since the column limit guarantees no value that long exists.
485
- When we insert the row, it'll raise `ActiveRecord::ValueTooLong` as we
486
- expect.
667
+ * Introduce `ActiveRecord::TransactionSerializationError` for catching
668
+ transaction serialization failures or deadlocks.
487
669
 
488
- This fixes edge-case incorrect validation failures for values that exceed
489
- the column limit but are identical to an existing value *when truncated*.
490
- Now these will pass validation and raise an exception.
670
+ *Erol Fornoles*
491
671
 
492
- *Ryuta Kamizono*
493
-
494
- * Raise `ActiveRecord::ValueTooLong` when column limits are exceeded.
495
- Supported by MySQL and PostgreSQL adapters.
496
-
497
- *Ryuta Kamizono*
498
-
499
- * Migrations: `#foreign_key` respects `table_name_prefix` and `_suffix`.
500
-
501
- *Ryuta Kamizono*
502
-
503
- * SQLite: Force NOT NULL primary keys.
672
+ * PostgreSQL: Fix `db:structure:load` silent failure on SQL error.
504
673
 
505
- From SQLite docs: https://www.sqlite.org/lang_createtable.html
506
- According to the SQL standard, PRIMARY KEY should always imply NOT
507
- NULL. Unfortunately, due to a bug in some early versions, this is not
508
- the case in SQLite. Unless the column is an INTEGER PRIMARY KEY or the
509
- table is a WITHOUT ROWID table or the column is declared NOT NULL,
510
- SQLite allows NULL values in a PRIMARY KEY column. SQLite could be
511
- fixed to conform to the standard, but doing so might break legacy
512
- applications. Hence, it has been decided to merely document the fact
513
- that SQLite allowing NULLs in most PRIMARY KEY columns.
514
-
515
- Now we override column options to explicitly set NOT NULL rather than rely
516
- on implicit NOT NULL like MySQL and PostgreSQL adapters.
517
-
518
- *Ryuta Kamizono*
519
-
520
- * Added notice when a database is successfully created or dropped.
674
+ The command line flag `-v ON_ERROR_STOP=1` should be used
675
+ when invoking `psql` to make sure errors are not suppressed.
521
676
 
522
677
  Example:
523
678
 
524
- $ bin/rails db:create
525
- Created database 'blog_development'
526
- Created database 'blog_test'
527
-
528
- $ bin/rails db:drop
529
- Dropped database 'blog_development'
530
- Dropped database 'blog_test'
531
-
532
- Changed older notices
533
- `blog_development already exists` to `Database 'blog_development' already exists`.
534
- and
535
- `Couldn't drop blog_development` to `Couldn't drop database 'blog_development'`.
536
-
537
- *bogdanvlviv*
538
-
539
- * Database comments. Annotate database objects (tables, columns, indexes)
540
- with comments stored in database metadata. PostgreSQL & MySQL support.
541
-
542
- create_table :pages, force: :cascade, comment: 'CMS content pages' do |t|
543
- t.string :path, comment: 'Path fragment of page URL used for routing'
544
- t.string :locale, comment: 'RFC 3066 locale code of website language section'
545
- t.index [:path, :locale], comment: 'Look up pages by URI'
546
- end
547
-
548
- *Andrey Novikov*
549
-
550
- * Add `quoted_time` for truncating the date part of a TIME column value.
551
- This fixes queries on TIME column on MariaDB, as it doesn't ignore the
552
- date part of the string when it coerces to time.
553
-
554
- *Ryuta Kamizono*
555
-
556
- * Properly accept all valid JSON primitives in the JSON data type.
557
-
558
- Fixes #24234
559
-
560
- *Sean Griffin*
561
-
562
- * MariaDB 5.3+ supports microsecond datetime precision.
563
-
564
- *Jeremy Daer*
565
-
566
- * Delegate `none?` and `one?`. Now they can be invoked as model class methods.
567
-
568
- Example:
679
+ psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db
569
680
 
570
- # When no record is found on the table
571
- Topic.none? # => true
681
+ Fixes #23818.
572
682
 
573
- # When only one record is found on the table
574
- Topic.one? # => true
683
+ *Ralin Chimev*
575
684
 
576
- *Kenta Shirai*
577
-
578
- * The form builder now properly displays values when passing a proc form
579
- default to the attributes API.
580
-
581
- Fixes #24249.
582
-
583
- *Sean Griffin*
584
-
585
- * The schema cache is now cleared after the `db:migrate` task is run.
586
-
587
- Closes #24273.
588
-
589
- *Chris Arcand*
590
-
591
- * MySQL: strict mode respects other SQL modes rather than overwriting them.
592
- Setting `strict: true` adds `STRICT_ALL_TABLES` to `sql_mode`. Setting
593
- `strict: false` removes `STRICT_TRANS_TABLES`, `STRICT_ALL_TABLES`, and
594
- `TRADITIONAL` from `sql_mode`.
595
-
596
- *Ryuta Kamizono*
597
-
598
- * Execute default_scope defined by abstract class in the context of subclass.
599
-
600
- Fixes #23413.
601
- Fixes #10658.
602
-
603
- *Mehmet Emin İNAÇ*
604
-
605
- * Fix an issue when preloading associations with extensions.
606
- Previously every association with extension methods was transformed into an
607
- instance dependent scope. This is no longer the case.
608
-
609
- Fixes #23934.
610
-
611
- *Yves Senn*
612
-
613
- * Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`.
614
- Use the `{insert|update|delete}` public methods instead.
615
-
616
- *Ryuta Kamizono*
617
-
618
- * Added a configuration option to have active record raise an ArgumentError
619
- if the order or limit is ignored in a batch query, rather than logging a
620
- warning message.
621
-
622
- *Scott Ringwelski*
623
-
624
- * Honour the order of the joining model in a `has_many :through` association when eager loading.
625
-
626
- Example:
627
-
628
- The below will now follow the order of `by_lines` when eager loading `authors`.
629
-
630
- class Article < ActiveRecord::Base
631
- has_many :by_lines, -> { order(:position) }
632
- has_many :authors, through: :by_lines
633
- end
634
-
635
- Fixes #17864.
636
-
637
- *Yasyf Mohamedali*, *Joel Turkel*
638
-
639
- * Ensure that the Suppressor runs before validations.
640
-
641
- This moves the suppressor up to be run before validations rather than after
642
- validations. There's no reason to validate a record you aren't planning on saving.
643
-
644
- *Eileen M. Uchitelle*
645
-
646
- * Save many-to-many objects based on association primary key.
647
-
648
- Fixes #20995.
649
-
650
- *himesh-r*
651
-
652
- * Ensure that mutations of the array returned from `ActiveRecord::Relation#to_a`
653
- do not affect the original relation, by returning a duplicate array each time.
654
-
655
- This brings the behavior in line with `CollectionProxy#to_a`, which was
656
- already more careful.
657
-
658
- *Matthew Draper*
659
-
660
- * Fixed `where` for polymorphic associations when passed an array containing different types.
661
-
662
- Fixes #17011.
663
-
664
- Example:
665
-
666
- PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
667
- # => SELECT "price_estimates".* FROM "price_estimates"
668
- WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
669
- OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
670
-
671
- *Philippe Huibonhoa*
672
-
673
- * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
674
- the same table definition would only create one foreign key.
675
-
676
- *George Millo*
677
-
678
- * Fix a regression on has many association, where calling a child from parent in child's callback
679
- results in same child records getting added repeatedly to target.
680
-
681
- Fixes #13387.
682
-
683
- *Bogdan Gusiev*, *Jon Hinson*
684
-
685
- * Rework `ActiveRecord::Relation#last`.
686
-
687
- 1. Never perform additional SQL on loaded relation
688
- 2. Use SQL reverse order instead of loading relation if relation doesn't have limit
689
- 3. Deprecated relation loading when SQL order can not be automatically reversed
690
-
691
- Topic.order("title").load.last(3)
692
- # before: SELECT ...
693
- # after: No SQL
694
-
695
- Topic.order("title").last
696
- # before: SELECT * FROM `topics`
697
- # after: SELECT * FROM `topics` ORDER BY `topics`.`title` DESC LIMIT 1
698
-
699
- Topic.order("coalesce(author, title)").last
700
- # before: SELECT * FROM `topics`
701
- # after: Deprecation Warning for irreversible order
702
-
703
- *Bogdan Gusiev*
704
-
705
- * Allow `joins` to be unscoped.
706
-
707
- Fixes #13775.
708
-
709
- *Takashi Kokubun*
710
-
711
- * Add `#second_to_last` and `#third_to_last` finder methods.
712
-
713
- *Brian Christian*
714
-
715
- * Added `numeric` helper into migrations.
716
-
717
- Example:
718
-
719
- create_table(:numeric_types) do |t|
720
- t.numeric :numeric_type, precision: 10, scale: 2
721
- end
722
-
723
- *Mehmet Emin İNAÇ*
724
-
725
- * Bumped the minimum supported version of PostgreSQL to >= 9.1.
726
- Both PG 9.0 and 8.4 are past their end of life date:
727
- http://www.postgresql.org/support/versioning/
728
-
729
- *Remo Mueller*
730
-
731
- * `ActiveRecord::Relation#reverse_order` throws `ActiveRecord::IrreversibleOrderError`
732
- when the order can not be reversed using current trivial algorithm.
733
- Also raises the same error when `#reverse_order` is called on
734
- relation without any order and table has no primary key:
735
-
736
- Topic.order("concat(author_name, title)").reverse_order
737
- # Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC
738
- # After: raises ActiveRecord::IrreversibleOrderError
739
- Edge.all.reverse_order
740
- # Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC
741
- # After: raises ActiveRecord::IrreversibleOrderError
742
-
743
- *Bogdan Gusiev*
744
-
745
- * Improve schema_migrations insertion performance by inserting all versions
746
- in one INSERT SQL.
747
-
748
- *Akira Matsuda*, *Naoto Koshikawa*
749
-
750
- * Using `references` or `belongs_to` in migrations will always add index
751
- for the referenced column by default, without adding `index: true` option
752
- to generated migration file. Users can opt out of this by passing
753
- `index: false`.
754
-
755
- Fixes #18146.
756
-
757
- *Matthew Draper*, *Prathamesh Sonpatki*
758
-
759
- * Run `type` attributes through attributes API type-casting before
760
- instantiating the corresponding subclass. This makes it possible to define
761
- custom STI mappings.
762
-
763
- Fixes #21986.
764
-
765
- *Yves Senn*
766
-
767
- * Don't try to quote functions or expressions passed to `:default` option if
768
- they are passed as procs.
769
-
770
- This will generate proper query with the passed function or expression for
771
- the default option, instead of trying to quote it in incorrect fashion.
772
-
773
- Example:
774
-
775
- create_table :posts do |t|
776
- t.datetime :published_at, default: -> { 'NOW()' }
777
- end
778
-
779
- *Ryuta Kamizono*
780
-
781
- * Fix regression when loading fixture files with symbol keys.
782
-
783
- Fixes #22584.
784
-
785
- *Yves Senn*
786
-
787
- * Use `version` column as primary key for schema_migrations table because
788
- `schema_migrations` versions are guaranteed to be unique.
789
-
790
- This makes it possible to use `update_attributes` on models that do
791
- not have a primary key.
792
-
793
- *Richard Schneeman*
794
-
795
- * Add short-hand methods for text and blob types in MySQL.
796
-
797
- In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
798
- But in MySQL, these have limited length for each types (ref #21591, #21619).
799
- This change adds short-hand methods for each text and blob types.
800
-
801
- Example:
802
-
803
- create_table :foos do |t|
804
- t.tinyblob :tiny_blob
805
- t.mediumblob :medium_blob
806
- t.longblob :long_blob
807
- t.tinytext :tiny_text
808
- t.mediumtext :medium_text
809
- t.longtext :long_text
810
- end
811
-
812
- *Ryuta Kamizono*
813
-
814
- * Take into account UTC offset when assigning string representation of
815
- timestamp with offset specified to attribute of time type.
816
-
817
- *Andrey Novikov*
818
-
819
- * When calling `first` with a `limit` argument, return directly from the
820
- `loaded?` records if available.
821
-
822
- *Ben Woosley*
823
-
824
- * Deprecate sending the `offset` argument to `find_nth`. Please use the
825
- `offset` method on relation instead.
826
-
827
- *Ben Woosley*
828
-
829
- * Limit record touching to once per transaction.
830
-
831
- If you have a parent/grand-parent relation like:
832
-
833
- Comment belongs_to :message, touch: true
834
- Message belongs_to :project, touch: true
835
- Project belongs_to :account, touch: true
836
-
837
- When the lowest entry(`Comment`) is saved, now, it won't repeat the touch
838
- call multiple times for the parent records.
839
-
840
- Related #18606.
841
-
842
- *arthurnn*
843
-
844
- * Order the result of `find(ids)` to match the passed array, if the relation
845
- has no explicit order defined.
846
-
847
- Fixes #20338.
848
-
849
- *Miguel Grazziotin*, *Matthew Draper*
850
-
851
- * Omit default limit values in dumped schema. It's tidier, and if the defaults
852
- change in the future, we can address that via Migration API Versioning.
853
-
854
- *Jean Boussier*
855
-
856
- * Support passing the schema name as a prefix to table name in
857
- `ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
858
- be considered a full part of the index name, and only the schema in the
859
- current search path would be considered.
860
-
861
- *Grey Baker*
862
-
863
- * Ignore index name in `index_exists?` and `remove_index` when not passed a
864
- name to check for.
865
-
866
- *Grey Baker*
867
-
868
- * Extract support for the legacy `mysql` database adapter from core. It will
869
- live on in a separate gem for now, but most users should just use `mysql2`.
870
-
871
- *Abdelkader Boudih*
872
-
873
- * ApplicationRecord is a new superclass for all app models, analogous to app
874
- controllers subclassing ApplicationController instead of
875
- ActionController::Base. This gives apps a single spot to configure app-wide
876
- model behavior.
877
-
878
- Newly generated applications have `app/models/application_record.rb`
879
- present by default.
880
-
881
- *Genadi Samokovarov*
882
-
883
- * Version the API presented to migration classes, so we can change parameter
884
- defaults without breaking existing migrations, or forcing them to be
885
- rewritten through a deprecation cycle.
886
-
887
- New migrations specify the Rails version they were written for:
888
-
889
- class AddStatusToOrders < ActiveRecord::Migration[5.0]
890
- def change
891
- # ...
892
- end
893
- end
894
-
895
- *Matthew Draper*, *Ravil Bayramgalin*
896
-
897
- * Use bind params for `limit` and `offset`. This will generate significantly
898
- fewer prepared statements for common tasks like pagination. To support this
899
- change, passing a string containing a comma to `limit` has been deprecated,
900
- and passing an Arel node to `limit` is no longer supported.
901
-
902
- Fixes #22250.
903
-
904
- *Sean Griffin*
905
-
906
- * Introduce after_{create,update,delete}_commit callbacks.
907
-
908
- Before:
909
-
910
- after_commit :add_to_index_later, on: :create
911
- after_commit :update_in_index_later, on: :update
912
- after_commit :remove_from_index_later, on: :destroy
913
-
914
- After:
915
-
916
- after_create_commit :add_to_index_later
917
- after_update_commit :update_in_index_later
918
- after_destroy_commit :remove_from_index_later
919
-
920
- Fixes #22515.
921
-
922
- *Genadi Samokovarov*
923
-
924
- * Respect the column default values for `inheritance_column` when
925
- instantiating records through the base class.
926
-
927
- Fixes #17121.
928
-
929
- Example:
930
-
931
- # The schema of BaseModel has `t.string :type, default: 'SubType'`
932
- subtype = BaseModel.new
933
- assert_equals SubType, subtype.class
934
-
935
- *Kuldeep Aggarwal*
936
-
937
- * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
938
-
939
- Fixes #22346.
940
-
941
- *Nick Muerdter*, *ckoenig*
942
-
943
- * Add schema dumping support for PostgreSQL geometric data types.
944
-
945
- *Ryuta Kamizono*
946
-
947
- * Except keys of `build_record`'s argument from `create_scope` in `initialize_attributes`.
948
-
949
- Fixes #21893.
950
-
951
- *Yuichiro Kaneko*
952
-
953
- * Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
954
- Also deprecate passing arguments to `#tables`.
955
- And deprecate `table_exists?`.
956
-
957
- The `#tables` method of some adapters (mysql, mysql2, sqlite3) would return
958
- both tables and views while others (postgresql) just return tables. To make
959
- their behavior consistent, `#tables` will return only tables in the future.
960
-
961
- The `#table_exists?` method would check both tables and views. To make
962
- their behavior consistent with `#tables`, `#table_exists?` will check only
963
- tables in the future.
964
-
965
- *Yuichiro Kaneko*
966
-
967
- * Improve support for non Active Record objects on `validates_associated`
968
-
969
- Skipping `marked_for_destruction?` when the associated object does not responds
970
- to it make easier to validate virtual associations built on top of Active Model
971
- objects and/or serialized objects that implement a `valid?` instance method.
972
-
973
- *Kassio Borges*, *Lucas Mazza*
974
-
975
- * Change connection management middleware to return a new response with
976
- a body proxy, rather than mutating the original.
977
-
978
- *Kevin Buchanan*
979
-
980
- * Make `db:migrate:status` to render `1_some.rb` format migrate files.
981
-
982
- These files are in `db/migrate`:
983
-
984
- * 1_valid_people_have_last_names.rb
985
- * 20150819202140_irreversible_migration.rb
986
- * 20150823202140_add_admin_flag_to_users.rb
987
- * 20150823202141_migration_tests.rb
988
- * 2_we_need_reminders.rb
989
- * 3_innocent_jointable.rb
990
-
991
- Before:
992
-
993
- $ bundle exec rake db:migrate:status
994
- ...
995
-
996
- Status Migration ID Migration Name
997
- --------------------------------------------------
998
- up 001 ********** NO FILE **********
999
- up 002 ********** NO FILE **********
1000
- up 003 ********** NO FILE **********
1001
- up 20150819202140 Irreversible migration
1002
- up 20150823202140 Add admin flag to users
1003
- up 20150823202141 Migration tests
1004
-
1005
- After:
1006
-
1007
- $ bundle exec rake db:migrate:status
1008
- ...
1009
-
1010
- Status Migration ID Migration Name
1011
- --------------------------------------------------
1012
- up 001 Valid people have last names
1013
- up 002 We need reminders
1014
- up 003 Innocent jointable
1015
- up 20150819202140 Irreversible migration
1016
- up 20150823202140 Add admin flag to users
1017
- up 20150823202141 Migration tests
1018
-
1019
- *Yuichiro Kaneko*
1020
-
1021
- * Define `ActiveRecord::Sanitization.sanitize_sql_for_order` and use it inside
1022
- `preprocess_order_args`.
1023
-
1024
- *Yuichiro Kaneko*
1025
-
1026
- * Allow bigint with default nil for avoiding auto increment primary key.
1027
-
1028
- *Ryuta Kamizono*
1029
-
1030
- * Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`.
1031
-
1032
- We should omit the collation entirely rather than providing a default.
1033
- Then the choice is the responsibility of the server and MySQL distribution.
1034
-
1035
- *Ryuta Kamizono*
1036
-
1037
- * Alias `ActiveRecord::Relation#left_joins` to
1038
- `ActiveRecord::Relation#left_outer_joins`.
1039
-
1040
- *Takashi Kokubun*
1041
-
1042
- * Use advisory locking to raise a `ConcurrentMigrationError` instead of
1043
- attempting to migrate when another migration is currently running.
1044
-
1045
- *Sam Davies*
1046
-
1047
- * Added `ActiveRecord::Relation#left_outer_joins`.
1048
-
1049
- Example:
1050
-
1051
- User.left_outer_joins(:posts)
1052
- # => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON
1053
- "posts"."user_id" = "users"."id"
1054
-
1055
- *Florian Thomas*
1056
-
1057
- * Support passing an array to `order` for SQL parameter sanitization.
1058
-
1059
- *Aaron Suggs*
1060
-
1061
- * Avoid disabling errors on the PostgreSQL connection when enabling the
1062
- `standard_conforming_strings` setting. Errors were previously disabled because
1063
- the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
1064
- versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
1065
- setting exists. Disabling errors caused problems when using a connection
1066
- pooling tool like PgBouncer because it's not guaranteed to have the same
1067
- connection between calls to `execute` and it could leave the connection
1068
- with errors disabled.
1069
-
1070
- Fixes #22101.
1071
-
1072
- *Harry Marr*
1073
-
1074
- * Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
1075
-
1076
- Fixes #21886.
1077
-
1078
- *Hiroaki Izu*
1079
-
1080
- * Add support for bidirectional destroy dependencies.
1081
-
1082
- Fixes #13609.
1083
-
1084
- Example:
1085
-
1086
- class Content < ActiveRecord::Base
1087
- has_one :position, dependent: :destroy
1088
- end
1089
-
1090
- class Position < ActiveRecord::Base
1091
- belongs_to :content, dependent: :destroy
1092
- end
1093
-
1094
- *Seb Jacobs*
1095
-
1096
- * Includes HABTM returns correct size now. It's caused by the join dependency
1097
- only instantiates one HABTM object because the join table hasn't a primary key.
1098
-
1099
- Fixes #16032.
1100
-
1101
- Examples:
1102
-
1103
- before:
1104
-
1105
- Project.first.salaried_developers.size # => 3
1106
- Project.includes(:salaried_developers).first.salaried_developers.size # => 1
1107
-
1108
- after:
1109
-
1110
- Project.first.salaried_developers.size # => 3
1111
- Project.includes(:salaried_developers).first.salaried_developers.size # => 3
1112
-
1113
- *Bigxiang*
1114
-
1115
- * Add option to index errors in nested attributes.
1116
-
1117
- For models which have nested attributes, errors within those models will
1118
- now be indexed if `:index_errors` option is set to true when defining a
1119
- `has_many` relationship or by setting the configuration option
1120
- `config.active_record.index_nested_attribute_errors` to true.
1121
-
1122
- Example:
1123
-
1124
- class Guitar < ActiveRecord::Base
1125
- has_many :tuning_pegs, index_errors: true
1126
- accepts_nested_attributes_for :tuning_pegs
1127
- end
1128
-
1129
- class TuningPeg < ActiveRecord::Base
1130
- belongs_to :guitar
1131
- validates_numericality_of :pitch
1132
- end
1133
-
1134
- # Before
1135
- guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
1136
-
1137
- # After
1138
- guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]
1139
-
1140
- *Michael Probber*, *Terence Sun*
1141
-
1142
- * Exit with non-zero status for failed database rake tasks.
1143
-
1144
- *Jay Hayes*
1145
-
1146
- * Queries such as `Computer.joins(:monitor).group(:status).count` will now be
1147
- interpreted as `Computer.joins(:monitor).group('computers.status').count`
1148
- so that when `Computer` and `Monitor` have both `status` columns we don't
1149
- have conflicts in projection.
1150
-
1151
- *Rafael Sales*
1152
-
1153
- * Add ability to default to `uuid` as primary key when generating database migrations.
1154
-
1155
- Example:
1156
-
1157
- config.generators do |g|
1158
- g.orm :active_record, primary_key_type: :uuid
1159
- end
1160
-
1161
- *Jon McCartie*
1162
-
1163
- * Don't cache arguments in `#find_by` if they are an `ActiveRecord::Relation`.
1164
-
1165
- Fixes #20817.
1166
-
1167
- *Hiroaki Izu*
1168
-
1169
- * Qualify column name inserted by `group` in calculation.
1170
-
1171
- Giving `group` an unqualified column name now works, even if the relation
1172
- has `JOIN` with another table which also has a column of the name.
1173
-
1174
- *Soutaro Matsumoto*
1175
-
1176
- * Don't cache prepared statements containing an IN clause or a SQL literal, as
1177
- these queries will change often and are unlikely to have a cache hit.
1178
-
1179
- *Sean Griffin*
1180
-
1181
- * Fix `rewhere` in a `has_many` association.
1182
-
1183
- Fixes #21955.
1184
-
1185
- *Josh Branchaud*, *Kal*
1186
-
1187
- * `where` raises ArgumentError on unsupported types.
1188
-
1189
- Fixes #20473.
1190
-
1191
- *Jake Worth*
1192
-
1193
- * Add an immutable string type to help reduce memory usage for apps which do
1194
- not need mutation detection on strings.
1195
-
1196
- *Sean Griffin*
1197
-
1198
- * Give `ActiveRecord::Relation#update` its own deprecation warning when
1199
- passed an `ActiveRecord::Base` instance.
1200
-
1201
- Fixes #21945.
1202
-
1203
- *Ted Johansson*
1204
-
1205
- * Make it possible to pass `:to_table` when adding a foreign key through
1206
- `add_reference`.
1207
-
1208
- Fixes #21563.
1209
-
1210
- *Yves Senn*
1211
-
1212
- * No longer pass deprecated option `-i` to `pg_dump`.
1213
-
1214
- *Paul Sadauskas*
1215
-
1216
- * Concurrent `AR::Base#increment!` and `#decrement!` on the same record
1217
- are all reflected in the database rather than overwriting each other.
1218
-
1219
- *Bogdan Gusiev*
1220
-
1221
- * Avoid leaking the first relation we call `first` on, per model.
1222
-
1223
- Fixes #21921.
1224
-
1225
- *Matthew Draper*, *Jean Boussier*
1226
-
1227
- * Remove unused `pk_and_sequence_for` in `AbstractMysqlAdapter`.
1228
-
1229
- *Ryuta Kamizono*
1230
-
1231
- * Allow fixtures files to set the model class in the YAML file itself.
1232
-
1233
- To load the fixtures file `accounts.yml` as the `User` model, use:
1234
-
1235
- _fixture:
1236
- model_class: User
1237
- david:
1238
- name: David
1239
-
1240
- Fixes #9516.
1241
-
1242
- *Roque Pinel*
1243
-
1244
- * Don't require a database connection to load a class which uses acceptance
1245
- validations.
1246
-
1247
- *Sean Griffin*
1248
-
1249
- * Correctly apply `unscope` when preloading through associations.
1250
-
1251
- *Jimmy Bourassa*
1252
-
1253
- * Fixed taking precision into count when assigning a value to timestamp attribute.
1254
-
1255
- Timestamp column can have less precision than ruby timestamp
1256
- In result in how big a fraction of a second can be stored in the
1257
- database.
1258
-
1259
-
1260
- m = Model.create!
1261
- m.created_at.usec == m.reload.created_at.usec # => false
1262
- # due to different precision in Time.now and database column
1263
-
1264
- If the precision is low enough, (mysql default is 0, so it is always low
1265
- enough by default) the value changes when model is reloaded from the
1266
- database. This patch fixes that issue ensuring that any timestamp
1267
- assigned as an attribute is converted to column precision under the
1268
- attribute.
1269
-
1270
- *Bogdan Gusiev*
1271
-
1272
- * Introduce `connection.data_sources` and `connection.data_source_exists?`.
1273
- These methods determine what relations can be used to back Active Record
1274
- models (usually tables and views).
1275
-
1276
- Also deprecate `SchemaCache#tables`, `SchemaCache#table_exists?` and
1277
- `SchemaCache#clear_table_cache!` in favor of their new data source
1278
- counterparts.
1279
-
1280
- *Yves Senn*, *Matthew Draper*
1281
-
1282
- * Add `ActiveRecord::Base.ignored_columns` to make some columns
1283
- invisible from Active Record.
1284
-
1285
- *Jean Boussier*
1286
-
1287
- * `ActiveRecord::Tasks::MySQLDatabaseTasks` fails if shellout to
1288
- mysql commands (like `mysqldump`) is not successful.
1289
-
1290
- *Steve Mitchell*
1291
-
1292
- * Ensure `select` quotes aliased attributes, even when using `from`.
1293
-
1294
- Fixes #21488.
1295
-
1296
- *Sean Griffin*, *@johanlunds*
1297
-
1298
- * MySQL: support `unsigned` numeric data types.
1299
-
1300
- Example:
1301
-
1302
- create_table :foos do |t|
1303
- t.unsigned_integer :quantity
1304
- t.unsigned_bigint :total
1305
- t.unsigned_float :percentage
1306
- t.unsigned_decimal :price, precision: 10, scale: 2
1307
- end
1308
-
1309
- The `unsigned: true` option may be used for the primary key:
1310
-
1311
- create_table :foos, id: :bigint, unsigned: true do |t|
1312
-
1313
- end
1314
-
1315
- *Ryuta Kamizono*
1316
-
1317
- * Add `#views` and `#view_exists?` methods on connection adapters.
1318
-
1319
- *Ryuta Kamizono*
1320
-
1321
- * Correctly dump composite primary key.
1322
-
1323
- Example:
1324
-
1325
- create_table :barcodes, primary_key: ["region", "code"] do |t|
1326
- t.string :region
1327
- t.integer :code
1328
- end
1329
-
1330
- *Ryuta Kamizono*
1331
-
1332
- * Lookup the attribute name for `restrict_with_error` messages on the
1333
- model class that defines the association.
1334
-
1335
- *kuboon*, *Ronak Jangir*
1336
-
1337
- * Correct query for PostgreSQL 8.2 compatibility.
1338
-
1339
- *Ben Murphy*, *Matthew Draper*
1340
-
1341
- * `bin/rails db:migrate` uses
1342
- `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
1343
- `Migrator.migrations_paths`.
1344
-
1345
- *Tobias Bielohlawek*
1346
-
1347
- * Support dropping indexes concurrently in PostgreSQL.
1348
-
1349
- See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more
1350
- details.
1351
-
1352
- *Grey Baker*
1353
-
1354
- * Deprecate passing conditions to `ActiveRecord::Relation#delete_all`
1355
- and `ActiveRecord::Relation#destroy_all`.
1356
-
1357
- *Wojciech Wnętrzak*
1358
-
1359
- * Instantiating an AR model with `ActionController::Parameters` now raises
1360
- an `ActiveModel::ForbiddenAttributesError` if the parameters include a
1361
- `type` field that has not been explicitly permitted. Previously, the
1362
- `type` field was simply ignored in the same situation.
1363
-
1364
- *Prem Sichanugrist*
1365
-
1366
- * PostgreSQL, `create_schema`, `drop_schema` and `rename_table` now quote
1367
- schema names.
1368
-
1369
- Fixes #21418.
1370
-
1371
- Example:
1372
-
1373
- create_schema("my.schema")
1374
- # CREATE SCHEMA "my.schema";
1375
-
1376
- *Yves Senn*
1377
-
1378
- * PostgreSQL, add `:if_exists` option to `#drop_schema`. This makes it
1379
- possible to drop a schema that might exist without raising an exception if
1380
- it doesn't.
1381
-
1382
- *Yves Senn*
1383
-
1384
- * Only try to nullify has_one target association if the record is persisted.
1385
-
1386
- Fixes #21223.
1387
-
1388
- *Agis Anastasopoulos*
1389
-
1390
- * Uniqueness validator raises descriptive error when running on a persisted
1391
- record without primary key.
1392
-
1393
- Fixes #21304.
1394
-
1395
- *Yves Senn*
1396
-
1397
- * Add a native JSON data type support in MySQL.
1398
-
1399
- Example:
1400
-
1401
- create_table :json_data_type do |t|
1402
- t.json :settings
1403
- end
1404
-
1405
- *Ryuta Kamizono*
1406
-
1407
- * Descriptive error message when fixtures contain a missing column.
1408
-
1409
- Fixes #21201.
1410
-
1411
- *Yves Senn*
1412
-
1413
- * `ActiveRecord::Tasks::PostgreSQLDatabaseTasks` fail if shellout to
1414
- postgresql commands (like `pg_dump`) is not successful.
1415
-
1416
- *Bryan Paxton*, *Nate Berkopec*
1417
-
1418
- * Add `ActiveRecord::Relation#in_batches` to work with records and relations
1419
- in batches.
1420
-
1421
- Available options are `of` (batch size), `load`, `start`, and `finish`.
1422
-
1423
- Examples:
1424
-
1425
- Person.in_batches.each_record(&:party_all_night!)
1426
- Person.in_batches.update_all(awesome: true)
1427
- Person.in_batches.delete_all
1428
- Person.in_batches.each do |relation|
1429
- relation.delete_all
1430
- sleep 10 # Throttles the delete queries
1431
- end
1432
-
1433
- Fixes #20933.
1434
-
1435
- *Sina Siadat*
1436
-
1437
- * Added methods for PostgreSQL geometric data types to use in migrations.
1438
-
1439
- Example:
1440
-
1441
- create_table :foo do |t|
1442
- t.line :foo_line
1443
- t.lseg :foo_lseg
1444
- t.box :foo_box
1445
- t.path :foo_path
1446
- t.polygon :foo_polygon
1447
- t.circle :foo_circle
1448
- end
1449
-
1450
- *Mehmet Emin İNAÇ*
1451
-
1452
- * Add `cache_key` to `ActiveRecord::Relation`.
1453
-
1454
- Example:
1455
-
1456
- @users = User.where("name like ?", "%Alberto%")
1457
- @users.cache_key
1458
- # => "/users/query-5942b155a43b139f2471b872ac54251f-3-20150714212107656125000"
1459
-
1460
- *Alberto Fernández-Capel*
1461
-
1462
- * Properly allow uniqueness validations on primary keys.
1463
-
1464
- Fixes #20966.
1465
-
1466
- *Sean Griffin*, *presskey*
1467
-
1468
- * Don't raise an error if an association failed to destroy when `destroy` was
1469
- called on the parent (as opposed to `destroy!`).
1470
-
1471
- Fixes #20991.
1472
-
1473
- *Sean Griffin*
1474
-
1475
- * `ActiveRecord::RecordNotFound` modified to store model name, primary_key and
1476
- id of the caller model. It allows the catcher of this exception to make
1477
- a better decision to what to do with it.
1478
-
1479
- Example:
1480
-
1481
- class SomeAbstractController < ActionController::Base
1482
- rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
1483
-
1484
- private def redirect_to_404(e)
1485
- return redirect_to(posts_url) if e.model == 'Post'
1486
- raise
1487
- end
1488
- end
1489
-
1490
- *Sameer Rahmani*
1491
-
1492
- * Deprecate the keys for association `restrict_dependent_destroy` errors in favor
1493
- of new key names.
1494
-
1495
- Previously `has_one` and `has_many` associations were using the
1496
- `one` and `many` keys respectively. Both of these keys have special
1497
- meaning in I18n (they are considered to be pluralizations) so by
1498
- renaming them to `has_one` and `has_many` we make the messages more explicit
1499
- and most importantly they don't clash with linguistical systems that need to
1500
- validate translation keys (and their pluralizations).
1501
-
1502
- The `:'restrict_dependent_destroy.one'` key should be replaced with
1503
- `:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'`
1504
- with `:'restrict_dependent_destroy.has_many'`.
1505
-
1506
- *Roque Pinel*, *Christopher Dell*
1507
-
1508
- * Fix state being carried over from previous transaction.
1509
-
1510
- Considering the following example where `name` is a required attribute.
1511
- Before we had `new_record?` returning `true` for a persisted record:
1512
-
1513
- author = Author.create! name: 'foo'
1514
- author.name = nil
1515
- author.save # => false
1516
- author.new_record? # => true
1517
-
1518
- Fixes #20824.
1519
-
1520
- *Roque Pinel*
1521
-
1522
- * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
1523
- when validating associations.
1524
-
1525
- Fixes #20882.
1526
-
1527
- *Sean Griffin*
1528
-
1529
- * Fix a bug where counter_cache doesn't always work with polymorphic
1530
- relations.
1531
-
1532
- Fixes #16407.
1533
-
1534
- *Stefan Kanev*, *Sean Griffin*
1535
-
1536
- * Ensure that cyclic associations with autosave don't cause duplicate errors
1537
- to be added to the parent record.
1538
-
1539
- Fixes #20874.
1540
-
1541
- *Sean Griffin*
1542
-
1543
- * Ensure that `ActionController::Parameters` can still be passed to nested
1544
- attributes.
1545
-
1546
- Fixes #20922.
1547
-
1548
- *Sean Griffin*
1549
-
1550
- * Deprecate force association reload by passing a truthy argument to
1551
- association method.
1552
-
1553
- For collection association, you can call `#reload` on association proxy to
1554
- force a reload:
1555
-
1556
- @user.posts.reload # Instead of @user.posts(true)
1557
-
1558
- For singular association, you can call `#reload` on the parent object to
1559
- clear its association cache then call the association method:
1560
-
1561
- @user.reload.profile # Instead of @user.profile(true)
1562
-
1563
- Passing a truthy argument to force association to reload will be removed in
1564
- Rails 5.1.
1565
-
1566
- *Prem Sichanugrist*
1567
-
1568
- * Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
1569
- from the concurrent-ruby gem.
1570
-
1571
- *Jerry D'Antonio*
1572
-
1573
- * Fix through associations using scopes having the scope merged multiple
1574
- times.
1575
-
1576
- Fixes #20721.
1577
- Fixes #20727.
1578
-
1579
- *Sean Griffin*
1580
-
1581
- * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
1582
- other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
1583
-
1584
- Fixes #20743.
1585
-
1586
- *Yves Senn*
1587
-
1588
- * Add alternate syntax to make `change_column_default` reversible.
1589
-
1590
- User can pass in `:from` and `:to` to make `change_column_default` command
1591
- become reversible.
1592
-
1593
- Example:
1594
-
1595
- change_column_default :posts, :status, from: nil, to: "draft"
1596
- change_column_default :users, :authorized, from: true, to: false
1597
-
1598
- *Prem Sichanugrist*
1599
-
1600
- * Prevent error when using `force_reload: true` on an unassigned polymorphic
1601
- belongs_to association.
1602
-
1603
- Fixes #20426.
1604
-
1605
- *James Dabbs*
1606
-
1607
- * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
1608
- a wrong type to a namespaced association.
1609
-
1610
- Fixes #20545.
1611
-
1612
- *Diego Carrion*
1613
-
1614
- * `validates_absence_of` respects `marked_for_destruction?`.
1615
-
1616
- Fixes #20449.
1617
-
1618
- *Yves Senn*
1619
-
1620
- * Include the `Enumerable` module in `ActiveRecord::Relation`
1621
-
1622
- *Sean Griffin*, *bogdan*
1623
-
1624
- * Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
1625
-
1626
- *Sean Griffin*
1627
-
1628
- * Let `WITH` queries (Common Table Expressions) be explainable.
1629
-
1630
- *Vladimir Kochnev*
1631
-
1632
- * Make `remove_index :table, :column` reversible.
1633
-
1634
- *Yves Senn*
1635
-
1636
- * Fixed an error which would occur in dirty checking when calling
1637
- `update_attributes` from a getter.
1638
-
1639
- Fixes #20531.
1640
-
1641
- *Sean Griffin*
1642
-
1643
- * Make `remove_foreign_key` reversible. Any foreign key options must be
1644
- specified, similar to `remove_column`.
1645
-
1646
- *Aster Ryan*
1647
-
1648
- * Add `:_prefix` and `:_suffix` options to `enum` definition.
1649
-
1650
- Fixes #17511, #17415.
1651
-
1652
- *Igor Kapkov*
1653
-
1654
- * Correctly handle decimal arrays with defaults in the schema dumper.
1655
-
1656
- Fixes #20515.
1657
-
1658
- *Sean Griffin*, *jmondo*
1659
-
1660
- * Deprecate the PostgreSQL `:point` type in favor of a new one which will return
1661
- `Point` objects instead of an `Array`
1662
-
1663
- *Sean Griffin*
1664
-
1665
- * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
1666
- as columns.
1667
-
1668
- Fixes #20360.
1669
-
1670
- *Sean Griffin*
1671
-
1672
- * Do not set `sql_mode` if `strict: :default` is specified.
1673
-
1674
- # config/database.yml
1675
- production:
1676
- adapter: mysql2
1677
- database: foo_prod
1678
- user: foo
1679
- strict: :default
1680
-
1681
- *Ryuta Kamizono*
1682
-
1683
- * Allow proc defaults to be passed to the attributes API. See documentation
1684
- for examples.
1685
-
1686
- *Sean Griffin*, *Kir Shatrov*
1687
-
1688
- * SQLite: `:collation` support for string and text columns.
1689
-
1690
- Example:
1691
-
1692
- create_table :foo do |t|
1693
- t.string :string_nocase, collation: 'NOCASE'
1694
- t.text :text_rtrim, collation: 'RTRIM'
1695
- end
1696
-
1697
- add_column :foo, :title, :string, collation: 'RTRIM'
1698
-
1699
- change_column :foo, :title, :string, collation: 'NOCASE'
1700
-
1701
- *Akshay Vishnoi*
1702
-
1703
- * Allow the use of symbols or strings to specify enum values in test
1704
- fixtures:
1705
-
1706
- awdr:
1707
- title: "Agile Web Development with Rails"
1708
- status: :proposed
1709
-
1710
- *George Claghorn*
1711
-
1712
- * Clear query cache when `ActiveRecord::Base#reload` is called.
1713
-
1714
- *Shane Hender, Pierre Nespo*
1715
-
1716
- * Include stored procedures and function on the MySQL structure dump.
1717
-
1718
- *Jonathan Worek*
1719
-
1720
- * Pass `:extend` option for `has_and_belongs_to_many` associations to the
1721
- underlying `has_many :through`.
1722
-
1723
- *Jaehyun Shin*
1724
-
1725
- * Deprecate `Relation#uniq` use `Relation#distinct` instead.
1726
-
1727
- See #9683.
1728
-
1729
- *Yves Senn*
1730
-
1731
- * Allow single table inheritance instantiation to work when storing
1732
- demodulized class names.
1733
-
1734
- *Alex Robbin*
1735
-
1736
- * Correctly pass MySQL options when using `structure_dump` or
1737
- `structure_load`.
1738
-
1739
- Specifically, it fixes an issue when using SSL authentication.
1740
-
1741
- *Alex Coomans*
1742
-
1743
- * Correctly dump `:options` on `create_table` for MySQL.
1744
-
1745
- *Ryuta Kamizono*
1746
-
1747
- * PostgreSQL: `:collation` support for string and text columns.
1748
-
1749
- Example:
1750
-
1751
- create_table :foos do |t|
1752
- t.string :string_en, collation: 'en_US.UTF-8'
1753
- t.text :text_ja, collation: 'ja_JP.UTF-8'
1754
- end
1755
-
1756
- *Ryuta Kamizono*
1757
-
1758
- * Remove `ActiveRecord::Serialization::XmlSerializer` from core.
1759
-
1760
- *Zachary Scott*
1761
-
1762
- * Make `unscope` aware of "less than" and "greater than" conditions.
1763
-
1764
- *TAKAHASHI Kazuaki*
1765
-
1766
- * `find_by` and `find_by!` raise `ArgumentError` when called without
1767
- arguments.
1768
-
1769
- *Kohei Suzuki*
1770
-
1771
- * Revert behavior of `db:schema:load` back to loading the full
1772
- environment. This ensures that initializers are run.
1773
-
1774
- Fixes #19545.
1775
-
1776
- *Yves Senn*
1777
-
1778
- * Fix missing index when using `timestamps` with the `index` option.
1779
-
1780
- The `index` option used with `timestamps` should be passed to both
1781
- `column` definitions for `created_at` and `updated_at` rather than just
1782
- the first.
1783
-
1784
- *Paul Mucur*
1785
-
1786
- * Rename `:class` to `:anonymous_class` in association options.
1787
-
1788
- Fixes #19659.
1789
-
1790
- *Andrew White*
1791
-
1792
- * Autosave existing records on a has many through association when the parent
1793
- is new.
1794
-
1795
- Fixes #19782.
1796
-
1797
- *Sean Griffin*
1798
-
1799
- * Fixed a bug where uniqueness validations would error on out of range values,
1800
- even if an validation should have prevented it from hitting the database.
1801
-
1802
- *Andrey Voronkov*
1803
-
1804
- * MySQL: `:charset` and `:collation` support for string and text columns.
1805
-
1806
- Example:
1807
-
1808
- create_table :foos do |t|
1809
- t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
1810
- t.text :text_ascii, charset: 'ascii'
1811
- end
1812
-
1813
- *Ryuta Kamizono*
1814
-
1815
- * Foreign key related methods in the migration DSL respect
1816
- `ActiveRecord::Base.pluralize_table_names = false`.
1817
-
1818
- Fixes #19643.
1819
-
1820
- *Mehmet Emin İNAÇ*
1821
-
1822
- * Reduce memory usage from loading types on PostgreSQL.
1823
-
1824
- Fixes #19578.
1825
-
1826
- *Sean Griffin*
1827
-
1828
- * Add `config.active_record.warn_on_records_fetched_greater_than` option.
1829
-
1830
- When set to an integer, a warning will be logged whenever a result set
1831
- larger than the specified size is returned by a query.
1832
-
1833
- Fixes #16463.
1834
-
1835
- *Jason Nochlin*
1836
-
1837
- * Ignore `.psqlrc` when loading database structure.
1838
-
1839
- *Jason Weathered*
1840
-
1841
- * Fix referencing wrong table aliases while joining tables of has many through
1842
- association (only when calling calculation methods).
1843
-
1844
- Fixes #19276.
1845
-
1846
- *pinglamb*
1847
-
1848
- * Correctly persist a serialized attribute that has been returned to
1849
- its default value by an in-place modification.
1850
-
1851
- Fixes #19467.
1852
-
1853
- *Matthew Draper*
1854
-
1855
- * Fix generating the schema file when using PostgreSQL `BigInt[]` data type.
1856
- Previously the `limit: 8` was not coming through, and this caused it to
1857
- become `Int[]` data type after rebuilding from the schema.
1858
-
1859
- Fixes #19420.
1860
-
1861
- *Jake Waller*
1862
-
1863
- * Reuse the `CollectionAssociation#reader` cache when the foreign key is
1864
- available prior to save.
1865
-
1866
- *Ben Woosley*
1867
-
1868
- * Add `config.active_record.dump_schemas` to fix `db:structure:dump`
1869
- when using schema_search_path and PostgreSQL extensions.
1870
-
1871
- Fixes #17157.
1872
-
1873
- *Ryan Wallace*
1874
-
1875
- * Renaming `use_transactional_fixtures` to `use_transactional_tests` for clarity.
1876
-
1877
- Fixes #18864.
1878
-
1879
- *Brandon Weiss*
1880
-
1881
- * Increase pg gem version requirement to `~> 0.18`. Earlier versions of the
1882
- pg gem are known to have problems with Ruby 2.2.
1883
-
1884
- *Matt Brictson*
1885
-
1886
- * Correctly dump `serial` and `bigserial`.
1887
-
1888
- *Ryuta Kamizono*
1889
-
1890
- * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
1891
-
1892
- *James Cox*
1893
-
1894
- * Don't enroll records in the transaction if they don't have commit callbacks.
1895
- This was causing a memory leak when creating many records inside a transaction.
1896
-
1897
- Fixes #15549.
1898
-
1899
- *Will Bryant*, *Aaron Patterson*
1900
-
1901
- * Correctly create through records when created on a has many through
1902
- association when using `where`.
1903
-
1904
- Fixes #19073.
1905
-
1906
- *Sean Griffin*
1907
-
1908
- * Add `SchemaMigration.create_table` support for any unicode charsets with MySQL.
1909
-
1910
- *Ryuta Kamizono*
1911
-
1912
- * PostgreSQL no longer disables user triggers if system triggers can't be
1913
- disabled. Disabling user triggers does not fulfill what the method promises.
1914
- Rails currently requires superuser privileges for this method.
1915
-
1916
- If you absolutely rely on this behavior, consider patching
1917
- `disable_referential_integrity`.
1918
-
1919
- *Yves Senn*
1920
-
1921
- * Restore aborted transaction state when `disable_referential_integrity` fails
1922
- due to missing permissions.
1923
-
1924
- *Toby Ovod-Everett*, *Yves Senn*
1925
-
1926
- * In PostgreSQL, print a warning message if `disable_referential_integrity`
1927
- fails due to missing permissions.
1928
-
1929
- *Andrey Nering*, *Yves Senn*
1930
-
1931
- * Allow a `:limit` option for MySQL bigint primary key support.
1932
-
1933
- Example:
1934
-
1935
- create_table :foos, id: :primary_key, limit: 8 do |t|
1936
- end
1937
-
1938
- # or
1939
-
1940
- create_table :foos, id: false do |t|
1941
- t.primary_key :id, limit: 8
1942
- end
1943
-
1944
- *Ryuta Kamizono*
1945
-
1946
- * `belongs_to` will now trigger a validation error by default if the association is not present.
1947
- You can turn this off on a per-association basis with `optional: true`.
1948
- (Note this new default only applies to new Rails apps that will be generated with
1949
- `config.active_record.belongs_to_required_by_default = true` in initializer.)
1950
-
1951
- *Josef Šimánek*
1952
-
1953
- * Fixed `ActiveRecord::Relation#becomes!` and `changed_attributes` issues for type
1954
- columns.
1955
-
1956
- Fixes #17139.
1957
-
1958
- *Miklos Fazekas*
1959
-
1960
- * Format the time string according to the precision of the time column.
1961
-
1962
- *Ryuta Kamizono*
1963
-
1964
- * Allow a `:precision` option for time type columns.
1965
-
1966
- *Ryuta Kamizono*
1967
-
1968
- * Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
1969
- during the given block.
1970
-
1971
- For example, here's a pattern of creating notifications when new comments
1972
- are posted. (The notification may in turn trigger an email, a push
1973
- notification, or just appear in the UI somewhere):
1974
-
1975
- class Comment < ActiveRecord::Base
1976
- belongs_to :commentable, polymorphic: true
1977
- after_create -> { Notification.create! comment: self,
1978
- recipients: commentable.recipients }
1979
- end
1980
-
1981
- That's what you want the bulk of the time. A new comment creates a new
1982
- Notification. There may be edge cases where you don't want that, like
1983
- when copying a commentable and its comments, in which case write a
1984
- concern with something like this:
1985
-
1986
- module Copyable
1987
- def copy_to(destination)
1988
- Notification.suppress do
1989
- # Copy logic that creates new comments that we do not want triggering
1990
- # notifications.
1991
- end
1992
- end
1993
- end
1994
-
1995
- *Michael Ryan*
1996
-
1997
- * `:time` option added for `#touch`.
1998
-
1999
- Fixes #18905.
2000
-
2001
- *Hyonjee Joo*
2002
-
2003
- * Add `foreign_key_exists?` method.
2004
-
2005
- *Tõnis Simo*
2006
-
2007
- * Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods
2008
- if no block or limit is given, instead of loading the entire
2009
- collection into memory. This applies to relations (e.g. `User.all`)
2010
- as well as associations (e.g. `account.users`)
2011
-
2012
- # Before:
2013
-
2014
- users.none?
2015
- # SELECT "users".* FROM "users"
2016
-
2017
- users.one?
2018
- # SELECT "users".* FROM "users"
2019
-
2020
- # After:
2021
-
2022
- users.none?
2023
- # SELECT 1 AS one FROM "users" LIMIT 1
2024
-
2025
- users.one?
2026
- # SELECT COUNT(*) FROM "users"
2027
-
2028
- *Eugene Gilburg*
2029
-
2030
- * Have `enum` perform type casting consistently with the rest of Active
2031
- Record, such as `where`.
2032
-
2033
- *Sean Griffin*
2034
-
2035
- * `scoping` no longer pollutes the current scope of sibling classes when using
2036
- STI.
2037
-
2038
- Fixes #18806.
2039
-
2040
- Example:
2041
-
2042
- StiOne.none.scoping do
2043
- StiTwo.all
2044
- end
2045
-
2046
-
2047
- *Sean Griffin*
2048
-
2049
- * `remove_reference` with `foreign_key: true` removes the foreign key before
2050
- removing the column. This fixes a bug where it was not possible to remove
2051
- the column on MySQL.
2052
-
2053
- Fixes #18664.
2054
-
2055
- *Yves Senn*
2056
-
2057
- * `find_in_batches` now accepts an `:finish` parameter that complements the `:start`
2058
- parameter to specify where to stop batch processing.
2059
-
2060
- *Vipul A M*
2061
-
2062
- * Fix a rounding problem for PostgreSQL timestamp columns.
2063
-
2064
- If a timestamp column has a precision specified, it needs to
2065
- format according to that.
2066
-
2067
- *Ryuta Kamizono*
2068
-
2069
- * Respect the database default charset for `schema_migrations` table.
2070
-
2071
- The charset of `version` column in `schema_migrations` table depends
2072
- on the database default charset and collation rather than the encoding
2073
- of the connection.
2074
-
2075
- *Ryuta Kamizono*
2076
-
2077
- * Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
2078
-
2079
- These are not valid values to merge in a relation, so it should warn users
2080
- early.
2081
-
2082
- *Rafael Mendonça França*
2083
-
2084
- * Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
2085
-
2086
- This makes the `db:structure` tasks consistent with `test:load_structure`.
2087
-
2088
- *Dieter Komendera*
2089
-
2090
- * Respect custom primary keys for associations when calling `Relation#where`
2091
-
2092
- Fixes #18813.
2093
-
2094
- *Sean Griffin*
2095
-
2096
- * Fix several edge cases which could result in a counter cache updating
2097
- twice or not updating at all for `has_many` and `has_many :through`.
2098
-
2099
- Fixes #10865.
2100
-
2101
- *Sean Griffin*
2102
-
2103
- * Foreign keys added by migrations were given random, generated names. This
2104
- meant a different `structure.sql` would be generated every time a developer
2105
- ran migrations on their machine.
2106
-
2107
- The generated part of foreign key names is now a hash of the table name and
2108
- column name, which is consistent every time you run the migration.
2109
-
2110
- *Chris Sinjakli*
2111
-
2112
- * Fix n+1 query problem when eager loading nil associations (fixes #18312)
2113
-
2114
- *Sammy Larbi*
2115
-
2116
- * Change the default error message from `can't be blank` to `must exist` for
2117
- the presence validator of the `:required` option on `belongs_to`/`has_one`
2118
- associations.
2119
-
2120
- *Henrik Nygren*
2121
-
2122
- * Fixed `ActiveRecord::Relation#group` method when an argument is an SQL
2123
- reserved keyword:
2124
-
2125
- Example:
2126
-
2127
- SplitTest.group(:key).count
2128
- Property.group(:value).count
2129
-
2130
- *Bogdan Gusiev*
2131
-
2132
- * Added the `#or` method on `ActiveRecord::Relation`, allowing use of the OR
2133
- operator to combine WHERE or HAVING clauses.
2134
-
2135
- Example:
2136
-
2137
- Post.where('id = 1').or(Post.where('id = 2'))
2138
- # => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
2139
-
2140
- *Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
2141
-
2142
- * Don't define autosave association callbacks twice from
2143
- `accepts_nested_attributes_for`.
2144
-
2145
- Fixes #18704.
2146
-
2147
- *Sean Griffin*
2148
-
2149
- * Integer types will no longer raise a `RangeError` when assigning an
2150
- attribute, but will instead raise when going to the database.
2151
-
2152
- Fixes several vague issues which were never reported directly. See the
2153
- commit message from the commit which added this line for some examples.
2154
-
2155
- *Sean Griffin*
2156
-
2157
- * Values which would error while being sent to the database (such as an
2158
- ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
2159
- assignment. They will still error when sent to the database, but you are
2160
- given the ability to re-assign it to a valid value.
2161
-
2162
- Fixes #18580.
2163
-
2164
- *Sean Griffin*
2165
-
2166
- * Don't remove join dependencies in `Relation#exists?`
2167
-
2168
- Fixes #18632.
2169
-
2170
- *Sean Griffin*
2171
-
2172
- * Invalid values assigned to a JSON column are assumed to be `nil`.
2173
-
2174
- Fixes #18629.
2175
-
2176
- *Sean Griffin*
2177
-
2178
- * Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
2179
- discover which fields were read from a model when you are looking to only
2180
- select the data you need from the database.
2181
-
2182
- *Sean Griffin*
2183
-
2184
- * Introduce the `:if_exists` option for `drop_table`.
2185
-
2186
- Example:
2187
-
2188
- drop_table(:posts, if_exists: true)
2189
-
2190
- That would execute:
2191
-
2192
- DROP TABLE IF EXISTS posts
2193
-
2194
- If the table doesn't exist, `if_exists: false` (the default) raises an
2195
- exception whereas `if_exists: true` does nothing.
2196
-
2197
- *Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
2198
-
2199
- * Don't run SQL if attribute value is not changed for update_attribute method.
2200
-
2201
- *Prathamesh Sonpatki*
2202
-
2203
- * `time` columns can now get affected by `time_zone_aware_attributes`. If you have
2204
- set `config.time_zone` to a value other than `'UTC'`, they will be treated
2205
- as in that time zone by default in Rails 5.1. If this is not the desired
2206
- behavior, you can set
2207
-
2208
- ActiveRecord::Base.time_zone_aware_types = [:datetime]
2209
-
2210
- A deprecation warning will be emitted if you have a `:time` column, and have
2211
- not explicitly opted out.
2212
-
2213
- Fixes #3145.
2214
-
2215
- *Sean Griffin*
2216
-
2217
- * Tests now run after_commit callbacks. You no longer have to declare
2218
- `uses_transaction ‘test name’` to test the results of an after_commit.
2219
-
2220
- after_commit callbacks run after committing a transaction whose parent
2221
- is not `joinable?`: un-nested transactions, transactions within test cases,
2222
- and transactions in `console --sandbox`.
2223
-
2224
- *arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
2225
-
2226
- * `nil` as a value for a binary column in a query no longer logs as
2227
- "<NULL binary data>", and instead logs as just "nil".
2228
-
2229
- *Sean Griffin*
2230
-
2231
- * `attribute_will_change!` will no longer cause non-persistable attributes to
2232
- be sent to the database.
2233
-
2234
- Fixes #18407.
2235
-
2236
- *Sean Griffin*
2237
-
2238
- * Remove support for the `protected_attributes` gem.
2239
-
2240
- *Carlos Antonio da Silva*, *Roberto Miranda*
2241
-
2242
- * Fix accessing of fixtures having non-string labels like Fixnum.
2243
-
2244
- *Prathamesh Sonpatki*
2245
-
2246
- * Remove deprecated support to preload instance-dependent associations.
2247
-
2248
- *Yves Senn*
2249
-
2250
- * Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
2251
-
2252
- *Yves Senn*
2253
-
2254
- * Remove deprecation when modifying a relation with cached Arel.
2255
- This raises an `ImmutableRelation` error instead.
2256
-
2257
- *Yves Senn*
2258
-
2259
- * Added `ActiveRecord::SecureToken` in order to encapsulate generation of
2260
- unique tokens for attributes in a model using `SecureRandom`.
2261
-
2262
- *Roberto Miranda*
2263
-
2264
- * Change the behavior of boolean columns to be closer to Ruby's semantics.
2265
-
2266
- Before this change we had a small set of "truthy", and all others are "falsy".
2267
-
2268
- Now, we have a small set of "falsy" values and all others are "truthy" matching
2269
- Ruby's semantics.
2270
-
2271
- *Rafael Mendonça França*
2272
-
2273
- * Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
2274
-
2275
- *Rafael Mendonça França*
2276
-
2277
- * Change transaction callbacks to not swallow errors.
2278
-
2279
- Before this change any errors raised inside a transaction callback
2280
- were getting rescued and printed in the logs.
2281
-
2282
- Now these errors are not rescued anymore and just bubble up, as the other callbacks.
2283
-
2284
- *Rafael Mendonça França*
2285
-
2286
- * Remove deprecated `sanitize_sql_hash_for_conditions`.
2287
-
2288
- *Rafael Mendonça França*
2289
-
2290
- * Remove deprecated `Reflection#source_macro`.
2291
-
2292
- *Rafael Mendonça França*
2293
-
2294
- * Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
2295
-
2296
- *Rafael Mendonça França*
2297
-
2298
- * Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
2299
-
2300
- *Rafael Mendonça França*
2301
-
2302
- * Remove deprecated access to connection specification using a string accessor.
2303
-
2304
- Now all strings will be handled as a URL.
2305
-
2306
- *Rafael Mendonça França*
2307
-
2308
- * Change the default `null` value for `timestamps` to `false`.
2309
-
2310
- *Rafael Mendonça França*
2311
-
2312
- * Return an array of pools from `connection_pools`.
2313
-
2314
- *Rafael Mendonça França*
2315
-
2316
- * Return a null column from `column_for_attribute` when no column exists.
2317
-
2318
- *Rafael Mendonça França*
2319
-
2320
- * Remove deprecated `serialized_attributes`.
2321
-
2322
- *Rafael Mendonça França*
2323
-
2324
- * Remove deprecated automatic counter caches on `has_many :through`.
2325
-
2326
- *Rafael Mendonça França*
2327
-
2328
- * Change the way in which callback chains can be halted.
2329
-
2330
- The preferred method to halt a callback chain from now on is to explicitly
2331
- `throw(:abort)`.
2332
- In the past, returning `false` in an Active Record `before_` callback had the
2333
- side effect of halting the callback chain.
2334
- This is not recommended anymore and, depending on the value of the
2335
- `ActiveSupport.halt_callback_chains_on_return_false` option, will
2336
- either not work at all or display a deprecation warning.
2337
-
2338
- *claudiob*
2339
-
2340
- * Clear query cache on rollback.
2341
-
2342
- *Florian Weingarten*
2343
-
2344
- * Fix setting of foreign_key for through associations when building a new record.
2345
-
2346
- Fixes #12698.
2347
-
2348
- *Ivan Antropov*
2349
-
2350
- * Improve dumping of the primary key. If it is not a default primary key,
2351
- correctly dump the type and options.
2352
-
2353
- Fixes #14169, #16599.
2354
-
2355
- *Ryuta Kamizono*
2356
-
2357
- * Format the datetime string according to the precision of the datetime field.
2358
-
2359
- Incompatible to rounding behavior between MySQL 5.6 and earlier.
2360
-
2361
- In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
2362
- is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
2363
-
2364
- http://bugs.mysql.com/bug.php?id=68760
2365
-
2366
- *Ryuta Kamizono*
2367
-
2368
- * Allow a precision option for MySQL datetimes.
2369
-
2370
- *Ryuta Kamizono*
2371
-
2372
- * Fixed automatic `inverse_of` for models nested in a module.
2373
-
2374
- *Andrew McCloud*
2375
-
2376
- * Change `ActiveRecord::Relation#update` behavior so that it can
2377
- be called without passing ids of the records to be updated.
2378
-
2379
- This change allows updating multiple records returned by
2380
- `ActiveRecord::Relation` with callbacks and validations.
2381
-
2382
- # Before
2383
- # ArgumentError: wrong number of arguments (1 for 2)
2384
- Comment.where(group: 'expert').update(body: "Group of Rails Experts")
2385
-
2386
- # After
2387
- # Comments with group expert updated with body "Group of Rails Experts"
2388
- Comment.where(group: 'expert').update(body: "Group of Rails Experts")
2389
-
2390
- *Prathamesh Sonpatki*
2391
-
2392
- * Fix `reaping_frequency` option when the value is a string.
2393
-
2394
- This usually happens when it is configured using `DATABASE_URL`.
2395
-
2396
- *korbin*
2397
-
2398
- * Fix error message when trying to create an associated record and the foreign
2399
- key is missing.
2400
-
2401
- Before this fix the following exception was being raised:
2402
-
2403
- NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
2404
-
2405
- Now the message is:
2406
-
2407
- ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
2408
-
2409
- *Rafael Mendonça França*
2410
-
2411
- * Fix change detection problem for PostgreSQL bytea type and
2412
- `ArgumentError: string contains null byte` exception with pg-0.18.
2413
-
2414
- Fixes #17680.
2415
-
2416
- *Lars Kanis*
2417
-
2418
- * When a table has a composite primary key, the `primary_key` method for
2419
- SQLite3 and PostgreSQL adapters was only returning the first field of the key.
2420
- Ensures that it will return nil instead, as Active Record doesn't support
2421
- composite primary keys.
2422
-
2423
- Fixes #18070.
2424
-
2425
- *arthurnn*
2426
-
2427
- * `validates_size_of` / `validates_length_of` do not count records
2428
- which are `marked_for_destruction?`.
2429
-
2430
- Fixes #7247.
2431
-
2432
- *Yves Senn*
2433
-
2434
- * Ensure `first!` and friends work on loaded associations.
2435
-
2436
- Fixes #18237.
2437
-
2438
- *Sean Griffin*
2439
-
2440
- * `eager_load` preserves readonly flag for associations.
2441
-
2442
- Fixes #15853.
2443
-
2444
- *Takashi Kokubun*
2445
-
2446
- * Provide `:touch` option to `save()` to accommodate saving without updating
2447
- timestamps.
2448
-
2449
- Fixes #18202.
2450
-
2451
- *Dan Olson*
2452
-
2453
- * Provide a more helpful error message when an unsupported class is passed to
2454
- `serialize`.
2455
-
2456
- Fixes #18224.
2457
-
2458
- *Sean Griffin*
2459
-
2460
- * Add bigint primary key support for MySQL.
2461
-
2462
- Example:
2463
-
2464
- create_table :foos, id: :bigint do |t|
2465
- end
2466
-
2467
- *Ryuta Kamizono*
2468
-
2469
- * Support for any type of primary key.
2470
-
2471
- Fixes #14194.
2472
-
2473
- *Ryuta Kamizono*
2474
-
2475
- * Dump the default `nil` for PostgreSQL UUID primary key.
2476
-
2477
- *Ryuta Kamizono*
2478
-
2479
- * Add a `:foreign_key` option to `references` and associated migration
2480
- methods. The model and migration generators now use this option, rather than
2481
- the `add_foreign_key` form.
2482
-
2483
- *Sean Griffin*
2484
-
2485
- * Don't raise when writing an attribute with an out-of-range datetime passed
2486
- by the user.
2487
-
2488
- *Grey Baker*
2489
-
2490
- * Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
2491
- `ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
2492
-
2493
- *Yves Senn*
2494
-
2495
- * Fix bug with `ActiveRecord::Type::Numeric` that caused negative values to
2496
- be marked as having changed when set to the same negative value.
2497
-
2498
- Fixes #18161.
2499
-
2500
- *Daniel Fox*
2501
-
2502
- * Introduce `force: :cascade` option for `create_table`. Using this option
2503
- will recreate tables even if they have dependent objects (like foreign keys).
2504
- `db/schema.rb` now uses `force: :cascade`. This makes it possible to
2505
- reload the schema when foreign keys are in place.
2506
-
2507
- *Matthew Draper*, *Yves Senn*
2508
-
2509
- * `db:schema:load` and `db:structure:load` no longer purge the database
2510
- before loading the schema. This is left for the user to do.
2511
- `db:test:prepare` will still purge the database.
2512
-
2513
- Fixes #17945.
2514
-
2515
- *Yves Senn*
2516
-
2517
- * Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
2518
-
2519
- *Ryuta Kamizono*
2520
-
2521
- * Add `foreign_type` option to `has_one` and `has_many` association macros.
2522
-
2523
- This option enables to define the column name of associated object's type for polymorphic associations.
2524
-
2525
- *Ulisses Almeida*, *Kassio Borges*
2526
-
2527
- * Remove deprecated behavior allowing nested arrays to be passed as query
2528
- values.
2529
-
2530
- *Melanie Gilman*
2531
-
2532
- * Deprecate passing a class as a value in a query. Users should pass strings
2533
- instead.
2534
-
2535
- *Melanie Gilman*
2536
-
2537
- * `add_timestamps` and `remove_timestamps` now properly reversible with
2538
- options.
2539
-
2540
- *Noam Gagliardi-Rabinovich*
2541
-
2542
- * `ActiveRecord::ConnectionAdapters::ColumnDumper#column_spec` and
2543
- `ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
2544
- longer have a `types` argument. They should access
2545
- `connection#native_database_types` directly.
2546
-
2547
- *Yves Senn*
2548
685
 
2549
- Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.
686
+ Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activerecord/CHANGELOG.md) for previous changes.