activerecord 4.2.11.3 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1029 -1349
- data/MIT-LICENSE +1 -1
- data/README.rdoc +6 -7
- data/examples/performance.rb +2 -2
- data/lib/active_record.rb +7 -3
- data/lib/active_record/aggregations.rb +35 -25
- data/lib/active_record/association_relation.rb +2 -2
- data/lib/active_record/associations.rb +305 -204
- data/lib/active_record/associations/alias_tracker.rb +19 -16
- data/lib/active_record/associations/association.rb +10 -8
- data/lib/active_record/associations/association_scope.rb +73 -102
- data/lib/active_record/associations/belongs_to_association.rb +20 -32
- data/lib/active_record/associations/builder/association.rb +28 -34
- data/lib/active_record/associations/builder/belongs_to.rb +41 -18
- data/lib/active_record/associations/builder/collection_association.rb +8 -24
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +11 -11
- data/lib/active_record/associations/builder/has_many.rb +4 -4
- data/lib/active_record/associations/builder/has_one.rb +10 -5
- data/lib/active_record/associations/builder/singular_association.rb +2 -9
- data/lib/active_record/associations/collection_association.rb +40 -43
- data/lib/active_record/associations/collection_proxy.rb +55 -29
- data/lib/active_record/associations/foreign_association.rb +1 -1
- data/lib/active_record/associations/has_many_association.rb +20 -71
- data/lib/active_record/associations/has_many_through_association.rb +8 -52
- data/lib/active_record/associations/has_one_association.rb +12 -5
- data/lib/active_record/associations/join_dependency.rb +28 -18
- data/lib/active_record/associations/join_dependency/join_association.rb +13 -12
- data/lib/active_record/associations/preloader.rb +13 -4
- data/lib/active_record/associations/preloader/association.rb +45 -51
- data/lib/active_record/associations/preloader/collection_association.rb +0 -6
- 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/through_association.rb +5 -4
- data/lib/active_record/associations/singular_association.rb +6 -0
- data/lib/active_record/associations/through_association.rb +11 -3
- data/lib/active_record/attribute.rb +61 -17
- data/lib/active_record/attribute/user_provided_default.rb +23 -0
- data/lib/active_record/attribute_assignment.rb +27 -140
- data/lib/active_record/attribute_decorators.rb +6 -5
- data/lib/active_record/attribute_methods.rb +79 -26
- 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 +2 -2
- data/lib/active_record/attribute_methods/query.rb +2 -2
- data/lib/active_record/attribute_methods/read.rb +26 -42
- data/lib/active_record/attribute_methods/serialization.rb +13 -16
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +42 -9
- data/lib/active_record/attribute_methods/write.rb +13 -24
- data/lib/active_record/attribute_mutation_tracker.rb +70 -0
- data/lib/active_record/attribute_set.rb +30 -3
- data/lib/active_record/attribute_set/builder.rb +6 -4
- data/lib/active_record/attributes.rb +194 -81
- data/lib/active_record/autosave_association.rb +33 -15
- data/lib/active_record/base.rb +30 -18
- data/lib/active_record/callbacks.rb +36 -40
- data/lib/active_record/coders/yaml_column.rb +20 -8
- data/lib/active_record/collection_cache_key.rb +31 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +431 -122
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +3 -3
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +40 -22
- data/lib/active_record/connection_adapters/abstract/quoting.rb +62 -8
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +46 -38
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +229 -185
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +52 -13
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +275 -115
- data/lib/active_record/connection_adapters/abstract/transaction.rb +32 -33
- data/lib/active_record/connection_adapters/abstract_adapter.rb +83 -32
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +384 -221
- data/lib/active_record/connection_adapters/column.rb +27 -41
- data/lib/active_record/connection_adapters/connection_specification.rb +2 -21
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +22 -0
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +57 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +69 -0
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +59 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +22 -101
- data/lib/active_record/connection_adapters/postgresql/column.rb +6 -10
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +3 -3
- data/lib/active_record/connection_adapters/postgresql/oid.rb +1 -6
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +23 -57
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +7 -22
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +3 -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 -2
- 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 +23 -16
- 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 +18 -11
- 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 +54 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +174 -128
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +35 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +184 -112
- 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/schema_creation.rb +15 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +134 -110
- data/lib/active_record/connection_adapters/statement_pool.rb +28 -11
- data/lib/active_record/connection_handling.rb +5 -5
- data/lib/active_record/core.rb +72 -104
- data/lib/active_record/counter_cache.rb +9 -20
- data/lib/active_record/dynamic_matchers.rb +1 -20
- data/lib/active_record/enum.rb +110 -76
- data/lib/active_record/errors.rb +72 -47
- 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 +19 -4
- data/lib/active_record/fixtures.rb +76 -40
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +27 -40
- data/lib/active_record/integration.rb +4 -4
- 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 +10 -14
- data/lib/active_record/locking/pessimistic.rb +1 -1
- data/lib/active_record/log_subscriber.rb +40 -22
- data/lib/active_record/migration.rb +304 -133
- data/lib/active_record/migration/command_recorder.rb +59 -18
- data/lib/active_record/migration/compatibility.rb +90 -0
- data/lib/active_record/model_schema.rb +92 -40
- data/lib/active_record/nested_attributes.rb +45 -34
- data/lib/active_record/null_relation.rb +15 -7
- data/lib/active_record/persistence.rb +112 -72
- data/lib/active_record/querying.rb +6 -5
- data/lib/active_record/railtie.rb +20 -13
- data/lib/active_record/railties/controller_runtime.rb +1 -1
- data/lib/active_record/railties/databases.rake +47 -38
- data/lib/active_record/readonly_attributes.rb +1 -1
- data/lib/active_record/reflection.rb +182 -57
- data/lib/active_record/relation.rb +152 -100
- data/lib/active_record/relation/batches.rb +133 -33
- data/lib/active_record/relation/batches/batch_enumerator.rb +67 -0
- data/lib/active_record/relation/calculations.rb +80 -101
- data/lib/active_record/relation/delegation.rb +6 -19
- data/lib/active_record/relation/finder_methods.rb +58 -46
- data/lib/active_record/relation/from_clause.rb +32 -0
- data/lib/active_record/relation/merger.rb +13 -42
- data/lib/active_record/relation/predicate_builder.rb +99 -105
- data/lib/active_record/relation/predicate_builder/array_handler.rb +11 -16
- data/lib/active_record/relation/predicate_builder/association_query_handler.rb +78 -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/range_handler.rb +17 -0
- data/lib/active_record/relation/query_attribute.rb +19 -0
- data/lib/active_record/relation/query_methods.rb +274 -238
- data/lib/active_record/relation/record_fetch_warning.rb +51 -0
- data/lib/active_record/relation/spawn_methods.rb +3 -6
- data/lib/active_record/relation/where_clause.rb +173 -0
- data/lib/active_record/relation/where_clause_factory.rb +37 -0
- data/lib/active_record/result.rb +4 -3
- data/lib/active_record/runtime_registry.rb +1 -1
- data/lib/active_record/sanitization.rb +94 -65
- data/lib/active_record/schema.rb +23 -22
- data/lib/active_record/schema_dumper.rb +33 -22
- data/lib/active_record/schema_migration.rb +10 -4
- data/lib/active_record/scoping.rb +17 -6
- data/lib/active_record/scoping/default.rb +19 -6
- data/lib/active_record/scoping/named.rb +39 -28
- data/lib/active_record/secure_token.rb +38 -0
- data/lib/active_record/serialization.rb +2 -4
- data/lib/active_record/statement_cache.rb +15 -13
- data/lib/active_record/store.rb +8 -3
- data/lib/active_record/suppressor.rb +54 -0
- data/lib/active_record/table_metadata.rb +64 -0
- data/lib/active_record/tasks/database_tasks.rb +30 -40
- data/lib/active_record/tasks/mysql_database_tasks.rb +7 -15
- data/lib/active_record/tasks/postgresql_database_tasks.rb +11 -2
- data/lib/active_record/tasks/sqlite_database_tasks.rb +5 -1
- data/lib/active_record/timestamp.rb +16 -9
- data/lib/active_record/touch_later.rb +58 -0
- data/lib/active_record/transactions.rb +138 -56
- 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 +9 -14
- data/lib/active_record/type/time.rb +3 -21
- 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 +24 -0
- data/lib/active_record/validations/associated.rb +10 -3
- data/lib/active_record/validations/length.rb +36 -0
- data/lib/active_record/validations/presence.rb +12 -12
- data/lib/active_record/validations/uniqueness.rb +24 -21
- data/lib/rails/generators/active_record/migration.rb +7 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +7 -4
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +8 -3
- data/lib/rails/generators/active_record/migration/templates/migration.rb +4 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +21 -15
- data/lib/rails/generators/active_record/model/templates/model.rb +3 -0
- metadata +50 -35
- 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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e133ed5dfb51d14f02b6c9500a2d6ef12ff3e44
|
4
|
+
data.tar.gz: f2c8ed50961369f794784c36333255503f35fee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7564870b045ef432c7e34f3633ae3dce0e555727226453144cda406999f0061d5ba663cac60c4b53f390228c33a785ea47a9bda9511e5d699a1cbce61892cb8e
|
7
|
+
data.tar.gz: 71237455c5267cb825c34ea0a450e79efa57a757ffc90a2bff1c5965ab9bbef668f323ebbbc4f51ec8a354fac9dff3a13076a49791069ad0410a57f3a7c2f194
|
data/CHANGELOG.md
CHANGED
@@ -1,183 +1,219 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 5.0.0.beta1 (December 18, 2015) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
* Order the result of `find(ids)` to match the passed array, if the relation
|
7
|
+
has no explicit order defined.
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 4.2.11.1 (March 11, 2019) ##
|
12
|
-
|
13
|
-
* No changes.
|
14
|
-
|
15
|
-
|
16
|
-
## Rails 4.2.11 (November 27, 2018) ##
|
17
|
-
|
18
|
-
* No changes.
|
9
|
+
Fixes #20338.
|
19
10
|
|
11
|
+
*Miguel Grazziotin*, *Matthew Draper*
|
20
12
|
|
21
|
-
|
13
|
+
* Omit default limit values in dumped schema. It's tidier, and if the defaults
|
14
|
+
change in the future, we can address that via Migration API Versioning.
|
22
15
|
|
23
|
-
*
|
24
|
-
`current_scope`, with the exception of `unscoped`.
|
16
|
+
*Jean Boussier*
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
* Support passing the schema name as a prefix to table name in
|
19
|
+
`ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
|
20
|
+
be considered a full part of the index name, and only the schema in the
|
21
|
+
current search path would be considered.
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
* Fix regression caused by `collection_singular_ids=` ignoring different primary key on relationship.
|
23
|
+
*Grey Baker*
|
33
24
|
|
34
|
-
|
25
|
+
* Ignore index name in `index_exists?` and `remove_index` when not passed a
|
26
|
+
name to check for.
|
35
27
|
|
36
|
-
*
|
28
|
+
*Grey Baker*
|
37
29
|
|
38
|
-
|
30
|
+
* Extract support for the legacy `mysql` database adapter from core. It will
|
31
|
+
live on in a separate gem for now, but most users should just use `mysql2`.
|
39
32
|
|
40
|
-
*
|
33
|
+
*Abdelkader Boudih*
|
41
34
|
|
42
|
-
|
35
|
+
* ApplicationRecord is a new superclass for all app models, analogous to app
|
36
|
+
controllers subclassing ApplicationController instead of
|
37
|
+
ActionController::Base. This gives apps a single spot to configure app-wide
|
38
|
+
model behavior.
|
43
39
|
|
44
|
-
|
40
|
+
Newly generated applications have `app/models/application_record.rb`
|
41
|
+
present by default.
|
45
42
|
|
46
|
-
*
|
43
|
+
*Genadi Samokovarov*
|
47
44
|
|
48
|
-
*
|
45
|
+
* Version the API presented to migration classes, so we can change parameter
|
46
|
+
defaults without breaking existing migrations, or forcing them to be
|
47
|
+
rewritten through a deprecation cycle.
|
49
48
|
|
50
|
-
|
49
|
+
*Matthew Draper*, *Ravil Bayramgalin*
|
51
50
|
|
52
|
-
|
51
|
+
* Use bind params for `limit` and `offset`. This will generate significantly
|
52
|
+
fewer prepared statements for common tasks like pagination. To support this
|
53
|
+
change, passing a string containing a comma to `limit` has been deprecated,
|
54
|
+
and passing an Arel node to `limit` is no longer supported.
|
53
55
|
|
54
|
-
|
55
|
-
so queries are not run against the previous table name.
|
56
|
+
Fixes #22250
|
56
57
|
|
57
|
-
*
|
58
|
+
*Sean Griffin*
|
58
59
|
|
60
|
+
* Introduce after_{create,update,delete}_commit callbacks.
|
59
61
|
|
60
|
-
|
62
|
+
Before:
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
+
after_commit :add_to_index_later, on: :create
|
65
|
+
after_commit :update_in_index_later, on: :update
|
66
|
+
after_commit :remove_from_index_later, on: :destroy
|
64
67
|
|
65
|
-
|
68
|
+
After:
|
66
69
|
|
67
|
-
|
70
|
+
after_create_commit :add_to_index_later
|
71
|
+
after_update_commit :update_in_index_later
|
72
|
+
after_destroy_commit :remove_from_index_later
|
68
73
|
|
69
|
-
|
74
|
+
Fixes #22515.
|
70
75
|
|
71
|
-
*
|
76
|
+
*Genadi Samokovarov*
|
72
77
|
|
73
|
-
|
78
|
+
* Respect the column default values for `inheritance_column` when
|
79
|
+
instantiating records through the base class.
|
74
80
|
|
75
|
-
|
81
|
+
Fixes #17121.
|
76
82
|
|
77
|
-
|
83
|
+
Example:
|
78
84
|
|
79
|
-
|
85
|
+
# The schema of BaseModel has `t.string :type, default: 'SubType'`
|
86
|
+
subtype = BaseModel.new
|
87
|
+
assert_equals SubType, subtype.class
|
80
88
|
|
81
|
-
*
|
89
|
+
*Kuldeep Aggarwal*
|
82
90
|
|
83
|
-
*
|
84
|
-
mapping methods are methods implemented on `Hash`.
|
91
|
+
* Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
|
85
92
|
|
86
|
-
Fixes #
|
93
|
+
Fixes #22346.
|
87
94
|
|
88
|
-
*
|
95
|
+
*Nick Muerdter*, *ckoenig*
|
89
96
|
|
97
|
+
* Add schema dumping support for PostgreSQL geometric data types.
|
90
98
|
|
91
|
-
|
99
|
+
*Ryuta Kamizono*
|
92
100
|
|
93
|
-
*
|
94
|
-
truncates the array, preventing `inspect` from looping infinitely in some
|
95
|
-
cases.
|
101
|
+
* Except keys of `build_record`'s argument from `create_scope` in `initialize_attributes`.
|
96
102
|
|
97
|
-
|
103
|
+
Fixes #21893.
|
98
104
|
|
99
|
-
*
|
100
|
-
Fixes #25210.
|
105
|
+
*Yuichiro Kaneko*
|
101
106
|
|
102
|
-
|
107
|
+
* Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
|
108
|
+
Also deprecate passing arguments to `#tables`.
|
109
|
+
And deprecate `table_exists?`.
|
103
110
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
have conflicts in projection.
|
111
|
+
The `#tables` method of some adapters (mysql, mysql2, sqlite3) would return
|
112
|
+
both tables and views while others (postgresql) just return tables. To make
|
113
|
+
their behavior consistent, `#tables` will return only tables in the future.
|
108
114
|
|
109
|
-
|
115
|
+
The `#table_exists?` method would check both tables and views. To make
|
116
|
+
their behavior consistent with `#tables`, `#table_exists?` will check only
|
117
|
+
tables in the future.
|
110
118
|
|
111
|
-
*
|
112
|
-
are specified or an ActiveRecord::StatementInvalid when an invalid type
|
113
|
-
is provided for a column name (e.g. a Hash).
|
119
|
+
*Yuichiro Kaneko*
|
114
120
|
|
115
|
-
|
121
|
+
* Improve support for non Active Record objects on `validates_associated`
|
116
122
|
|
117
|
-
|
123
|
+
Skipping `marked_for_destruction?` when the associated object does not responds
|
124
|
+
to it make easier to validate virtual associations built on top of Active Model
|
125
|
+
objects and/or serialized objects that implement a `valid?` instance method.
|
118
126
|
|
119
|
-
*
|
127
|
+
*Kassio Borges*, *Lucas Mazza*
|
120
128
|
|
121
|
-
|
129
|
+
* Change connection management middleware to return a new response with
|
130
|
+
a body proxy, rather than mutating the original.
|
122
131
|
|
123
|
-
*
|
132
|
+
*Kevin Buchanan*
|
124
133
|
|
134
|
+
* Make `db:migrate:status` to render `1_some.rb` format migrate files.
|
125
135
|
|
126
|
-
|
136
|
+
These files are in `db/migrate`:
|
127
137
|
|
128
|
-
*
|
129
|
-
|
138
|
+
* 1_valid_people_have_last_names.rb
|
139
|
+
* 20150819202140_irreversible_migration.rb
|
140
|
+
* 20150823202140_add_admin_flag_to_users.rb
|
141
|
+
* 20150823202141_migration_tests.rb
|
142
|
+
* 2_we_need_reminders.rb
|
143
|
+
* 3_innocent_jointable.rb
|
130
144
|
|
131
|
-
|
145
|
+
Before:
|
132
146
|
|
133
|
-
|
134
|
-
|
147
|
+
$ bundle exec rake db:migrate:status
|
148
|
+
...
|
135
149
|
|
136
|
-
|
150
|
+
Status Migration ID Migration Name
|
151
|
+
--------------------------------------------------
|
152
|
+
up 001 ********** NO FILE **********
|
153
|
+
up 002 ********** NO FILE **********
|
154
|
+
up 003 ********** NO FILE **********
|
155
|
+
up 20150819202140 Irreversible migration
|
156
|
+
up 20150823202140 Add admin flag to users
|
157
|
+
up 20150823202141 Migration tests
|
137
158
|
|
138
|
-
|
159
|
+
After:
|
139
160
|
|
140
|
-
|
161
|
+
$ bundle exec rake db:migrate:status
|
162
|
+
...
|
141
163
|
|
142
|
-
|
164
|
+
Status Migration ID Migration Name
|
165
|
+
--------------------------------------------------
|
166
|
+
up 001 Valid people have last names
|
167
|
+
up 002 We need reminders
|
168
|
+
up 003 Innocent jointable
|
169
|
+
up 20150819202140 Irreversible migration
|
170
|
+
up 20150823202140 Add admin flag to users
|
171
|
+
up 20150823202141 Migration tests
|
143
172
|
|
144
|
-
*
|
173
|
+
*Yuichiro Kaneko*
|
145
174
|
|
146
|
-
|
175
|
+
* Define `ActiveRecord::Sanitization.sanitize_sql_for_order` and use it inside
|
176
|
+
`preprocess_order_args`.
|
147
177
|
|
148
|
-
*
|
178
|
+
*Yuichiro Kaneko*
|
149
179
|
|
150
|
-
*
|
151
|
-
These methods determine what relations can be used to back Active Record
|
152
|
-
models (usually tables and views).
|
180
|
+
* Allow bigint with default nil for avoiding auto increment primary key.
|
153
181
|
|
154
|
-
*
|
182
|
+
*Ryuta Kamizono*
|
155
183
|
|
184
|
+
* Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`.
|
156
185
|
|
157
|
-
|
186
|
+
We should omit the collation entirely rather than providing a default.
|
187
|
+
Then the choice is the responsibility of the server and MySQL distribution.
|
158
188
|
|
159
|
-
*
|
189
|
+
*Ryuta Kamizono*
|
160
190
|
|
191
|
+
* Alias `ActiveRecord::Relation#left_joins` to
|
192
|
+
`ActiveRecord::Relation#left_outer_joins`.
|
161
193
|
|
162
|
-
|
194
|
+
*Takashi Kokubun*
|
163
195
|
|
164
|
-
*
|
196
|
+
* Use advisory locking to raise a `ConcurrentMigrationError` instead of
|
197
|
+
attempting to migrate when another migration is currently running.
|
165
198
|
|
199
|
+
*Sam Davies*
|
166
200
|
|
167
|
-
|
201
|
+
* Added `ActiveRecord::Relation#left_outer_joins`.
|
168
202
|
|
169
|
-
|
203
|
+
Example:
|
170
204
|
|
171
|
-
|
205
|
+
User.left_outer_joins(:posts)
|
206
|
+
# => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON
|
207
|
+
"posts"."user_id" = "users"."id"
|
172
208
|
|
173
|
-
*
|
209
|
+
*Florian Thomas*
|
174
210
|
|
175
|
-
|
211
|
+
* Support passing an array to `order` for SQL parameter sanitization.
|
176
212
|
|
177
|
-
*
|
213
|
+
*Aaron Suggs*
|
178
214
|
|
179
215
|
* Avoid disabling errors on the PostgreSQL connection when enabling the
|
180
|
-
standard_conforming_strings setting. Errors were previously disabled because
|
216
|
+
`standard_conforming_strings` setting. Errors were previously disabled because
|
181
217
|
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
|
182
218
|
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
|
183
219
|
setting exists. Disabling errors caused problems when using a connection
|
@@ -189,1855 +225,1499 @@
|
|
189
225
|
|
190
226
|
*Harry Marr*
|
191
227
|
|
192
|
-
*
|
193
|
-
only instantiates one HABTM object because the join table hasn't a primary key.
|
194
|
-
|
195
|
-
Fixes #16032.
|
196
|
-
|
197
|
-
Examples:
|
198
|
-
|
199
|
-
before:
|
200
|
-
|
201
|
-
Project.first.salaried_developers.size # => 3
|
202
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
203
|
-
|
204
|
-
after:
|
205
|
-
|
206
|
-
Project.first.salaried_developers.size # => 3
|
207
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
208
|
-
|
209
|
-
*Bigxiang*
|
210
|
-
|
211
|
-
* Descriptive error message when fixtures contain a missing column.
|
212
|
-
|
213
|
-
Closes #21201.
|
214
|
-
|
215
|
-
*Yves Senn*
|
216
|
-
|
217
|
-
* `bin/rake db:migrate` uses
|
218
|
-
`ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
|
219
|
-
`Migrator.migrations_paths`.
|
220
|
-
|
221
|
-
*Tobias Bielohlawek*
|
222
|
-
|
223
|
-
* Fix `rewhere` in a `has_many` association.
|
224
|
-
|
225
|
-
Fixes #21955.
|
226
|
-
|
227
|
-
*Josh Branchaud*, *Kal*
|
228
|
-
|
229
|
-
* Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
|
230
|
-
drying up Kernel.system() calls within this namespace and to avoid
|
231
|
-
shell expansion by using a paramter list instead of string as arguments
|
232
|
-
for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
|
233
|
-
test units passing.
|
234
|
-
|
235
|
-
*Bryan Paxton*
|
236
|
-
|
237
|
-
* Avoid leaking the first relation we call `first` on, per model.
|
238
|
-
|
239
|
-
Fixes #21921.
|
240
|
-
|
241
|
-
*Matthew Draper*, *Jean Boussier*
|
242
|
-
|
243
|
-
* Allow deserialization of Active Record models that were YAML encoded prior
|
244
|
-
to Rails 4.2
|
245
|
-
|
246
|
-
*Sean Griffin*
|
247
|
-
|
248
|
-
* Correctly apply `unscope` when preloading through associations.
|
249
|
-
|
250
|
-
*Jimmy Bourassa*
|
251
|
-
|
252
|
-
* Ensure `select` quotes aliased attributes, even when using `from`.
|
253
|
-
|
254
|
-
Fixes #21488
|
255
|
-
|
256
|
-
*Sean Griffin & @johanlunds*
|
257
|
-
|
258
|
-
* Correct query for PostgreSQL 8.2 compatibility.
|
259
|
-
|
260
|
-
*Ben Murphy*, *Matthew Draper*
|
261
|
-
|
262
|
-
* Uniqueness validator raises descriptive error when running on a persisted
|
263
|
-
record without primary key.
|
264
|
-
|
265
|
-
Closes #21304.
|
266
|
-
|
267
|
-
*Yves Senn*
|
268
|
-
|
269
|
-
|
270
|
-
## Rails 4.2.4 (August 24, 2015) ##
|
271
|
-
|
272
|
-
* Skip statement cache on through association reader.
|
273
|
-
|
274
|
-
If the through class has default scopes we should skip the statement
|
275
|
-
cache.
|
276
|
-
|
277
|
-
Closes #20745.
|
278
|
-
|
279
|
-
*Rafael Mendonça França*
|
280
|
-
|
281
|
-
* Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
|
282
|
-
the limit: 8 was not coming through. This caused it to become Int[] data type
|
283
|
-
after doing a rebuild off of schema.rb.
|
284
|
-
|
285
|
-
*Jake Waller*
|
286
|
-
|
287
|
-
* Fix state being carried over from previous transaction.
|
288
|
-
|
289
|
-
Considering the following example where `name` is a required attribute.
|
290
|
-
Before we had `new_record?` returning `true` for a persisted record:
|
291
|
-
|
292
|
-
author = Author.create! name: 'foo'
|
293
|
-
author.name = nil
|
294
|
-
author.save # => false
|
295
|
-
author.new_record? # => true
|
296
|
-
|
297
|
-
Fixes #20824.
|
298
|
-
|
299
|
-
*Roque Pinel*
|
300
|
-
|
301
|
-
* Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
|
302
|
-
when validating associations.
|
303
|
-
|
304
|
-
Fixes #20882.
|
305
|
-
|
306
|
-
*Sean Griffin*
|
307
|
-
|
308
|
-
* Fix through associations using scopes having the scope merged multiple
|
309
|
-
times.
|
310
|
-
|
311
|
-
Fixes #20721.
|
312
|
-
Fixes #20727.
|
313
|
-
|
314
|
-
*Sean Griffin*
|
315
|
-
|
316
|
-
* `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
|
317
|
-
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
228
|
+
* Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
|
318
229
|
|
319
|
-
Fixes #
|
320
|
-
|
321
|
-
*Yves Senn*
|
322
|
-
|
323
|
-
* Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
|
324
|
-
a wrong type to a namespaced association.
|
325
|
-
|
326
|
-
Fixes #20545.
|
327
|
-
|
328
|
-
*Diego Carrion*
|
329
|
-
|
330
|
-
* Prevent error when using `force_reload: true` on an unassigned polymorphic
|
331
|
-
belongs_to association.
|
332
|
-
|
333
|
-
Fixes #20426.
|
334
|
-
|
335
|
-
*James Dabbs*
|
336
|
-
|
337
|
-
|
338
|
-
## Rails 4.2.3 (June 25, 2015) ##
|
339
|
-
|
340
|
-
* Let `WITH` queries (Common Table Expressions) be explainable.
|
341
|
-
|
342
|
-
*Vladimir Kochnev*
|
343
|
-
|
344
|
-
* Fix n+1 query problem when eager loading nil associations (fixes #18312)
|
345
|
-
|
346
|
-
*Sammy Larbi*
|
347
|
-
|
348
|
-
* Fixed an error which would occur in dirty checking when calling
|
349
|
-
`update_attributes` from a getter.
|
350
|
-
|
351
|
-
Fixes #20531.
|
352
|
-
|
353
|
-
*Sean Griffin*
|
354
|
-
|
355
|
-
* Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
|
356
|
-
as columns.
|
357
|
-
|
358
|
-
Fixes #20360.
|
359
|
-
|
360
|
-
*Sean Griffin*
|
361
|
-
|
362
|
-
* Clear query cache when `ActiveRecord::Base#reload` is called.
|
363
|
-
|
364
|
-
*Shane Hender*
|
365
|
-
|
366
|
-
* Pass `:extend` option for `has_and_belongs_to_many` associations to the
|
367
|
-
underlying `has_many :through`.
|
368
|
-
|
369
|
-
*Jaehyun Shin*
|
370
|
-
|
371
|
-
* Make `unscope` aware of "less than" and "greater than" conditions.
|
372
|
-
|
373
|
-
*TAKAHASHI Kazuaki*
|
374
|
-
|
375
|
-
* Revert behavior of `db:schema:load` back to loading the full
|
376
|
-
environment. This ensures that initializers are run.
|
377
|
-
|
378
|
-
Fixes #19545.
|
379
|
-
|
380
|
-
*Yves Senn*
|
381
|
-
|
382
|
-
* Fix missing index when using `timestamps` with the `index` option.
|
383
|
-
|
384
|
-
The `index` option used with `timestamps` should be passed to both
|
385
|
-
`column` definitions for `created_at` and `updated_at` rather than just
|
386
|
-
the first.
|
387
|
-
|
388
|
-
*Paul Mucur*
|
389
|
-
|
390
|
-
* Rename `:class` to `:anonymous_class` in association options.
|
391
|
-
|
392
|
-
Fixes #19659.
|
393
|
-
|
394
|
-
*Andrew White*
|
395
|
-
|
396
|
-
* Fixed a bug where uniqueness validations would error on out of range values,
|
397
|
-
even if an validation should have prevented it from hitting the database.
|
398
|
-
|
399
|
-
*Andrey Voronkov*
|
400
|
-
|
401
|
-
* Foreign key related methods in the migration DSL respect
|
402
|
-
`ActiveRecord::Base.pluralize_table_names = false`.
|
403
|
-
|
404
|
-
Fixes #19643.
|
405
|
-
|
406
|
-
*Mehmet Emin İNAÇ*
|
407
|
-
|
408
|
-
* Reduce memory usage from loading types on pg.
|
409
|
-
|
410
|
-
Fixes #19578.
|
411
|
-
|
412
|
-
*Sean Griffin*
|
413
|
-
|
414
|
-
* Fix referencing wrong table aliases while joining tables of has many through
|
415
|
-
association (only when calling calculation methods).
|
416
|
-
|
417
|
-
Fixes #19276.
|
418
|
-
|
419
|
-
*pinglamb*
|
420
|
-
|
421
|
-
* Don't attempt to update counter caches, when the column wasn't selected.
|
422
|
-
|
423
|
-
Fixes #19437.
|
424
|
-
|
425
|
-
*Sean Griffin*
|
426
|
-
|
427
|
-
* Correctly persist a serialized attribute that has been returned to
|
428
|
-
its default value by an in-place modification.
|
429
|
-
|
430
|
-
Fixes #19467.
|
431
|
-
|
432
|
-
*Matthew Draper*
|
433
|
-
|
434
|
-
* Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
|
435
|
-
|
436
|
-
*James Cox*
|
437
|
-
|
438
|
-
* Dont enroll records in the transaction if they dont have commit callbacks.
|
439
|
-
That was causing a memory grow problem when creating a lot of records inside a transaction.
|
440
|
-
|
441
|
-
Fixes #15549.
|
442
|
-
|
443
|
-
*Will Bryant*, *Aaron Patterson*
|
444
|
-
|
445
|
-
* Correctly create through records when created on a has many through
|
446
|
-
association when using `where`.
|
447
|
-
|
448
|
-
Fixes #19073.
|
449
|
-
|
450
|
-
*Sean Griffin*
|
451
|
-
|
452
|
-
|
453
|
-
## Rails 4.2.2 (June 16, 2015) ##
|
454
|
-
|
455
|
-
* No Changes *
|
456
|
-
|
457
|
-
|
458
|
-
## Rails 4.2.1 (March 19, 2015) ##
|
459
|
-
|
460
|
-
* Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
|
461
|
-
|
462
|
-
Fixes #17139.
|
463
|
-
|
464
|
-
*Miklos Fazekas*
|
465
|
-
|
466
|
-
* `remove_reference` with `foreign_key: true` removes the foreign key before
|
467
|
-
removing the column. This fixes a bug where it was not possible to remove
|
468
|
-
the column on MySQL.
|
469
|
-
|
470
|
-
Fixes #18664.
|
471
|
-
|
472
|
-
*Yves Senn*
|
473
|
-
|
474
|
-
* Add a `:foreign_key` option to `references` and associated migration
|
475
|
-
methods. The model and migration generators now use this option, rather than
|
476
|
-
the `add_foreign_key` form.
|
477
|
-
|
478
|
-
*Sean Griffin*
|
479
|
-
|
480
|
-
* Fix rounding problem for PostgreSQL timestamp column.
|
481
|
-
|
482
|
-
If timestamp column have the precision, it need to format according to
|
483
|
-
the precision of timestamp column.
|
484
|
-
|
485
|
-
*Ryuta Kamizono*
|
486
|
-
|
487
|
-
* Respect the database default charset for `schema_migrations` table.
|
488
|
-
|
489
|
-
The charset of `version` column in `schema_migrations` table is depend
|
490
|
-
on the database default charset and collation rather than the encoding
|
491
|
-
of the connection.
|
492
|
-
|
493
|
-
*Ryuta Kamizono*
|
494
|
-
|
495
|
-
* Respect custom primary keys for associations when calling `Relation#where`
|
496
|
-
|
497
|
-
Fixes #18813.
|
498
|
-
|
499
|
-
*Sean Griffin*
|
500
|
-
|
501
|
-
* Fixed several edge cases which could result in a counter cache updating
|
502
|
-
twice or not updating at all for `has_many` and `has_many :through`.
|
503
|
-
|
504
|
-
Fixes #10865.
|
505
|
-
|
506
|
-
*Sean Griffin*
|
507
|
-
|
508
|
-
* Foreign keys added by migrations were given random, generated names. This
|
509
|
-
meant a different `structure.sql` would be generated every time a developer
|
510
|
-
ran migrations on their machine.
|
511
|
-
|
512
|
-
The generated part of foreign key names is now a hash of the table name and
|
513
|
-
column name, which is consistent every time you run the migration.
|
514
|
-
|
515
|
-
*Chris Sinjakli*
|
516
|
-
|
517
|
-
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
518
|
-
|
519
|
-
SplitTest.group(:key).count
|
520
|
-
Property.group(:value).count
|
521
|
-
|
522
|
-
*Bogdan Gusiev*
|
523
|
-
|
524
|
-
* Don't define autosave association callbacks twice from
|
525
|
-
`accepts_nested_attributes_for`.
|
526
|
-
|
527
|
-
Fixes #18704.
|
528
|
-
|
529
|
-
*Sean Griffin*
|
530
|
-
|
531
|
-
* Integer types will no longer raise a `RangeError` when assigning an
|
532
|
-
attribute, but will instead raise when going to the database.
|
533
|
-
|
534
|
-
Fixes several vague issues which were never reported directly. See the
|
535
|
-
commit message from the commit which added this line for some examples.
|
536
|
-
|
537
|
-
*Sean Griffin*
|
538
|
-
|
539
|
-
* Values which would error while being sent to the database (such as an
|
540
|
-
ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
|
541
|
-
assignment. They will still error when sent to the database, but you are
|
542
|
-
given the ability to re-assign it to a valid value.
|
543
|
-
|
544
|
-
Fixes #18580.
|
545
|
-
|
546
|
-
*Sean Griffin*
|
547
|
-
|
548
|
-
* Don't remove join dependencies in `Relation#exists?`
|
549
|
-
|
550
|
-
Fixes #18632.
|
551
|
-
|
552
|
-
*Sean Griffin*
|
553
|
-
|
554
|
-
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
555
|
-
|
556
|
-
Fixes #18629.
|
557
|
-
|
558
|
-
*Sean Griffin*
|
559
|
-
|
560
|
-
* No longer issue deprecation warning when including a scope with extensions.
|
561
|
-
Previously every scope with extension methods was transformed into an
|
562
|
-
instance dependent scope. Including such a scope would wrongfully issue a
|
563
|
-
deprecation warning. This is no longer the case.
|
564
|
-
|
565
|
-
Fixes #18467.
|
566
|
-
|
567
|
-
*Yves Senn*
|
568
|
-
|
569
|
-
* Correctly use the type provided by `serialize` when updating records using
|
570
|
-
optimistic locking.
|
571
|
-
|
572
|
-
Fixes #18385.
|
573
|
-
|
574
|
-
*Sean Griffin*
|
575
|
-
|
576
|
-
* `attribute_will_change!` will no longer cause non-persistable attributes to
|
577
|
-
be sent to the database.
|
578
|
-
|
579
|
-
Fixes #18407.
|
580
|
-
|
581
|
-
*Sean Griffin*
|
582
|
-
|
583
|
-
* Format the datetime string according to the precision of the datetime field.
|
584
|
-
|
585
|
-
Incompatible to rounding behavior between MySQL 5.6 and earlier.
|
586
|
-
|
587
|
-
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
|
588
|
-
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
589
|
-
|
590
|
-
http://bugs.mysql.com/bug.php?id=68760
|
591
|
-
|
592
|
-
*Ryuta Kamizono*
|
593
|
-
|
594
|
-
* Allow precision option for MySQL datetimes.
|
595
|
-
|
596
|
-
*Ryuta Kamizono*
|
597
|
-
|
598
|
-
* Clear query cache on rollback.
|
599
|
-
|
600
|
-
*Florian Weingarten*
|
601
|
-
|
602
|
-
* Fixed setting of foreign_key for through associations while building of new record.
|
603
|
-
|
604
|
-
Fixes #12698.
|
605
|
-
|
606
|
-
*Ivan Antropov*
|
607
|
-
|
608
|
-
* Fixed automatic inverse_of for models nested in module.
|
609
|
-
|
610
|
-
*Andrew McCloud*
|
611
|
-
|
612
|
-
* Fix `reaping_frequency` option when the value is a string.
|
613
|
-
|
614
|
-
This usually happens when it is configured using `DATABASE_URL`.
|
615
|
-
|
616
|
-
*korbin*
|
617
|
-
|
618
|
-
* Fix error message when trying to create an associated record and the foreign
|
619
|
-
key is missing.
|
230
|
+
Fixes #21886.
|
620
231
|
|
621
|
-
|
232
|
+
*Hiroaki Izu*
|
622
233
|
|
623
|
-
|
234
|
+
* Add support for bidirectional destroy dependencies.
|
624
235
|
|
625
|
-
|
236
|
+
Fixes #13609.
|
626
237
|
|
627
|
-
|
238
|
+
Example:
|
628
239
|
|
629
|
-
|
240
|
+
class Content < ActiveRecord::Base
|
241
|
+
has_one :position, dependent: :destroy
|
242
|
+
end
|
630
243
|
|
631
|
-
|
632
|
-
|
244
|
+
class Position < ActiveRecord::Base
|
245
|
+
belongs_to :content, dependent: :destroy
|
246
|
+
end
|
633
247
|
|
634
|
-
|
248
|
+
*Seb Jacobs*
|
635
249
|
|
636
|
-
|
250
|
+
* Includes HABTM returns correct size now. It's caused by the join dependency
|
251
|
+
only instantiates one HABTM object because the join table hasn't a primary key.
|
637
252
|
|
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.
|
253
|
+
Fixes #16032.
|
642
254
|
|
643
|
-
|
255
|
+
Examples:
|
644
256
|
|
645
|
-
|
257
|
+
before:
|
646
258
|
|
647
|
-
|
259
|
+
Project.first.salaried_developers.size # => 3
|
260
|
+
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
648
261
|
|
649
|
-
|
262
|
+
after:
|
650
263
|
|
651
|
-
|
264
|
+
Project.first.salaried_developers.size # => 3
|
265
|
+
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
652
266
|
|
653
|
-
*
|
267
|
+
*Bigxiang*
|
654
268
|
|
655
|
-
|
269
|
+
* Add option to index errors in nested attributes
|
656
270
|
|
657
|
-
|
658
|
-
|
271
|
+
For models which have nested attributes, errors within those models will
|
272
|
+
now be indexed if :index_errors is specified when defining a
|
273
|
+
has_many relationship, or if its set in the global config.
|
659
274
|
|
660
|
-
|
275
|
+
Example:
|
661
276
|
|
662
|
-
|
663
|
-
|
277
|
+
class Guitar < ActiveRecord::Base
|
278
|
+
has_many :tuning_pegs
|
279
|
+
accepts_nested_attributes_for :tuning_pegs
|
280
|
+
end
|
664
281
|
|
665
|
-
|
282
|
+
class TuningPeg < ActiveRecord::Base
|
283
|
+
belongs_to :guitar
|
284
|
+
validates_numericality_of :pitch
|
285
|
+
end
|
666
286
|
|
667
|
-
|
287
|
+
# Old style
|
288
|
+
guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
|
668
289
|
|
290
|
+
# New style (if defined globally, or set in has_many_relationship)
|
291
|
+
guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]
|
669
292
|
|
670
|
-
|
293
|
+
*Michael Probber*, *Terence Sun*
|
671
294
|
|
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.
|
295
|
+
* Exit with non-zero status for failed database rake tasks.
|
676
296
|
|
677
|
-
*
|
297
|
+
*Jay Hayes*
|
678
298
|
|
679
|
-
*
|
680
|
-
|
681
|
-
`
|
299
|
+
* Queries such as `Computer.joins(:monitor).group(:status).count` will now be
|
300
|
+
interpreted as `Computer.joins(:monitor).group('computers.status').count`
|
301
|
+
so that when `Computer` and `Monitor` have both `status` columns we don't
|
302
|
+
have conflicts in projection.
|
682
303
|
|
683
|
-
|
304
|
+
*Rafael Sales*
|
684
305
|
|
685
|
-
|
306
|
+
* Add ability to default to `uuid` as primary key when generating database migrations.
|
686
307
|
|
687
|
-
|
308
|
+
Example:
|
688
309
|
|
689
|
-
|
310
|
+
config.generators do |g|
|
311
|
+
g.orm :active_record, primary_key_type: :uuid
|
312
|
+
end
|
690
313
|
|
691
|
-
*
|
314
|
+
*Jon McCartie*
|
692
315
|
|
693
|
-
|
316
|
+
* Don't cache arguments in `#find_by` if they are an `ActiveRecord::Relation`.
|
694
317
|
|
695
|
-
|
318
|
+
Fixes #20817
|
696
319
|
|
697
|
-
*
|
698
|
-
options.
|
320
|
+
*Hiroaki Izu*
|
699
321
|
|
700
|
-
|
322
|
+
* Qualify column name inserted by `group` in calculation.
|
701
323
|
|
702
|
-
|
324
|
+
Giving `group` an unqualified column name now works, even if the relation
|
325
|
+
has `JOIN` with another table which also has a column of the name.
|
703
326
|
|
704
|
-
|
705
|
-
when a migration is rolled-back, edited and reapplied.
|
327
|
+
*Soutaro Matsumoto*
|
706
328
|
|
707
|
-
|
708
|
-
|
709
|
-
provide custom behavior after the schema has been loaded.
|
329
|
+
* Don't cache prepared statements containing an IN clause or a SQL literal, as
|
330
|
+
these queries will change often and are unlikely to have a cache hit.
|
710
331
|
|
711
|
-
|
332
|
+
*Sean Griffin*
|
712
333
|
|
713
|
-
|
334
|
+
* Fix `rewhere` in a `has_many` association.
|
714
335
|
|
715
|
-
|
336
|
+
Fixes #21955.
|
716
337
|
|
717
|
-
*
|
338
|
+
*Josh Branchaud*, *Kal*
|
718
339
|
|
719
|
-
|
340
|
+
* `where` raises ArgumentError on unsupported types.
|
720
341
|
|
721
|
-
|
342
|
+
Fixes #20473.
|
722
343
|
|
723
|
-
*
|
344
|
+
*Jake Worth*
|
724
345
|
|
725
|
-
|
346
|
+
* Add an immutable string type to help reduce memory usage for apps which do
|
347
|
+
not need mutation detection on strings.
|
726
348
|
|
727
349
|
*Sean Griffin*
|
728
350
|
|
729
|
-
*
|
351
|
+
* Give `AcriveRecord::Relation#update` its own deprecation warning when
|
352
|
+
passed an `ActiveRecord::Base` instance.
|
730
353
|
|
731
|
-
|
354
|
+
Fixes #21945.
|
732
355
|
|
733
|
-
*
|
734
|
-
conditions on the joined association.
|
356
|
+
*Ted Johansson*
|
735
357
|
|
736
|
-
|
358
|
+
* Make it possible to pass `:to_table` when adding a foreign key through
|
359
|
+
`add_reference`.
|
737
360
|
|
738
|
-
|
361
|
+
Fixes #21563.
|
739
362
|
|
740
|
-
*
|
363
|
+
*Yves Senn*
|
741
364
|
|
742
|
-
*
|
743
|
-
the owner has been saved so that the proxy is not cached without the
|
744
|
-
owner's id.
|
365
|
+
* No longer pass deprecated option `-i` to `pg_dump`.
|
745
366
|
|
746
|
-
*
|
367
|
+
*Paul Sadauskas*
|
747
368
|
|
748
|
-
* `
|
369
|
+
* Concurrent `AR::Base#increment!` and `#decrement!` on the same record
|
370
|
+
are all reflected in the database rather than overwriting each other.
|
749
371
|
|
750
|
-
*
|
372
|
+
*Bogdan Gusiev*
|
751
373
|
|
752
|
-
*
|
374
|
+
* Avoid leaking the first relation we call `first` on, per model.
|
753
375
|
|
754
|
-
Fixes #
|
376
|
+
Fixes #21921.
|
755
377
|
|
756
|
-
*
|
378
|
+
*Matthew Draper*, *Jean Boussier*
|
757
379
|
|
758
|
-
*
|
380
|
+
* Remove unused `pk_and_sequence_for` in `AbstractMysqlAdapter`.
|
759
381
|
|
760
|
-
*
|
382
|
+
*Ryuta Kamizono*
|
761
383
|
|
762
|
-
*
|
763
|
-
`Relation` for performing queries and updates is the prefered API.
|
384
|
+
* Allow fixtures files to set the model class in the YAML file itself.
|
764
385
|
|
765
|
-
|
386
|
+
To load the fixtures file `accounts.yml` as the `User` model, use:
|
766
387
|
|
767
|
-
|
768
|
-
|
388
|
+
_fixture:
|
389
|
+
model_class: User
|
390
|
+
david:
|
391
|
+
name: David
|
769
392
|
|
770
|
-
|
393
|
+
Fixes #9516.
|
771
394
|
|
772
|
-
*
|
773
|
-
in an endless loop.
|
395
|
+
*Roque Pinel*
|
774
396
|
|
775
|
-
|
397
|
+
* Don't require a database connection to load a class which uses acceptance
|
398
|
+
validations.
|
776
399
|
|
777
|
-
*
|
400
|
+
*Sean Griffin*
|
778
401
|
|
779
|
-
*
|
402
|
+
* Correctly apply `unscope` when preloading through associations.
|
780
403
|
|
781
|
-
*
|
404
|
+
*Jimmy Bourassa*
|
782
405
|
|
783
|
-
*
|
406
|
+
* Fixed taking precision into count when assigning a value to timestamp attribute.
|
784
407
|
|
785
|
-
|
408
|
+
Timestamp column can have less precision than ruby timestamp
|
409
|
+
In result in how big a fraction of a second can be stored in the
|
410
|
+
database.
|
786
411
|
|
787
|
-
* Fix `Relation.rewhere` to work with Range values.
|
788
412
|
|
789
|
-
|
413
|
+
m = Model.create!
|
414
|
+
m.created_at.usec == m.reload.created_at.usec # => false
|
415
|
+
# due to different precision in Time.now and database column
|
790
416
|
|
791
|
-
|
417
|
+
If the precision is low enough, (mysql default is 0, so it is always low
|
418
|
+
enough by default) the value changes when model is reloaded from the
|
419
|
+
database. This patch fixes that issue ensuring that any timestamp
|
420
|
+
assigned as an attribute is converted to column precision under the
|
421
|
+
attribute.
|
792
422
|
|
793
|
-
|
794
|
-
# => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
|
423
|
+
*Bogdan Gusiev*
|
795
424
|
|
796
|
-
|
425
|
+
* Introduce `connection.data_sources` and `connection.data_source_exists?`.
|
426
|
+
These methods determine what relations can be used to back Active Record
|
427
|
+
models (usually tables and views).
|
797
428
|
|
798
|
-
|
799
|
-
|
429
|
+
Also deprecate `SchemaCache#tables`, `SchemaCache#table_exists?` and
|
430
|
+
`SchemaCache#clear_table_cache!` in favor of their new data source
|
431
|
+
counterparts.
|
800
432
|
|
801
|
-
|
433
|
+
*Yves Senn*, *Matthew Draper*
|
802
434
|
|
803
|
-
|
435
|
+
* Add `ActiveRecord::Base.ignored_columns` to make some columns
|
436
|
+
invisible from Active Record.
|
804
437
|
|
805
|
-
*
|
806
|
-
management middleware.
|
438
|
+
*Jean Boussier*
|
807
439
|
|
808
|
-
|
440
|
+
* `ActiveRecord::Tasks::MySQLDatabaseTasks` fails if shellout to
|
441
|
+
mysql commands (like `mysqldump`) is not successful.
|
809
442
|
|
810
|
-
*
|
443
|
+
*Steve Mitchell*
|
811
444
|
|
812
|
-
|
445
|
+
* Ensure `select` quotes aliased attributes, even when using `from`.
|
813
446
|
|
814
|
-
|
447
|
+
Fixes #21488
|
815
448
|
|
816
|
-
*
|
449
|
+
*Sean Griffin & @johanlunds*
|
817
450
|
|
818
|
-
*
|
451
|
+
* MySQL: support `unsigned` numeric data types.
|
819
452
|
|
820
|
-
|
453
|
+
Example:
|
821
454
|
|
822
|
-
|
823
|
-
|
455
|
+
create_table :foos do |t|
|
456
|
+
t.unsigned_integer :quantity
|
457
|
+
t.unsigned_bigint :total
|
458
|
+
t.unsigned_float :percentage
|
459
|
+
t.unsigned_decimal :price, precision: 10, scale: 2
|
460
|
+
end
|
824
461
|
|
825
|
-
|
462
|
+
The `unsigned: true` option may be used for the primary key:
|
826
463
|
|
827
|
-
|
464
|
+
create_table :foos, id: :bigint, unsigned: true do |t|
|
465
|
+
…
|
466
|
+
end
|
828
467
|
|
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.
|
468
|
+
*Ryuta Kamizono*
|
834
469
|
|
835
|
-
|
470
|
+
* Add `#views` and `#view_exists?` methods on connection adapters.
|
836
471
|
|
837
|
-
*
|
838
|
-
`Comment.where(post_id: Post.none)` returned a non-empty result.
|
472
|
+
*Ryuta Kamizono*
|
839
473
|
|
840
|
-
|
474
|
+
* Correctly dump composite primary key.
|
841
475
|
|
842
|
-
|
476
|
+
Example:
|
843
477
|
|
844
|
-
|
845
|
-
|
478
|
+
create_table :barcodes, primary_key: ["region", "code"] do |t|
|
479
|
+
t.string :region
|
480
|
+
t.integer :code
|
481
|
+
end
|
846
482
|
|
847
|
-
*
|
483
|
+
*Ryuta Kamizono*
|
848
484
|
|
849
|
-
*
|
485
|
+
* Lookup the attribute name for `restrict_with_error` messages on the
|
486
|
+
model class that defines the association.
|
850
487
|
|
851
|
-
*
|
488
|
+
*kuboon*, *Ronak Jangir*
|
852
489
|
|
853
|
-
*
|
490
|
+
* Correct query for PostgreSQL 8.2 compatibility.
|
854
491
|
|
855
|
-
*
|
492
|
+
*Ben Murphy*, *Matthew Draper*
|
856
493
|
|
857
|
-
*
|
494
|
+
* `bin/rake db:migrate` uses
|
495
|
+
`ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
|
496
|
+
`Migrator.migrations_paths`.
|
858
497
|
|
859
|
-
*
|
498
|
+
*Tobias Bielohlawek*
|
860
499
|
|
861
|
-
*
|
862
|
-
has support for SQL views. Connection adapters should define this method.
|
500
|
+
* Support dropping indexes concurrently in PostgreSQL.
|
863
501
|
|
864
|
-
|
502
|
+
See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more
|
503
|
+
details.
|
865
504
|
|
866
|
-
*
|
505
|
+
*Grey Baker*
|
867
506
|
|
868
|
-
|
507
|
+
* Deprecate passing conditions to `ActiveRecord::Relation#delete_all`
|
508
|
+
and `ActiveRecord::Relation#destroy_all`.
|
869
509
|
|
870
|
-
*
|
510
|
+
*Wojciech Wnętrzak*
|
871
511
|
|
872
|
-
*
|
873
|
-
|
512
|
+
* Instantiating an AR model with `ActionController::Parameters` now raises
|
513
|
+
an `ActiveModel::ForbiddenAttributesError` if the parameters include a
|
514
|
+
`type` field that has not been explicitly permitted. Previously, the
|
515
|
+
`type` field was simply ignored in the same situation.
|
874
516
|
|
875
|
-
|
517
|
+
*Prem Sichanugrist*
|
876
518
|
|
877
|
-
|
519
|
+
* PostgreSQL, `create_schema`, `drop_schema` and `rename_table` now quote
|
520
|
+
schema names.
|
878
521
|
|
879
|
-
|
522
|
+
Fixes #21418.
|
880
523
|
|
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.
|
524
|
+
Example:
|
885
525
|
|
886
|
-
|
887
|
-
|
526
|
+
create_schema("my.schema")
|
527
|
+
# CREATE SCHEMA "my.schema";
|
888
528
|
|
889
|
-
*
|
529
|
+
*Yves Senn*
|
890
530
|
|
891
|
-
* `
|
531
|
+
* PostgreSQL, add `:if_exists` option to `#drop_schema`. This makes it
|
532
|
+
possible to drop a schema that might exist without raising an exception if
|
533
|
+
it doesn't.
|
892
534
|
|
893
535
|
*Yves Senn*
|
894
536
|
|
895
|
-
*
|
896
|
-
|
537
|
+
* Only try to nullify has_one target association if the record is persisted.
|
538
|
+
|
539
|
+
Fixes #21223.
|
897
540
|
|
898
541
|
*Agis Anastasopoulos*
|
899
542
|
|
900
|
-
|
543
|
+
* Uniqueness validator raises descriptive error when running on a persisted
|
544
|
+
record without primary key.
|
901
545
|
|
902
|
-
|
903
|
-
passed as a lambda with an arity of one.
|
546
|
+
Fixes #21304.
|
904
547
|
|
905
|
-
|
548
|
+
*Yves Senn*
|
906
549
|
|
907
|
-
|
550
|
+
* Add a native JSON data type support in MySQL.
|
908
551
|
|
909
|
-
|
552
|
+
Example:
|
910
553
|
|
911
|
-
|
554
|
+
create_table :json_data_type do |t|
|
555
|
+
t.json :settings
|
556
|
+
end
|
912
557
|
|
913
|
-
*
|
558
|
+
*Ryuta Kamizono*
|
914
559
|
|
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.
|
560
|
+
* Descriptive error message when fixtures contain a missing column.
|
919
561
|
|
920
|
-
|
562
|
+
Fixes #21201.
|
921
563
|
|
922
|
-
|
564
|
+
*Yves Senn*
|
923
565
|
|
924
|
-
|
925
|
-
|
566
|
+
* `ActiveRecord::Tasks::PostgreSQLDatabaseTasks` fail if shellout to
|
567
|
+
postgresql commands (like `pg_dump`) is not successful.
|
926
568
|
|
927
|
-
|
569
|
+
*Bryan Paxton*, *Nate Berkopec*
|
928
570
|
|
929
|
-
|
571
|
+
* Add `ActiveRecord::Relation#in_batches` to work with records and relations
|
572
|
+
in batches.
|
930
573
|
|
931
|
-
|
932
|
-
`enum`) with the same name as a global method are incorrectly overridden
|
933
|
-
when subclassing.
|
574
|
+
Available options are `of` (batch size), `load`, `begin_at`, and `end_at`.
|
934
575
|
|
935
|
-
|
576
|
+
Examples:
|
936
577
|
|
937
|
-
|
578
|
+
Person.in_batches.each_record(&:party_all_night!)
|
579
|
+
Person.in_batches.update_all(awesome: true)
|
580
|
+
Person.in_batches.delete_all
|
581
|
+
Person.in_batches.each do |relation|
|
582
|
+
relation.delete_all
|
583
|
+
sleep 10 # Throttles the delete queries
|
584
|
+
end
|
938
585
|
|
939
|
-
|
940
|
-
well.
|
586
|
+
Fixes #20933.
|
941
587
|
|
942
|
-
*
|
588
|
+
*Sina Siadat*
|
943
589
|
|
944
|
-
*
|
590
|
+
* Added methods for PostgreSQL geometric data types to use in migrations.
|
945
591
|
|
946
|
-
|
592
|
+
Example:
|
947
593
|
|
948
|
-
|
594
|
+
create_table :foo do |t|
|
595
|
+
t.line :foo_line
|
596
|
+
t.lseg :foo_lseg
|
597
|
+
t.box :foo_box
|
598
|
+
t.path :foo_path
|
599
|
+
t.polygon :foo_polygon
|
600
|
+
t.circle :foo_circle
|
601
|
+
end
|
949
602
|
|
950
|
-
*
|
603
|
+
*Mehmet Emin İNAÇ*
|
951
604
|
|
952
|
-
|
605
|
+
* Add `cache_key` to ActiveRecord::Relation.
|
953
606
|
|
954
|
-
|
607
|
+
Example:
|
955
608
|
|
956
|
-
|
609
|
+
@users = User.where("name like ?", "%Alberto%")
|
610
|
+
@users.cache_key
|
611
|
+
# => "/users/query-5942b155a43b139f2471b872ac54251f-3-20150714212107656125000"
|
957
612
|
|
958
|
-
|
613
|
+
*Alberto Fernández-Capel*
|
959
614
|
|
960
|
-
|
615
|
+
* Properly allow uniqueness validations on primary keys.
|
961
616
|
|
962
|
-
|
963
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
964
|
-
index_exists? :articles, :body, name: "idx_title" # => `true`
|
617
|
+
Fixes #20966.
|
965
618
|
|
966
|
-
|
967
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
968
|
-
index_exists? :articles, :body, name: "idx_title" # => `false`
|
619
|
+
*Sean Griffin*, *presskey*
|
969
620
|
|
970
|
-
|
621
|
+
* Don't raise an error if an association failed to destroy when `destroy` was
|
622
|
+
called on the parent (as opposed to `destroy!`).
|
971
623
|
|
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`.
|
624
|
+
Fixes #20991.
|
975
625
|
|
976
626
|
*Sean Griffin*
|
977
627
|
|
978
|
-
*
|
979
|
-
|
980
|
-
|
628
|
+
* `ActiveRecord::RecordNotFound` modified to store model name, primary_key and
|
629
|
+
id of the caller model. It allows the catcher of this exception to make
|
630
|
+
a better decision to what to do with it.
|
981
631
|
|
982
|
-
|
632
|
+
Example:
|
983
633
|
|
984
|
-
|
634
|
+
class SomeAbstractController < ActionController::Base
|
635
|
+
rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
|
985
636
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
637
|
+
private def redirect_to_404(e)
|
638
|
+
return redirect_to(posts_url) if e.model == 'Post'
|
639
|
+
raise
|
640
|
+
end
|
641
|
+
end
|
990
642
|
|
991
|
-
|
643
|
+
*Sameer Rahmani*
|
992
644
|
|
993
|
-
|
645
|
+
* Deprecate the keys for association `restrict_dependent_destroy` errors in favor
|
646
|
+
of new key names.
|
994
647
|
|
995
|
-
|
996
|
-
|
997
|
-
|
648
|
+
Previously `has_one` and `has_many` associations were using the
|
649
|
+
`one` and `many` keys respectively. Both of these keys have special
|
650
|
+
meaning in I18n (they are considered to be pluralizations) so by
|
651
|
+
renaming them to `has_one` and `has_many` we make the messages more explicit
|
652
|
+
and most importantly they don't clash with linguistical systems that need to
|
653
|
+
validate translation keys (and their pluralizations).
|
998
654
|
|
999
|
-
|
655
|
+
The `:'restrict_dependent_destroy.one'` key should be replaced with
|
656
|
+
`:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'`
|
657
|
+
with `:'restrict_dependent_destroy.has_many'`.
|
1000
658
|
|
1001
|
-
*
|
1002
|
-
schema format.
|
659
|
+
*Roque Pinel*, *Christopher Dell*
|
1003
660
|
|
1004
|
-
|
661
|
+
* Fix state being carried over from previous transaction.
|
1005
662
|
|
1006
|
-
|
663
|
+
Considering the following example where `name` is a required attribute.
|
664
|
+
Before we had `new_record?` returning `true` for a persisted record:
|
665
|
+
|
666
|
+
author = Author.create! name: 'foo'
|
667
|
+
author.name = nil
|
668
|
+
author.save # => false
|
669
|
+
author.new_record? # => true
|
670
|
+
|
671
|
+
Fixes #20824.
|
1007
672
|
|
1008
|
-
*
|
673
|
+
*Roque Pinel*
|
1009
674
|
|
1010
|
-
|
675
|
+
* Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
|
676
|
+
when validating associations.
|
1011
677
|
|
1012
|
-
|
678
|
+
Fixes #20882.
|
1013
679
|
|
1014
|
-
|
1015
|
-
source so it has been deprecated. Code that used `source_macro`
|
1016
|
-
was removed in #16353.
|
680
|
+
*Sean Griffin*
|
1017
681
|
|
1018
|
-
|
682
|
+
* Fix a bug where counter_cache doesn't always work with polymorphic
|
683
|
+
relations.
|
1019
684
|
|
1020
|
-
|
685
|
+
Fixes #16407.
|
1021
686
|
|
1022
|
-
|
687
|
+
*Stefan Kanev*, *Sean Griffin*
|
1023
688
|
|
1024
|
-
|
689
|
+
* Ensure that cyclic associations with autosave don't cause duplicate errors
|
690
|
+
to be added to the parent record.
|
1025
691
|
|
1026
|
-
|
692
|
+
Fixes #20874.
|
1027
693
|
|
1028
|
-
|
694
|
+
*Sean Griffin*
|
1029
695
|
|
1030
|
-
|
1031
|
-
|
1032
|
-
end
|
696
|
+
* Ensure that `ActionController::Parameters` can still be passed to nested
|
697
|
+
attributes.
|
1033
698
|
|
1034
|
-
|
699
|
+
Fixes #20922.
|
1035
700
|
|
1036
|
-
*
|
701
|
+
*Sean Griffin*
|
1037
702
|
|
1038
|
-
|
703
|
+
* Deprecate force association reload by passing a truthy argument to
|
704
|
+
association method.
|
1039
705
|
|
1040
|
-
|
1041
|
-
|
706
|
+
For collection association, you can call `#reload` on association proxy to
|
707
|
+
force a reload:
|
1042
708
|
|
1043
|
-
|
709
|
+
@user.posts.reload # Instead of @user.posts(true)
|
1044
710
|
|
1045
|
-
|
711
|
+
For singular association, you can call `#reload` on the parent object to
|
712
|
+
clear its association cache then call the association method:
|
1046
713
|
|
1047
|
-
|
1048
|
-
and `add_reference`.
|
714
|
+
@user.reload.profile # Instead of @user.profile(true)
|
1049
715
|
|
1050
|
-
|
716
|
+
Passing a truthy argument to force association to reload will be removed in
|
717
|
+
Rails 5.1.
|
1051
718
|
|
1052
|
-
|
1053
|
-
t.references :station, type: :uuid
|
1054
|
-
end
|
719
|
+
*Prem Sichanugrist*
|
1055
720
|
|
1056
|
-
|
721
|
+
* Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
|
722
|
+
from the concurrent-ruby gem.
|
1057
723
|
|
1058
|
-
*
|
1059
|
-
This matches the existing behavior of HABTM associations.
|
724
|
+
*Jerry D'Antonio*
|
1060
725
|
|
1061
|
-
|
726
|
+
* Fix through associations using scopes having the scope merged multiple
|
727
|
+
times.
|
1062
728
|
|
1063
|
-
|
729
|
+
Fixes #20721.
|
730
|
+
Fixes #20727.
|
1064
731
|
|
1065
|
-
*
|
1066
|
-
a class.
|
732
|
+
*Sean Griffin*
|
1067
733
|
|
1068
|
-
|
734
|
+
* `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
|
735
|
+
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
1069
736
|
|
1070
|
-
|
737
|
+
Fixes #20743.
|
1071
738
|
|
1072
|
-
*
|
739
|
+
*Yves Senn*
|
1073
740
|
|
1074
|
-
*
|
741
|
+
* Add alternate syntax to make `change_column_default` reversible.
|
1075
742
|
|
1076
|
-
|
1077
|
-
|
743
|
+
User can pass in `:from` and `:to` to make `change_column_default` command
|
744
|
+
become reversible.
|
1078
745
|
|
1079
746
|
Example:
|
1080
747
|
|
1081
|
-
|
1082
|
-
|
1083
|
-
end
|
748
|
+
change_column_default :posts, :status, from: nil, to: "draft"
|
749
|
+
change_column_default :users, :authorized, from: true, to: false
|
1084
750
|
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
751
|
+
*Prem Sichanugrist*
|
752
|
+
|
753
|
+
* Prevent error when using `force_reload: true` on an unassigned polymorphic
|
754
|
+
belongs_to association.
|
755
|
+
|
756
|
+
Fixes #20426.
|
1089
757
|
|
1090
|
-
|
1091
|
-
post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
|
1092
|
-
post.save!
|
758
|
+
*James Dabbs*
|
1093
759
|
|
1094
|
-
|
1095
|
-
|
760
|
+
* Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
|
761
|
+
a wrong type to a namespaced association.
|
1096
762
|
|
1097
|
-
|
1098
|
-
post.comment # => "#<Comment:0x007f80ab48ff98>"
|
763
|
+
Fixes #20545.
|
1099
764
|
|
1100
|
-
|
1101
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
765
|
+
*Diego Carrion*
|
1102
766
|
|
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.
|
767
|
+
* `validates_absence_of` respects `marked_for_destruction?`.
|
1107
768
|
|
1108
|
-
|
1109
|
-
([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
|
769
|
+
Fixes #20449.
|
1110
770
|
|
1111
|
-
|
771
|
+
*Yves Senn*
|
1112
772
|
|
1113
|
-
|
773
|
+
* Include the `Enumerable` module in `ActiveRecord::Relation`
|
1114
774
|
|
1115
|
-
*
|
775
|
+
*Sean Griffin & bogdan*
|
1116
776
|
|
1117
|
-
|
777
|
+
* Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
|
1118
778
|
|
1119
|
-
*
|
779
|
+
*Sean Griffin*
|
1120
780
|
|
1121
|
-
*
|
1122
|
-
counter cache if one exists.
|
781
|
+
* Let `WITH` queries (Common Table Expressions) be explainable.
|
1123
782
|
|
1124
|
-
*
|
783
|
+
*Vladimir Kochnev*
|
1125
784
|
|
1126
|
-
*
|
1127
|
-
primary key with default value of custom PostgreSQL function result.
|
785
|
+
* Make `remove_index :table, :column` reversible.
|
1128
786
|
|
1129
|
-
|
787
|
+
*Yves Senn*
|
1130
788
|
|
1131
|
-
|
789
|
+
* Fixed an error which would occur in dirty checking when calling
|
790
|
+
`update_attributes` from a getter.
|
1132
791
|
|
1133
|
-
|
1134
|
-
produce an `IN` statements.
|
792
|
+
Fixes #20531.
|
1135
793
|
|
1136
|
-
|
794
|
+
*Sean Griffin*
|
1137
795
|
|
1138
|
-
|
1139
|
-
|
796
|
+
* Make `remove_foreign_key` reversible. Any foreign key options must be
|
797
|
+
specified, similar to `remove_column`.
|
1140
798
|
|
1141
|
-
|
799
|
+
*Aster Ryan*
|
1142
800
|
|
1143
|
-
|
1144
|
-
"categorizations"."category_id" = 1
|
801
|
+
* Add `:_prefix` and `:_suffix` options to `enum` definition.
|
1145
802
|
|
1146
|
-
|
803
|
+
Fixes #17511, #17415.
|
1147
804
|
|
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.
|
805
|
+
*Igor Kapkov*
|
1152
806
|
|
1153
|
-
|
807
|
+
* Correctly handle decimal arrays with defaults in the schema dumper.
|
1154
808
|
|
1155
|
-
|
809
|
+
Fixes #20515.
|
1156
810
|
|
1157
|
-
*
|
811
|
+
*Sean Griffin & jmondo*
|
1158
812
|
|
1159
|
-
*
|
1160
|
-
|
813
|
+
* Deprecate the PostgreSQL `:point` type in favor of a new one which will return
|
814
|
+
`Point` objects instead of an `Array`
|
1161
815
|
|
1162
816
|
*Sean Griffin*
|
1163
817
|
|
1164
|
-
*
|
1165
|
-
|
818
|
+
* Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
|
819
|
+
as columns.
|
1166
820
|
|
1167
|
-
|
821
|
+
Fixes #20360.
|
1168
822
|
|
1169
|
-
*
|
823
|
+
*Sean Griffin*
|
1170
824
|
|
1171
|
-
|
825
|
+
* Do not set `sql_mode` if `strict: :default` is specified.
|
1172
826
|
|
1173
|
-
|
827
|
+
# config/database.yml
|
828
|
+
production:
|
829
|
+
adapter: mysql2
|
830
|
+
database: foo_prod
|
831
|
+
user: foo
|
832
|
+
strict: :default
|
1174
833
|
|
1175
|
-
*
|
834
|
+
*Ryuta Kamizono*
|
1176
835
|
|
1177
|
-
|
836
|
+
* Allow proc defaults to be passed to the attributes API. See documentation
|
837
|
+
for examples.
|
1178
838
|
|
1179
|
-
*
|
1180
|
-
from `before_destroy` to `after_destroy` callback chain
|
839
|
+
*Sean Griffin*, *Kir Shatrov*
|
1181
840
|
|
1182
|
-
|
841
|
+
* SQLite: `:collation` support for string and text columns.
|
1183
842
|
|
1184
|
-
|
843
|
+
Example:
|
1185
844
|
|
1186
|
-
|
845
|
+
create_table :foo do |t|
|
846
|
+
t.string :string_nocase, collation: 'NOCASE'
|
847
|
+
t.text :text_rtrim, collation: 'RTRIM'
|
848
|
+
end
|
1187
849
|
|
1188
|
-
|
1189
|
-
changed in order for it to be persisted in the database. Now it is no longer
|
1190
|
-
required.
|
850
|
+
add_column :foo, :title, :string, collation: 'RTRIM'
|
1191
851
|
|
1192
|
-
|
852
|
+
change_column :foo, :title, :string, collation: 'NOCASE'
|
1193
853
|
|
1194
|
-
|
1195
|
-
user.name << ' Griffin'
|
1196
|
-
user.name_will_change!
|
1197
|
-
user.save
|
1198
|
-
user.reload.name # => "Sean Griffin"
|
854
|
+
*Akshay Vishnoi*
|
1199
855
|
|
1200
|
-
|
856
|
+
* Allow the use of symbols or strings to specify enum values in test
|
857
|
+
fixtures:
|
1201
858
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
user.reload.name # => "Sean Griffin"
|
859
|
+
awdr:
|
860
|
+
title: "Agile Web Development with Rails"
|
861
|
+
status: :proposed
|
1206
862
|
|
1207
|
-
*
|
863
|
+
*George Claghorn*
|
864
|
+
|
865
|
+
* Clear query cache when `ActiveRecord::Base#reload` is called.
|
1208
866
|
|
1209
|
-
*
|
1210
|
-
is invalid.
|
867
|
+
*Shane Hender, Pierre Nespo*
|
1211
868
|
|
1212
|
-
|
869
|
+
* Include stored procedures and function on the MySQL structure dump.
|
1213
870
|
|
1214
|
-
*
|
1215
|
-
a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
|
1216
|
-
and PostgreSQLAdapter.
|
871
|
+
*Jonathan Worek*
|
1217
872
|
|
1218
|
-
|
1219
|
-
|
873
|
+
* Pass `:extend` option for `has_and_belongs_to_many` associations to the
|
874
|
+
underlying `has_many :through`.
|
1220
875
|
|
1221
|
-
|
876
|
+
*Jaehyun Shin*
|
877
|
+
|
878
|
+
* Deprecate `Relation#uniq` use `Relation#distinct` instead.
|
1222
879
|
|
1223
|
-
|
1224
|
-
add_foreign_key :articles, :authors
|
1225
|
-
remove_foreign_key :articles, :authors
|
880
|
+
See #9683.
|
1226
881
|
|
1227
882
|
*Yves Senn*
|
1228
883
|
|
1229
|
-
*
|
1230
|
-
|
884
|
+
* Allow single table inheritance instantiation to work when storing
|
885
|
+
demodulized class names.
|
1231
886
|
|
1232
|
-
*
|
887
|
+
*Alex Robbin*
|
1233
888
|
|
1234
|
-
*
|
1235
|
-
|
889
|
+
* Correctly pass MySQL options when using `structure_dump` or
|
890
|
+
`structure_load`.
|
1236
891
|
|
1237
|
-
|
892
|
+
Specifically, it fixes an issue when using SSL authentication.
|
893
|
+
|
894
|
+
*Alex Coomans*
|
1238
895
|
|
1239
|
-
* `
|
896
|
+
* Dump indexes in `create_table` instead of `add_index`.
|
1240
897
|
|
1241
|
-
|
898
|
+
If the adapter supports indexes in `create_table`, generated SQL is
|
899
|
+
slightly more efficient.
|
1242
900
|
|
1243
|
-
*
|
901
|
+
*Ryuta Kamizono*
|
902
|
+
|
903
|
+
* Correctly dump `:options` on `create_table` for MySQL.
|
904
|
+
|
905
|
+
*Ryuta Kamizono*
|
1244
906
|
|
1245
|
-
*
|
1246
|
-
would fail numericality validation, regardless of the old value. Previously
|
1247
|
-
this would only occur if the old value was 0.
|
907
|
+
* PostgreSQL: `:collation` support for string and text columns.
|
1248
908
|
|
1249
909
|
Example:
|
1250
910
|
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
911
|
+
create_table :foos do |t|
|
912
|
+
t.string :string_en, collation: 'en_US.UTF-8'
|
913
|
+
t.text :text_ja, collation: 'ja_JP.UTF-8'
|
914
|
+
end
|
1254
915
|
|
1255
|
-
|
916
|
+
*Ryuta Kamizono*
|
1256
917
|
|
1257
|
-
|
918
|
+
* Remove `ActiveRecord::Serialization::XmlSerializer` from core.
|
1258
919
|
|
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)`.
|
920
|
+
*Zachary Scott*
|
1262
921
|
|
1263
|
-
|
922
|
+
* Make `unscope` aware of "less than" and "greater than" conditions.
|
1264
923
|
|
1265
|
-
*
|
1266
|
-
If this is not the case a `NoMethodError` is raised.
|
924
|
+
*TAKAHASHI Kazuaki*
|
1267
925
|
|
1268
|
-
|
926
|
+
* `find_by` and `find_by!` raise `ArgumentError` when called without
|
927
|
+
arguments.
|
1269
928
|
|
1270
|
-
*
|
929
|
+
*Kohei Suzuki*
|
1271
930
|
|
1272
|
-
|
931
|
+
* Revert behavior of `db:schema:load` back to loading the full
|
932
|
+
environment. This ensures that initializers are run.
|
1273
933
|
|
1274
|
-
|
934
|
+
Fixes #19545.
|
1275
935
|
|
1276
936
|
*Yves Senn*
|
1277
937
|
|
1278
|
-
*
|
938
|
+
* Fix missing index when using `timestamps` with the `index` option.
|
939
|
+
|
940
|
+
The `index` option used with `timestamps` should be passed to both
|
941
|
+
`column` definitions for `created_at` and `updated_at` rather than just
|
942
|
+
the first.
|
943
|
+
|
944
|
+
*Paul Mucur*
|
1279
945
|
|
1280
|
-
|
946
|
+
* Rename `:class` to `:anonymous_class` in association options.
|
1281
947
|
|
1282
|
-
|
1283
|
-
are part of the URI structure, not the actual host.
|
948
|
+
Fixes #19659.
|
1284
949
|
|
1285
|
-
|
950
|
+
*Andrew White*
|
1286
951
|
|
1287
|
-
|
952
|
+
* Autosave existing records on a has many through association when the parent
|
953
|
+
is new.
|
1288
954
|
|
1289
|
-
|
1290
|
-
through association are new.
|
955
|
+
Fixes #19782.
|
1291
956
|
|
1292
957
|
*Sean Griffin*
|
1293
958
|
|
1294
|
-
*
|
1295
|
-
|
1296
|
-
unchanged.
|
1297
|
-
|
1298
|
-
Fixes #8328.
|
959
|
+
* Fixed a bug where uniqueness validations would error on out of range values,
|
960
|
+
even if an validation should have prevented it from hitting the database.
|
1299
961
|
|
1300
|
-
*
|
962
|
+
*Andrey Voronkov*
|
1301
963
|
|
1302
|
-
* `
|
1303
|
-
name.
|
964
|
+
* MySQL: `:charset` and `:collation` support for string and text columns.
|
1304
965
|
|
1305
|
-
|
966
|
+
Example:
|
1306
967
|
|
1307
|
-
|
968
|
+
create_table :foos do |t|
|
969
|
+
t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
|
970
|
+
t.text :text_ascii, charset: 'ascii'
|
971
|
+
end
|
1308
972
|
|
1309
|
-
*
|
973
|
+
*Ryuta Kamizono*
|
1310
974
|
|
1311
|
-
|
975
|
+
* Foreign key related methods in the migration DSL respect
|
976
|
+
`ActiveRecord::Base.pluralize_table_names = false`.
|
1312
977
|
|
1313
|
-
|
978
|
+
Fixes #19643.
|
1314
979
|
|
1315
|
-
*
|
980
|
+
*Mehmet Emin İNAÇ*
|
1316
981
|
|
1317
|
-
*
|
1318
|
-
`Enumerable#find` does.
|
982
|
+
* Reduce memory usage from loading types on PostgreSQL.
|
1319
983
|
|
1320
|
-
Fixes #
|
984
|
+
Fixes #19578.
|
1321
985
|
|
1322
|
-
*
|
986
|
+
*Sean Griffin*
|
1323
987
|
|
1324
|
-
*
|
988
|
+
* Add `config.active_record.warn_on_records_fetched_greater_than` option.
|
1325
989
|
|
1326
|
-
|
990
|
+
When set to an integer, a warning will be logged whenever a result set
|
991
|
+
larger than the specified size is returned by a query.
|
1327
992
|
|
1328
|
-
|
993
|
+
Fixes #16463.
|
1329
994
|
|
1330
|
-
*
|
1331
|
-
`primary_key_prefix_type` configuration.
|
995
|
+
*Jason Nochlin*
|
1332
996
|
|
1333
|
-
|
997
|
+
* Ignore `.psqlrc` when loading database structure.
|
1334
998
|
|
1335
|
-
*
|
999
|
+
*Jason Weathered*
|
1336
1000
|
|
1337
|
-
*
|
1001
|
+
* Fix referencing wrong table aliases while joining tables of has many through
|
1002
|
+
association (only when calling calculation methods).
|
1338
1003
|
|
1339
|
-
Fixes #
|
1004
|
+
Fixes #19276.
|
1340
1005
|
|
1341
|
-
*
|
1006
|
+
*pinglamb*
|
1342
1007
|
|
1343
|
-
*
|
1008
|
+
* Correctly persist a serialized attribute that has been returned to
|
1009
|
+
its default value by an in-place modification.
|
1344
1010
|
|
1345
|
-
|
1346
|
-
updated.
|
1011
|
+
Fixes #19467.
|
1347
1012
|
|
1348
|
-
|
1013
|
+
*Matthew Draper*
|
1349
1014
|
|
1350
|
-
|
1015
|
+
* Fix generating the schema file when using PostgreSQL `BigInt[]` data type.
|
1016
|
+
Previously the `limit: 8` was not coming through, and this caused it to
|
1017
|
+
become `Int[]` data type after rebuilding from the schema.
|
1351
1018
|
|
1352
|
-
|
1353
|
-
`proper_table_name` instance method on `ActiveRecord::Migration` instead.
|
1019
|
+
Fixes #19420.
|
1354
1020
|
|
1355
|
-
*
|
1021
|
+
*Jake Waller*
|
1356
1022
|
|
1357
|
-
*
|
1358
|
-
|
1023
|
+
* Reuse the `CollectionAssociation#reader` cache when the foreign key is
|
1024
|
+
available prior to save.
|
1359
1025
|
|
1360
|
-
|
1026
|
+
*Ben Woosley*
|
1361
1027
|
|
1362
|
-
|
1028
|
+
* Add `config.active_record.dump_schemas` to fix `db:structure:dump`
|
1029
|
+
when using schema_search_path and PostgreSQL extensions.
|
1363
1030
|
|
1364
|
-
|
1365
|
-
It will return a null object in Rails 5.0
|
1031
|
+
Fixes #17157.
|
1366
1032
|
|
1367
|
-
*
|
1033
|
+
*Ryan Wallace*
|
1368
1034
|
|
1369
|
-
*
|
1035
|
+
* Renaming `use_transactional_fixtures` to `use_transactional_tests` for clarity.
|
1370
1036
|
|
1371
|
-
|
1037
|
+
Fixes #18864.
|
1372
1038
|
|
1373
|
-
*
|
1374
|
-
columns.
|
1039
|
+
*Brandon Weiss*
|
1375
1040
|
|
1376
|
-
|
1041
|
+
* Increase pg gem version requirement to `~> 0.18`. Earlier versions of the
|
1042
|
+
pg gem are known to have problems with Ruby 2.2.
|
1377
1043
|
|
1378
|
-
*
|
1044
|
+
*Matt Brictson*
|
1379
1045
|
|
1380
|
-
|
1046
|
+
* Correctly dump `serial` and `bigserial`.
|
1381
1047
|
|
1382
|
-
*
|
1048
|
+
*Ryuta Kamizono*
|
1383
1049
|
|
1384
|
-
|
1050
|
+
* Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
|
1385
1051
|
|
1386
|
-
*
|
1052
|
+
*James Cox*
|
1387
1053
|
|
1388
|
-
|
1054
|
+
* Don't enroll records in the transaction if they don't have commit callbacks.
|
1055
|
+
This was causing a memory leak when creating many records inside a transaction.
|
1389
1056
|
|
1390
|
-
|
1391
|
-
with orders without sort direction modifiers.
|
1057
|
+
Fixes #15549.
|
1392
1058
|
|
1393
|
-
*
|
1059
|
+
*Will Bryant*, *Aaron Patterson*
|
1394
1060
|
|
1395
|
-
*
|
1061
|
+
* Correctly create through records when created on a has many through
|
1062
|
+
association when using `where`.
|
1396
1063
|
|
1397
|
-
|
1064
|
+
Fixes #19073.
|
1398
1065
|
|
1399
|
-
*
|
1400
|
-
Fixes duplication in combination with `store_accessor`.
|
1066
|
+
*Sean Griffin*
|
1401
1067
|
|
1402
|
-
|
1068
|
+
* Add `SchemaMigration.create_table` support for any unicode charsets with MySQL.
|
1403
1069
|
|
1404
|
-
*
|
1070
|
+
*Ryuta Kamizono*
|
1405
1071
|
|
1406
|
-
*
|
1072
|
+
* PostgreSQL no longer disables user triggers if system triggers can't be
|
1073
|
+
disabled. Disabling user triggers does not fulfill what the method promises.
|
1074
|
+
Rails currently requires superuser privileges for this method.
|
1407
1075
|
|
1408
|
-
|
1076
|
+
If you absolutely rely on this behavior, consider patching
|
1077
|
+
`disable_referential_integrity`.
|
1409
1078
|
|
1410
|
-
*
|
1411
|
-
Fixing regression case, where redefining the same `has_and_belongs_to_many`
|
1412
|
-
definition into a subclass would raise.
|
1079
|
+
*Yves Senn*
|
1413
1080
|
|
1414
|
-
|
1081
|
+
* Restore aborted transaction state when `disable_referential_integrity` fails
|
1082
|
+
due to missing permissions.
|
1415
1083
|
|
1416
|
-
*
|
1084
|
+
*Toby Ovod-Everett*, *Yves Senn*
|
1417
1085
|
|
1418
|
-
*
|
1419
|
-
|
1420
|
-
But as `reflections` is a public API, people expect to see the right macro.
|
1086
|
+
* In PostgreSQL, print a warning message if `disable_referential_integrity`
|
1087
|
+
fails due to missing permissions.
|
1421
1088
|
|
1422
|
-
|
1089
|
+
*Andrey Nering*, *Yves Senn*
|
1423
1090
|
|
1424
|
-
|
1091
|
+
* Allow a `:limit` option for MySQL bigint primary key support.
|
1425
1092
|
|
1426
|
-
|
1093
|
+
Example:
|
1427
1094
|
|
1428
|
-
|
1095
|
+
create_table :foos, id: :primary_key, limit: 8 do |t|
|
1096
|
+
end
|
1429
1097
|
|
1430
|
-
|
1098
|
+
# or
|
1431
1099
|
|
1432
|
-
|
1433
|
-
|
1100
|
+
create_table :foos, id: false do |t|
|
1101
|
+
t.primary_key :id, limit: 8
|
1102
|
+
end
|
1434
1103
|
|
1435
|
-
*
|
1104
|
+
*Ryuta Kamizono*
|
1436
1105
|
|
1437
|
-
*
|
1438
|
-
`
|
1106
|
+
* `belongs_to` will now trigger a validation error by default if the association is not present.
|
1107
|
+
You can turn this off on a per-association basis with `optional: true`.
|
1108
|
+
(Note this new default only applies to new Rails apps that will be generated with
|
1109
|
+
`config.active_record.belongs_to_required_by_default = true` in initializer.)
|
1439
1110
|
|
1440
|
-
*
|
1111
|
+
*Josef Šimánek*
|
1441
1112
|
|
1442
|
-
*
|
1113
|
+
* Fixed `ActiveRecord::Relation#becomes!` and `changed_attributes` issues for type
|
1114
|
+
columns.
|
1443
1115
|
|
1444
|
-
Fixes #
|
1116
|
+
Fixes #17139.
|
1445
1117
|
|
1446
|
-
*
|
1118
|
+
*Miklos Fazekas*
|
1447
1119
|
|
1448
|
-
*
|
1120
|
+
* Format the time string according to the precision of the time column.
|
1449
1121
|
|
1450
|
-
|
1451
|
-
record will only be touched if the record was modified. This makes it
|
1452
|
-
consistent with timestamp updating on the record itself.
|
1122
|
+
*Ryuta Kamizono*
|
1453
1123
|
|
1454
|
-
|
1124
|
+
* Allow a `:precision` option for time type columns.
|
1455
1125
|
|
1456
|
-
*
|
1457
|
-
table inside a schema.
|
1126
|
+
*Ryuta Kamizono*
|
1458
1127
|
|
1459
|
-
|
1128
|
+
* Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
|
1129
|
+
during the given block.
|
1460
1130
|
|
1461
|
-
|
1131
|
+
For example, here's a pattern of creating notifications when new comments
|
1132
|
+
are posted. (The notification may in turn trigger an email, a push
|
1133
|
+
notification, or just appear in the UI somewhere):
|
1462
1134
|
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1135
|
+
class Comment < ActiveRecord::Base
|
1136
|
+
belongs_to :commentable, polymorphic: true
|
1137
|
+
after_create -> { Notification.create! comment: self,
|
1138
|
+
recipients: commentable.recipients }
|
1139
|
+
end
|
1466
1140
|
|
1467
|
-
|
1141
|
+
That's what you want the bulk of the time. A new comment creates a new
|
1142
|
+
Notification. There may be edge cases where you don't want that, like
|
1143
|
+
when copying a commentable and its comments, in which case write a
|
1144
|
+
concern with something like this:
|
1145
|
+
|
1146
|
+
module Copyable
|
1147
|
+
def copy_to(destination)
|
1148
|
+
Notification.suppress do
|
1149
|
+
# Copy logic that creates new comments that we do not want triggering
|
1150
|
+
# notifications.
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
end
|
1468
1154
|
|
1469
|
-
*
|
1470
|
-
extension names in PostgreSQL when migrating.
|
1155
|
+
*Michael Ryan*
|
1471
1156
|
|
1472
|
-
|
1157
|
+
* `:time` option added for `#touch`.
|
1473
1158
|
|
1474
|
-
|
1475
|
-
`references`, now works with any column types.
|
1159
|
+
Fixes #18905.
|
1476
1160
|
|
1477
|
-
*
|
1161
|
+
*Hyonjee Joo*
|
1478
1162
|
|
1479
|
-
*
|
1163
|
+
* Deprecate passing of `start` value to `find_in_batches` and `find_each`
|
1164
|
+
in favour of `begin_at` value.
|
1480
1165
|
|
1481
|
-
*
|
1166
|
+
*Vipul A M*
|
1482
1167
|
|
1483
|
-
*
|
1484
|
-
or `offset`.
|
1168
|
+
* Add `foreign_key_exists?` method.
|
1485
1169
|
|
1486
|
-
|
1487
|
-
records to be deleted.
|
1170
|
+
*Tõnis Simo*
|
1488
1171
|
|
1489
|
-
|
1172
|
+
* Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods
|
1173
|
+
if no block or limit is given, instead of loading the entire
|
1174
|
+
collection into memory. This applies to relations (e.g. `User.all`)
|
1175
|
+
as well as associations (e.g. `account.users`)
|
1490
1176
|
|
1491
|
-
|
1177
|
+
# Before:
|
1492
1178
|
|
1493
|
-
|
1494
|
-
|
1179
|
+
users.none?
|
1180
|
+
# SELECT "users".* FROM "users"
|
1495
1181
|
|
1496
|
-
|
1182
|
+
users.one?
|
1183
|
+
# SELECT "users".* FROM "users"
|
1497
1184
|
|
1498
|
-
|
1185
|
+
# After:
|
1499
1186
|
|
1500
|
-
|
1501
|
-
|
1187
|
+
users.none?
|
1188
|
+
# SELECT 1 AS one FROM "users" LIMIT 1
|
1502
1189
|
|
1503
|
-
|
1190
|
+
users.one?
|
1191
|
+
# SELECT COUNT(*) FROM "users"
|
1504
1192
|
|
1505
|
-
*
|
1193
|
+
*Eugene Gilburg*
|
1506
1194
|
|
1507
|
-
* `
|
1508
|
-
|
1195
|
+
* Have `enum` perform type casting consistently with the rest of Active
|
1196
|
+
Record, such as `where`.
|
1509
1197
|
|
1510
|
-
|
1511
|
-
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
1512
|
-
throw a `StatementInvalid` exception.
|
1198
|
+
*Sean Griffin*
|
1513
1199
|
|
1514
|
-
|
1200
|
+
* `scoping` no longer pollutes the current scope of sibling classes when using
|
1201
|
+
STI. e.x.
|
1515
1202
|
|
1516
|
-
|
1517
|
-
|
1203
|
+
StiOne.none.scoping do
|
1204
|
+
StiTwo.all
|
1205
|
+
end
|
1518
1206
|
|
1519
|
-
Fixes #
|
1207
|
+
Fixes #18806.
|
1520
1208
|
|
1521
|
-
*
|
1209
|
+
*Sean Griffin*
|
1522
1210
|
|
1523
|
-
* `
|
1211
|
+
* `remove_reference` with `foreign_key: true` removes the foreign key before
|
1212
|
+
removing the column. This fixes a bug where it was not possible to remove
|
1213
|
+
the column on MySQL.
|
1524
1214
|
|
1525
|
-
Fixes #
|
1215
|
+
Fixes #18664.
|
1526
1216
|
|
1527
1217
|
*Yves Senn*
|
1528
1218
|
|
1529
|
-
*
|
1530
|
-
|
1531
|
-
`name` and `"char"` are special character types used internally by
|
1532
|
-
PostgreSQL and are used by internal system catalogs. These field types
|
1533
|
-
can sometimes show up in structure-sniffing queries that feature internal system
|
1534
|
-
structures or with certain PostgreSQL extensions.
|
1219
|
+
* `find_in_batches` now accepts an `:end_at` parameter that complements the `:start`
|
1220
|
+
parameter to specify where to stop batch processing.
|
1535
1221
|
|
1536
|
-
*
|
1222
|
+
*Vipul A M*
|
1537
1223
|
|
1538
|
-
* Fix
|
1539
|
-
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
1224
|
+
* Fix a rounding problem for PostgreSQL timestamp columns.
|
1540
1225
|
|
1541
|
-
|
1226
|
+
If a timestamp column has a precision specified, it needs to
|
1227
|
+
format according to that.
|
1542
1228
|
|
1543
|
-
|
1544
|
-
Point.last.value # => 0.0
|
1229
|
+
*Ryuta Kamizono*
|
1545
1230
|
|
1546
|
-
|
1231
|
+
* Respect the database default charset for `schema_migrations` table.
|
1547
1232
|
|
1548
|
-
|
1549
|
-
|
1233
|
+
The charset of `version` column in `schema_migrations` table depends
|
1234
|
+
on the database default charset and collation rather than the encoding
|
1235
|
+
of the connection.
|
1550
1236
|
|
1551
|
-
*
|
1237
|
+
*Ryuta Kamizono*
|
1552
1238
|
|
1553
|
-
*
|
1239
|
+
* Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
|
1554
1240
|
|
1555
|
-
|
1241
|
+
These are not valid values to merge in a relation, so it should warn users
|
1242
|
+
early.
|
1556
1243
|
|
1557
|
-
*
|
1244
|
+
*Rafael Mendonça França*
|
1558
1245
|
|
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.
|
1246
|
+
* Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
|
1563
1247
|
|
1564
|
-
|
1248
|
+
This makes the db:structure tasks consistent with test:load_structure.
|
1565
1249
|
|
1566
|
-
*
|
1250
|
+
*Dieter Komendera*
|
1567
1251
|
|
1568
|
-
*
|
1252
|
+
* Respect custom primary keys for associations when calling `Relation#where`
|
1569
1253
|
|
1570
|
-
|
1571
|
-
size calculation if the collection is not cached or loaded.
|
1254
|
+
Fixes #18813.
|
1572
1255
|
|
1573
|
-
|
1256
|
+
*Sean Griffin*
|
1574
1257
|
|
1575
|
-
|
1258
|
+
* Fix several edge cases which could result in a counter cache updating
|
1259
|
+
twice or not updating at all for `has_many` and `has_many :through`.
|
1576
1260
|
|
1577
|
-
|
1578
|
-
not exist.
|
1261
|
+
Fixes #10865.
|
1579
1262
|
|
1580
|
-
*
|
1263
|
+
*Sean Griffin*
|
1581
1264
|
|
1582
|
-
*
|
1265
|
+
* Foreign keys added by migrations were given random, generated names. This
|
1266
|
+
meant a different `structure.sql` would be generated every time a developer
|
1267
|
+
ran migrations on their machine.
|
1583
1268
|
|
1584
|
-
|
1585
|
-
|
1269
|
+
The generated part of foreign key names is now a hash of the table name and
|
1270
|
+
column name, which is consistent every time you run the migration.
|
1586
1271
|
|
1587
|
-
*
|
1272
|
+
*Chris Sinjakli*
|
1588
1273
|
|
1589
|
-
*
|
1274
|
+
* Validation errors would be raised for parent records when an association
|
1275
|
+
was saved when the parent had `validate: false`. It should not be the
|
1276
|
+
responsibility of the model to validate an associated object unless the
|
1277
|
+
object was created or modified by the parent.
|
1590
1278
|
|
1591
|
-
|
1592
|
-
|
1279
|
+
This fixes the issue by skipping validations if the parent record is
|
1280
|
+
persisted, not changed, and not marked for destruction.
|
1593
1281
|
|
1594
|
-
|
1282
|
+
Fixes #17621.
|
1595
1283
|
|
1596
|
-
*
|
1284
|
+
*Eileen M. Uchitelle, Aaron Patterson*
|
1597
1285
|
|
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.
|
1286
|
+
* Fix n+1 query problem when eager loading nil associations (fixes #18312)
|
1605
1287
|
|
1606
|
-
*
|
1288
|
+
*Sammy Larbi*
|
1607
1289
|
|
1608
|
-
*
|
1609
|
-
|
1290
|
+
* Change the default error message from `can't be blank` to `must exist` for
|
1291
|
+
the presence validator of the `:required` option on `belongs_to`/`has_one`
|
1292
|
+
associations.
|
1610
1293
|
|
1611
|
-
|
1294
|
+
*Henrik Nygren*
|
1612
1295
|
|
1613
|
-
|
1296
|
+
* Fixed `ActiveRecord::Relation#group` method when an argument is an SQL
|
1297
|
+
reserved keyword:
|
1614
1298
|
|
1615
|
-
|
1299
|
+
Example:
|
1616
1300
|
|
1617
|
-
|
1618
|
-
|
1301
|
+
SplitTest.group(:key).count
|
1302
|
+
Property.group(:value).count
|
1619
1303
|
|
1620
|
-
|
1304
|
+
*Bogdan Gusiev*
|
1621
1305
|
|
1622
|
-
|
1306
|
+
* Added the `#or` method on `ActiveRecord::Relation`, allowing use of the OR
|
1307
|
+
operator to combine WHERE or HAVING clauses.
|
1623
1308
|
|
1624
|
-
|
1309
|
+
Example:
|
1625
1310
|
|
1626
|
-
|
1311
|
+
Post.where('id = 1').or(Post.where('id = 2'))
|
1312
|
+
# => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
|
1627
1313
|
|
1628
|
-
*
|
1314
|
+
*Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
|
1629
1315
|
|
1630
|
-
*
|
1316
|
+
* Don't define autosave association callbacks twice from
|
1317
|
+
`accepts_nested_attributes_for`.
|
1631
1318
|
|
1632
|
-
|
1319
|
+
Fixes #18704.
|
1633
1320
|
|
1634
|
-
*
|
1635
|
-
on Reflections. This causes a problem when rails loads fixtures, because it
|
1636
|
-
uses the reflections to set database with fixtures.
|
1321
|
+
*Sean Griffin*
|
1637
1322
|
|
1638
|
-
|
1323
|
+
* Integer types will no longer raise a `RangeError` when assigning an
|
1324
|
+
attribute, but will instead raise when going to the database.
|
1639
1325
|
|
1640
|
-
|
1326
|
+
Fixes several vague issues which were never reported directly. See the
|
1327
|
+
commit message from the commit which added this line for some examples.
|
1641
1328
|
|
1642
|
-
*
|
1643
|
-
Additionally display a warning message to make the user aware.
|
1329
|
+
*Sean Griffin*
|
1644
1330
|
|
1645
|
-
|
1331
|
+
* Values which would error while being sent to the database (such as an
|
1332
|
+
ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
|
1333
|
+
assignment. They will still error when sent to the database, but you are
|
1334
|
+
given the ability to re-assign it to a valid value.
|
1646
1335
|
|
1647
|
-
|
1648
|
-
different spellings of timestamps are treated the same.
|
1336
|
+
Fixes #18580.
|
1649
1337
|
|
1650
|
-
|
1338
|
+
*Sean Griffin*
|
1651
1339
|
|
1652
|
-
|
1653
|
-
# => :datetime
|
1654
|
-
mytimestamp.simplified_type('timestamp(6) without time zone')
|
1655
|
-
# => also :datetime (previously would be :timestamp)
|
1340
|
+
* Don't remove join dependencies in `Relation#exists?`
|
1656
1341
|
|
1657
|
-
|
1342
|
+
Fixes #18632.
|
1658
1343
|
|
1659
|
-
*
|
1344
|
+
*Sean Griffin*
|
1660
1345
|
|
1661
|
-
*
|
1346
|
+
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
1662
1347
|
|
1663
|
-
Fixes #
|
1348
|
+
Fixes #18629.
|
1664
1349
|
|
1665
|
-
*
|
1350
|
+
*Sean Griffin*
|
1666
1351
|
|
1667
|
-
*
|
1352
|
+
* Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
|
1353
|
+
discover which fields were read from a model when you are looking to only
|
1354
|
+
select the data you need from the database.
|
1668
1355
|
|
1669
|
-
|
1356
|
+
*Sean Griffin*
|
1670
1357
|
|
1671
|
-
|
1358
|
+
* Introduce the `:if_exists` option for `drop_table`.
|
1672
1359
|
|
1673
|
-
|
1674
|
-
a scoped `has_many`.
|
1360
|
+
Example:
|
1675
1361
|
|
1676
|
-
|
1677
|
-
`has_many :through` uses this association, then the scope adjustment is
|
1678
|
-
unexpectedly neglected.
|
1362
|
+
drop_table(:posts, if_exists: true)
|
1679
1363
|
|
1680
|
-
|
1364
|
+
That would execute:
|
1681
1365
|
|
1682
|
-
|
1366
|
+
DROP TABLE IF EXISTS posts
|
1683
1367
|
|
1684
|
-
|
1368
|
+
If the table doesn't exist, `if_exists: false` (the default) raises an
|
1369
|
+
exception whereas `if_exists: true` does nothing.
|
1685
1370
|
|
1686
|
-
*
|
1371
|
+
*Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
|
1687
1372
|
|
1688
|
-
*
|
1373
|
+
* Don't run SQL if attribute value is not changed for update_attribute method.
|
1689
1374
|
|
1690
|
-
|
1375
|
+
*Prathamesh Sonpatki*
|
1691
1376
|
|
1692
|
-
|
1377
|
+
* `time` columns can now get affected by `time_zone_aware_attributes`. If you have
|
1378
|
+
set `config.time_zone` to a value other than `'UTC'`, they will be treated
|
1379
|
+
as in that time zone by default in Rails 5.1. If this is not the desired
|
1380
|
+
behavior, you can set
|
1693
1381
|
|
1694
|
-
|
1382
|
+
ActiveRecord::Base.time_zone_aware_types = [:datetime]
|
1695
1383
|
|
1696
|
-
|
1384
|
+
A deprecation warning will be emitted if you have a `:time` column, and have
|
1385
|
+
not explicitly opted out.
|
1697
1386
|
|
1698
|
-
|
1387
|
+
Fixes #3145.
|
1699
1388
|
|
1700
|
-
*
|
1701
|
-
LIKE statement.
|
1389
|
+
*Sean Griffin*
|
1702
1390
|
|
1703
|
-
|
1391
|
+
* Tests now run after_commit callbacks. You no longer have to declare
|
1392
|
+
`uses_transaction ‘test name’` to test the results of an after_commit.
|
1704
1393
|
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
end
|
1709
|
-
end
|
1394
|
+
after_commit callbacks run after committing a transaction whose parent
|
1395
|
+
is not `joinable?`: un-nested transactions, transactions within test cases,
|
1396
|
+
and transactions in `console --sandbox`.
|
1710
1397
|
|
1711
|
-
|
1712
|
-
# => Query looks like "... title LIKE '20\% \_reduction\_' ..."
|
1398
|
+
*arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
|
1713
1399
|
|
1714
|
-
|
1400
|
+
* `nil` as a value for a binary column in a query no longer logs as
|
1401
|
+
"<NULL binary data>", and instead logs as just "nil".
|
1715
1402
|
|
1716
|
-
*
|
1403
|
+
*Sean Griffin*
|
1717
1404
|
|
1718
|
-
|
1405
|
+
* `attribute_will_change!` will no longer cause non-persistable attributes to
|
1406
|
+
be sent to the database.
|
1719
1407
|
|
1720
|
-
|
1408
|
+
Fixes #18407.
|
1721
1409
|
|
1722
|
-
*
|
1410
|
+
*Sean Griffin*
|
1723
1411
|
|
1724
|
-
|
1412
|
+
* Remove support for the `protected_attributes` gem.
|
1725
1413
|
|
1726
|
-
|
1727
|
-
# => true
|
1728
|
-
Post.where(author_id: author.id) == author.posts
|
1729
|
-
# => true
|
1414
|
+
*Carlos Antonio da Silva*, *Roberto Miranda*
|
1730
1415
|
|
1731
|
-
|
1416
|
+
* Fix accessing of fixtures having non-string labels like Fixnum.
|
1732
1417
|
|
1733
|
-
*
|
1418
|
+
*Prathamesh Sonpatki*
|
1734
1419
|
|
1735
|
-
*
|
1736
|
-
generates an SQL statement containing each id of the collection:
|
1420
|
+
* Remove deprecated support to preload instance-dependent associations.
|
1737
1421
|
|
1738
|
-
|
1422
|
+
*Yves Senn*
|
1739
1423
|
|
1740
|
-
|
1741
|
-
AND `model`.`id` IN (1, 2, 3...)
|
1424
|
+
* Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
|
1742
1425
|
|
1743
|
-
|
1426
|
+
*Yves Senn*
|
1744
1427
|
|
1745
|
-
|
1428
|
+
* Remove deprecation when modifying a relation with cached Arel.
|
1429
|
+
This raises an `ImmutableRelation` error instead.
|
1746
1430
|
|
1747
|
-
*
|
1431
|
+
*Yves Senn*
|
1748
1432
|
|
1749
|
-
*
|
1750
|
-
|
1433
|
+
* Added `ActiveRecord::SecureToken` in order to encapsulate generation of
|
1434
|
+
unique tokens for attributes in a model using `SecureRandom`.
|
1751
1435
|
|
1752
|
-
|
1436
|
+
*Roberto Miranda*
|
1753
1437
|
|
1754
|
-
|
1438
|
+
* Change the behavior of boolean columns to be closer to Ruby's semantics.
|
1755
1439
|
|
1756
|
-
|
1440
|
+
Before this change we had a small set of "truthy", and all others are "falsy".
|
1757
1441
|
|
1758
|
-
|
1442
|
+
Now, we have a small set of "falsy" values and all others are "truthy" matching
|
1443
|
+
Ruby's semantics.
|
1759
1444
|
|
1760
|
-
*
|
1445
|
+
*Rafael Mendonça França*
|
1761
1446
|
|
1762
|
-
*
|
1763
|
-
unknown OIDs.
|
1447
|
+
* Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
|
1764
1448
|
|
1765
|
-
|
1449
|
+
*Rafael Mendonça França*
|
1766
1450
|
|
1767
|
-
|
1451
|
+
* Change transaction callbacks to not swallow errors.
|
1768
1452
|
|
1769
|
-
|
1453
|
+
Before this change any errors raised inside a transaction callback
|
1454
|
+
were getting rescued and printed in the logs.
|
1770
1455
|
|
1771
|
-
|
1456
|
+
Now these errors are not rescued anymore and just bubble up, as the other callbacks.
|
1772
1457
|
|
1773
|
-
*
|
1458
|
+
*Rafael Mendonça França*
|
1774
1459
|
|
1775
|
-
*
|
1460
|
+
* Remove deprecated `sanitize_sql_hash_for_conditions`.
|
1776
1461
|
|
1777
|
-
|
1462
|
+
*Rafael Mendonça França*
|
1778
1463
|
|
1779
|
-
|
1464
|
+
* Remove deprecated `Reflection#source_macro`.
|
1780
1465
|
|
1781
|
-
*
|
1782
|
-
same name in an unrelated class.
|
1466
|
+
*Rafael Mendonça França*
|
1783
1467
|
|
1784
|
-
|
1468
|
+
* Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
|
1785
1469
|
|
1786
|
-
*
|
1470
|
+
*Rafael Mendonça França*
|
1787
1471
|
|
1788
|
-
*
|
1472
|
+
* Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
|
1789
1473
|
|
1790
|
-
|
1474
|
+
*Rafael Mendonça França*
|
1791
1475
|
|
1792
|
-
|
1476
|
+
* Remove deprecated access to connection specification using a string accessor.
|
1793
1477
|
|
1794
|
-
|
1478
|
+
Now all strings will be handled as a URL.
|
1795
1479
|
|
1796
|
-
|
1480
|
+
*Rafael Mendonça França*
|
1797
1481
|
|
1798
|
-
|
1482
|
+
* Change the default `null` value for `timestamps` to `false`.
|
1799
1483
|
|
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.
|
1484
|
+
*Rafael Mendonça França*
|
1804
1485
|
|
1805
|
-
|
1486
|
+
* Return an array of pools from `connection_pools`.
|
1806
1487
|
|
1807
|
-
*
|
1488
|
+
*Rafael Mendonça França*
|
1808
1489
|
|
1809
|
-
*
|
1490
|
+
* Return a null column from `column_for_attribute` when no column exists.
|
1810
1491
|
|
1811
|
-
|
1492
|
+
*Rafael Mendonça França*
|
1812
1493
|
|
1813
|
-
|
1494
|
+
* Remove deprecated `serialized_attributes`.
|
1814
1495
|
|
1815
|
-
*
|
1496
|
+
*Rafael Mendonça França*
|
1816
1497
|
|
1817
|
-
*
|
1498
|
+
* Remove deprecated automatic counter caches on `has_many :through`.
|
1818
1499
|
|
1819
|
-
|
1500
|
+
*Rafael Mendonça França*
|
1820
1501
|
|
1821
|
-
|
1502
|
+
* Change the way in which callback chains can be halted.
|
1822
1503
|
|
1823
|
-
|
1824
|
-
|
1504
|
+
The preferred method to halt a callback chain from now on is to explicitly
|
1505
|
+
`throw(:abort)`.
|
1506
|
+
In the past, returning `false` in an Active Record `before_` callback had the
|
1507
|
+
side effect of halting the callback chain.
|
1508
|
+
This is not recommended anymore and, depending on the value of the
|
1509
|
+
`ActiveSupport.halt_callback_chains_on_return_false` option, will
|
1510
|
+
either not work at all or display a deprecation warning.
|
1825
1511
|
|
1826
|
-
|
1827
|
-
`sqlite3:///my/path` with `sqlite3:my/path`.
|
1512
|
+
*claudiob*
|
1828
1513
|
|
1829
|
-
|
1514
|
+
* Clear query cache on rollback.
|
1830
1515
|
|
1831
|
-
*
|
1516
|
+
*Florian Weingarten*
|
1832
1517
|
|
1833
|
-
|
1518
|
+
* Fix setting of foreign_key for through associations when building a new record.
|
1834
1519
|
|
1835
|
-
|
1520
|
+
Fixes #12698.
|
1836
1521
|
|
1837
|
-
*
|
1522
|
+
*Ivan Antropov*
|
1838
1523
|
|
1839
|
-
*
|
1524
|
+
* Improve dumping of the primary key. If it is not a default primary key,
|
1525
|
+
correctly dump the type and options.
|
1840
1526
|
|
1841
|
-
|
1527
|
+
Fixes #14169, #16599.
|
1842
1528
|
|
1843
|
-
*
|
1529
|
+
*Ryuta Kamizono*
|
1844
1530
|
|
1845
|
-
|
1531
|
+
* Format the datetime string according to the precision of the datetime field.
|
1846
1532
|
|
1847
|
-
|
1848
|
-
The column types stay the same except for enum columns. They no longer have
|
1849
|
-
`nil` as type but `enum`.
|
1533
|
+
Incompatible to rounding behavior between MySQL 5.6 and earlier.
|
1850
1534
|
|
1851
|
-
|
1535
|
+
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
|
1536
|
+
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
1852
1537
|
|
1853
|
-
|
1538
|
+
http://bugs.mysql.com/bug.php?id=68760
|
1854
1539
|
|
1855
|
-
*
|
1856
|
-
column.
|
1540
|
+
*Ryuta Kamizono*
|
1857
1541
|
|
1858
|
-
|
1542
|
+
* Allow a precision option for MySQL datetimes.
|
1859
1543
|
|
1860
|
-
*
|
1544
|
+
*Ryuta Kamizono*
|
1861
1545
|
|
1862
|
-
*
|
1863
|
-
custom primary key that did not save due to validation error.
|
1546
|
+
* Fixed automatic `inverse_of` for models nested in a module.
|
1864
1547
|
|
1865
|
-
|
1548
|
+
*Andrew McCloud*
|
1866
1549
|
|
1867
|
-
|
1550
|
+
* Change `ActiveRecord::Relation#update` behavior so that it can
|
1551
|
+
be called without passing ids of the records to be updated.
|
1868
1552
|
|
1869
|
-
|
1553
|
+
This change allows updating multiple records returned by
|
1554
|
+
`ActiveRecord::Relation` with callbacks and validations.
|
1870
1555
|
|
1871
|
-
|
1556
|
+
# Before
|
1557
|
+
# ArgumentError: wrong number of arguments (1 for 2)
|
1558
|
+
Comment.where(group: 'expert').update(body: "Group of Rails Experts")
|
1872
1559
|
|
1873
|
-
|
1560
|
+
# After
|
1561
|
+
# Comments with group expert updated with body "Group of Rails Experts"
|
1562
|
+
Comment.where(group: 'expert').update(body: "Group of Rails Experts")
|
1874
1563
|
|
1875
|
-
*
|
1564
|
+
*Prathamesh Sonpatki*
|
1876
1565
|
|
1877
|
-
|
1878
|
-
would commit the transaction.
|
1566
|
+
* Fix `reaping_frequency` option when the value is a string.
|
1879
1567
|
|
1880
|
-
|
1881
|
-
required.
|
1568
|
+
This usually happens when it is configured using `DATABASE_URL`.
|
1882
1569
|
|
1883
|
-
|
1570
|
+
*korbin*
|
1884
1571
|
|
1885
|
-
|
1886
|
-
|
1887
|
-
end
|
1888
|
-
# => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
|
1572
|
+
* Fix error message when trying to create an associated record and the foreign
|
1573
|
+
key is missing.
|
1889
1574
|
|
1890
|
-
|
1575
|
+
Before this fix the following exception was being raised:
|
1891
1576
|
|
1892
|
-
|
1893
|
-
`ActiveRecord::Base.pluralize_table_names` is `false`.
|
1577
|
+
NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
|
1894
1578
|
|
1895
|
-
|
1579
|
+
Now the message is:
|
1896
1580
|
|
1897
|
-
|
1581
|
+
ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
|
1898
1582
|
|
1899
|
-
*
|
1583
|
+
*Rafael Mendonça França*
|
1900
1584
|
|
1901
|
-
|
1585
|
+
* Fix change detection problem for PostgreSQL bytea type and
|
1586
|
+
`ArgumentError: string contains null byte` exception with pg-0.18.
|
1902
1587
|
|
1903
|
-
|
1904
|
-
Photo.last.touch(:signed_at, :sealed_at)
|
1588
|
+
Fixes #17680.
|
1905
1589
|
|
1906
|
-
*
|
1590
|
+
*Lars Kanis*
|
1907
1591
|
|
1908
|
-
*
|
1909
|
-
|
1592
|
+
* When a table has a composite primary key, the `primary_key` method for
|
1593
|
+
SQLite3 and PostgreSQL adapters was only returning the first field of the key.
|
1594
|
+
Ensures that it will return nil instead, as Active Record doesn't support
|
1595
|
+
composite primary keys.
|
1910
1596
|
|
1911
|
-
Fixes #
|
1597
|
+
Fixes #18070.
|
1912
1598
|
|
1913
|
-
*
|
1599
|
+
*arthurnn*
|
1914
1600
|
|
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.
|
1601
|
+
* `validates_size_of` / `validates_length_of` do not count records
|
1602
|
+
which are `marked_for_destruction?`.
|
1920
1603
|
|
1921
|
-
|
1604
|
+
Fixes #7247.
|
1922
1605
|
|
1923
|
-
*
|
1924
|
-
pointing to pg_class, and thus only sequence objects, are considered.
|
1606
|
+
*Yves Senn*
|
1925
1607
|
|
1926
|
-
|
1608
|
+
* Ensure `first!` and friends work on loaded associations.
|
1927
1609
|
|
1928
|
-
|
1610
|
+
Fixes #18237.
|
1929
1611
|
|
1930
|
-
|
1612
|
+
*Sean Griffin*
|
1931
1613
|
|
1932
|
-
|
1614
|
+
* `eager_load` preserves readonly flag for associations.
|
1933
1615
|
|
1934
|
-
|
1616
|
+
Fixes #15853.
|
1935
1617
|
|
1936
|
-
|
1618
|
+
*Takashi Kokubun*
|
1937
1619
|
|
1938
|
-
|
1939
|
-
|
1620
|
+
* Provide `:touch` option to `save()` to accommodate saving without updating
|
1621
|
+
timestamps.
|
1940
1622
|
|
1941
|
-
|
1623
|
+
Fixes #18202.
|
1942
1624
|
|
1943
|
-
*
|
1625
|
+
*Dan Olson*
|
1944
1626
|
|
1945
|
-
*
|
1627
|
+
* Provide a more helpful error message when an unsupported class is passed to
|
1628
|
+
`serialize`.
|
1946
1629
|
|
1947
|
-
Fixes #
|
1630
|
+
Fixes #18224.
|
1948
1631
|
|
1949
|
-
*
|
1632
|
+
*Sean Griffin*
|
1950
1633
|
|
1951
|
-
*
|
1952
|
-
Call `.id` on the object first.
|
1634
|
+
* Add bigint primary key support for MySQL.
|
1953
1635
|
|
1954
|
-
|
1636
|
+
Example:
|
1955
1637
|
|
1956
|
-
|
1957
|
-
|
1638
|
+
create_table :foos, id: :bigint do |t|
|
1639
|
+
end
|
1958
1640
|
|
1959
1641
|
*Ryuta Kamizono*
|
1960
1642
|
|
1961
|
-
* Support for
|
1643
|
+
* Support for any type of primary key.
|
1962
1644
|
|
1963
|
-
|
1645
|
+
Fixes #14194.
|
1964
1646
|
|
1965
|
-
*
|
1966
|
-
`where` values without needing to wrap in UPPER/LOWER sql functions.
|
1647
|
+
*Ryuta Kamizono*
|
1967
1648
|
|
1968
|
-
|
1649
|
+
* Dump the default `nil` for PostgreSQL UUID primary key.
|
1969
1650
|
|
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.
|
1651
|
+
*Ryuta Kamizono*
|
1973
1652
|
|
1974
|
-
|
1653
|
+
* Add a `:foreign_key` option to `references` and associated migration
|
1654
|
+
methods. The model and migration generators now use this option, rather than
|
1655
|
+
the `add_foreign_key` form.
|
1975
1656
|
|
1976
|
-
*
|
1657
|
+
*Sean Griffin*
|
1977
1658
|
|
1978
|
-
|
1659
|
+
* Don't raise when writing an attribute with an out-of-range datetime passed
|
1660
|
+
by the user.
|
1979
1661
|
|
1980
|
-
|
1662
|
+
*Grey Baker*
|
1981
1663
|
|
1982
|
-
|
1664
|
+
* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
|
1665
|
+
`ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
|
1983
1666
|
|
1984
|
-
*
|
1985
|
-
warnings on enum columns.
|
1667
|
+
*Yves Senn*
|
1986
1668
|
|
1987
|
-
|
1669
|
+
* Fix bug with `ActiveRecord::Type::Numeric` that caused negative values to
|
1670
|
+
be marked as having changed when set to the same negative value.
|
1988
1671
|
|
1989
|
-
|
1990
|
-
joins are involved.
|
1672
|
+
Fixes #18161.
|
1991
1673
|
|
1992
|
-
|
1674
|
+
*Daniel Fox*
|
1993
1675
|
|
1994
|
-
|
1676
|
+
* Introduce `force: :cascade` option for `create_table`. Using this option
|
1677
|
+
will recreate tables even if they have dependent objects (like foreign keys).
|
1678
|
+
`db/schema.rb` now uses `force: :cascade`. This makes it possible to
|
1679
|
+
reload the schema when foreign keys are in place.
|
1995
1680
|
|
1996
|
-
*
|
1997
|
-
any enum attribute is always evaluated as 0 during uniqueness validation.
|
1681
|
+
*Matthew Draper*, *Yves Senn*
|
1998
1682
|
|
1999
|
-
|
1683
|
+
* `db:schema:load` and `db:structure:load` no longer purge the database
|
1684
|
+
before loading the schema. This is left for the user to do.
|
1685
|
+
`db:test:prepare` will still purge the database.
|
2000
1686
|
|
2001
|
-
|
1687
|
+
Fixes #17945.
|
2002
1688
|
|
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.
|
1689
|
+
*Yves Senn*
|
2008
1690
|
|
2009
|
-
|
1691
|
+
* Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
|
2010
1692
|
|
2011
|
-
*
|
2012
|
-
private method defined on its ancestors.
|
1693
|
+
*Ryuta Kamizono*
|
2013
1694
|
|
2014
|
-
|
1695
|
+
* Add `foreign_type` option to `has_one` and `has_many` association macros.
|
2015
1696
|
|
2016
|
-
|
1697
|
+
This option enables to define the column name of associated object's type for polymorphic associations.
|
2017
1698
|
|
2018
|
-
*
|
1699
|
+
*Ulisses Almeida*, *Kassio Borges*
|
2019
1700
|
|
2020
|
-
|
1701
|
+
* Remove deprecated behavior allowing nested arrays to be passed as query
|
1702
|
+
values.
|
2021
1703
|
|
2022
|
-
|
2023
|
-
book.save!
|
2024
|
-
book.title # => "12345"
|
1704
|
+
*Melanie Gilman*
|
2025
1705
|
|
2026
|
-
|
1706
|
+
* Deprecate passing a class as a value in a query. Users should pass strings
|
1707
|
+
instead.
|
2027
1708
|
|
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.
|
1709
|
+
*Melanie Gilman*
|
2031
1710
|
|
2032
|
-
|
2033
|
-
|
2034
|
-
is not defined) it will raise an `ArgumentException` for ranges with excluding
|
2035
|
-
beginnings.
|
1711
|
+
* `add_timestamps` and `remove_timestamps` now properly reversible with
|
1712
|
+
options.
|
2036
1713
|
|
2037
|
-
*
|
1714
|
+
*Noam Gagliardi-Rabinovich*
|
2038
1715
|
|
2039
|
-
*
|
1716
|
+
* `ActiveRecord::ConnectionAdapters::ColumnDumper#column_spec` and
|
1717
|
+
`ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
|
1718
|
+
longer have a `types` argument. They should access
|
1719
|
+
`connection#native_database_types` directly.
|
2040
1720
|
|
2041
1721
|
*Yves Senn*
|
2042
1722
|
|
2043
|
-
Please check [4-
|
1723
|
+
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.
|