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