activerecord 3.1.12 → 3.2.22.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +804 -338
- data/README.rdoc +3 -3
- data/examples/performance.rb +20 -1
- data/lib/active_record/aggregations.rb +1 -1
- data/lib/active_record/associations/alias_tracker.rb +3 -6
- data/lib/active_record/associations/association.rb +13 -45
- data/lib/active_record/associations/association_scope.rb +3 -15
- data/lib/active_record/associations/belongs_to_association.rb +1 -1
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +2 -1
- data/lib/active_record/associations/builder/association.rb +6 -4
- data/lib/active_record/associations/builder/belongs_to.rb +7 -4
- data/lib/active_record/associations/builder/collection_association.rb +2 -2
- data/lib/active_record/associations/builder/has_many.rb +4 -4
- data/lib/active_record/associations/builder/has_one.rb +5 -6
- data/lib/active_record/associations/builder/singular_association.rb +3 -16
- data/lib/active_record/associations/collection_association.rb +65 -32
- data/lib/active_record/associations/collection_proxy.rb +8 -41
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +1 -0
- data/lib/active_record/associations/has_many_association.rb +11 -7
- data/lib/active_record/associations/has_many_through_association.rb +19 -9
- data/lib/active_record/associations/has_one_association.rb +23 -13
- data/lib/active_record/associations/join_dependency/join_association.rb +6 -1
- data/lib/active_record/associations/join_dependency.rb +3 -3
- data/lib/active_record/associations/preloader/through_association.rb +3 -3
- data/lib/active_record/associations/preloader.rb +14 -10
- data/lib/active_record/associations/through_association.rb +8 -4
- data/lib/active_record/associations.rb +92 -76
- data/lib/active_record/attribute_assignment.rb +221 -0
- data/lib/active_record/attribute_methods/deprecated_underscore_read.rb +32 -0
- data/lib/active_record/attribute_methods/dirty.rb +21 -11
- data/lib/active_record/attribute_methods/primary_key.rb +62 -25
- data/lib/active_record/attribute_methods/read.rb +73 -83
- data/lib/active_record/attribute_methods/serialization.rb +120 -0
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +12 -14
- data/lib/active_record/attribute_methods/write.rb +32 -6
- data/lib/active_record/attribute_methods.rb +231 -30
- data/lib/active_record/autosave_association.rb +44 -26
- data/lib/active_record/base.rb +227 -1708
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +150 -148
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +85 -29
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +7 -34
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +10 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +7 -4
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +39 -28
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +48 -19
- data/lib/active_record/connection_adapters/abstract_adapter.rb +77 -42
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +676 -0
- data/lib/active_record/connection_adapters/column.rb +37 -11
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +133 -581
- data/lib/active_record/connection_adapters/mysql_adapter.rb +136 -693
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +209 -97
- data/lib/active_record/connection_adapters/schema_cache.rb +69 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +2 -6
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +62 -35
- data/lib/active_record/counter_cache.rb +9 -4
- data/lib/active_record/dynamic_finder_match.rb +12 -0
- data/lib/active_record/dynamic_matchers.rb +84 -0
- data/lib/active_record/errors.rb +11 -1
- data/lib/active_record/explain.rb +86 -0
- data/lib/active_record/explain_subscriber.rb +25 -0
- data/lib/active_record/fixtures/file.rb +65 -0
- data/lib/active_record/fixtures.rb +57 -86
- data/lib/active_record/identity_map.rb +3 -4
- data/lib/active_record/inheritance.rb +174 -0
- data/lib/active_record/integration.rb +60 -0
- data/lib/active_record/locking/optimistic.rb +33 -26
- data/lib/active_record/locking/pessimistic.rb +23 -1
- data/lib/active_record/log_subscriber.rb +8 -4
- data/lib/active_record/migration/command_recorder.rb +8 -8
- data/lib/active_record/migration.rb +68 -35
- data/lib/active_record/model_schema.rb +368 -0
- data/lib/active_record/nested_attributes.rb +60 -24
- data/lib/active_record/persistence.rb +57 -11
- data/lib/active_record/query_cache.rb +6 -6
- data/lib/active_record/querying.rb +58 -0
- data/lib/active_record/railtie.rb +37 -29
- data/lib/active_record/railties/controller_runtime.rb +3 -1
- data/lib/active_record/railties/databases.rake +213 -117
- data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
- data/lib/active_record/readonly_attributes.rb +26 -0
- data/lib/active_record/reflection.rb +7 -15
- data/lib/active_record/relation/batches.rb +7 -4
- data/lib/active_record/relation/calculations.rb +55 -16
- data/lib/active_record/relation/delegation.rb +49 -0
- data/lib/active_record/relation/finder_methods.rb +16 -11
- data/lib/active_record/relation/predicate_builder.rb +8 -6
- data/lib/active_record/relation/query_methods.rb +75 -9
- data/lib/active_record/relation/spawn_methods.rb +48 -7
- data/lib/active_record/relation.rb +78 -32
- data/lib/active_record/result.rb +10 -4
- data/lib/active_record/sanitization.rb +194 -0
- data/lib/active_record/schema_dumper.rb +12 -5
- data/lib/active_record/scoping/default.rb +142 -0
- data/lib/active_record/scoping/named.rb +200 -0
- data/lib/active_record/scoping.rb +152 -0
- data/lib/active_record/serialization.rb +1 -43
- data/lib/active_record/serializers/xml_serializer.rb +4 -45
- data/lib/active_record/session_store.rb +18 -16
- data/lib/active_record/store.rb +52 -0
- data/lib/active_record/test_case.rb +11 -7
- data/lib/active_record/timestamp.rb +17 -3
- data/lib/active_record/transactions.rb +27 -6
- data/lib/active_record/translation.rb +22 -0
- data/lib/active_record/validations/associated.rb +5 -4
- data/lib/active_record/validations/uniqueness.rb +8 -8
- data/lib/active_record/validations.rb +1 -1
- data/lib/active_record/version.rb +3 -3
- data/lib/active_record.rb +38 -3
- data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb +12 -3
- data/lib/rails/generators/active_record/model/model_generator.rb +9 -1
- data/lib/rails/generators/active_record/model/templates/migration.rb +3 -5
- data/lib/rails/generators/active_record/model/templates/model.rb +5 -0
- data/lib/rails/generators/active_record/session_migration/templates/migration.rb +1 -5
- metadata +49 -28
- data/lib/active_record/named_scope.rb +0 -200
data/CHANGELOG.md
CHANGED
@@ -1,548 +1,1014 @@
|
|
1
|
-
##
|
1
|
+
## Rails 3.2.22 (Jun 16, 2015) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
compared to string columns.' This caused several regressions.
|
3
|
+
* No changes.
|
5
4
|
|
6
|
-
*Steve Klabnik*
|
7
5
|
|
8
|
-
## Rails 3.
|
6
|
+
## Rails 3.2.19 (Jul 2, 2014) ##
|
9
7
|
|
10
|
-
*
|
11
|
-
in some database, the string column values will be coerced to a numeric
|
12
|
-
allowing 0, 0.0 or false to match any string starting with a non-digit.
|
8
|
+
* Fix SQL Injection Vulnerability in 'bitstring' quoting.
|
13
9
|
|
14
|
-
|
10
|
+
Fixes CVE-2014-3482.
|
15
11
|
|
16
|
-
|
12
|
+
*Rafael Mendonça França*
|
17
13
|
|
18
|
-
*Dylan Smith*
|
19
14
|
|
20
|
-
## Rails 3.
|
15
|
+
## Rails 3.2.18 (May 6, 2014) ##
|
21
16
|
|
22
|
-
*
|
17
|
+
* No changes.
|
23
18
|
|
24
|
-
## Rails 3.1.9 (Jan 2, 2013) ##
|
25
19
|
|
26
|
-
|
20
|
+
## Rails 3.2.17 (Feb 18, 2014) ##
|
27
21
|
|
28
|
-
|
22
|
+
* No changes.
|
29
23
|
|
30
|
-
* No changes.
|
31
24
|
|
32
|
-
## Rails 3.
|
25
|
+
## Rails 3.2.16 (Dec 3, 2013) ##
|
33
26
|
|
34
|
-
*
|
27
|
+
* No changes.
|
35
28
|
|
36
|
-
## Rails 3.1.6 (Jun 12, 2012) ##
|
37
29
|
|
38
|
-
|
39
|
-
table context in the next call to build_from_hash. This fix
|
40
|
-
covers this case as well.
|
30
|
+
## Rails 3.2.15 (Oct 16, 2013) ##
|
41
31
|
|
42
|
-
|
32
|
+
* When calling the method .find_or_initialize_by_* from a collection_proxy
|
33
|
+
it should set the inverse_of relation even when the entry was found on the db.
|
43
34
|
|
44
|
-
|
35
|
+
*arthurnn*
|
45
36
|
|
46
|
-
*
|
37
|
+
* Callbacks on has_many should access the in memory parent if a inverse_of is set.
|
47
38
|
|
48
|
-
*
|
39
|
+
*arthurnn*
|
49
40
|
|
50
|
-
*
|
41
|
+
* Fix `FinderMethods#last` unscoped primary key.
|
51
42
|
|
52
|
-
|
53
|
-
Thanks to Ben Murphy for reporting this! CVE-2012-2661
|
43
|
+
Fixes #11917.
|
54
44
|
|
55
|
-
|
45
|
+
*Eugene Kalenkovich*
|
56
46
|
|
57
|
-
*
|
47
|
+
* Load fixtures from linked folders.
|
58
48
|
|
59
|
-
*
|
49
|
+
*Kassio Borges*
|
60
50
|
|
61
|
-
*
|
62
|
-
|
51
|
+
* When using optimistic locking, `update` was not passing the column to `quote_value`
|
52
|
+
to allow the connection adapter to properly determine how to quote the value. This was
|
53
|
+
affecting certain databases that use specific colmn types.
|
63
54
|
|
64
|
-
|
55
|
+
Fixes: #6763
|
65
56
|
|
66
|
-
*
|
67
|
-
where the calls are chained. *GH #3890*
|
57
|
+
*Alfred Wong*
|
68
58
|
|
69
|
-
(E.g. `post.comments.where(bla).my_proxy_method`)
|
70
59
|
|
71
|
-
|
60
|
+
## Rails 3.2.14 (Jul 22, 2013) ##
|
72
61
|
|
73
|
-
*
|
74
|
-
|
62
|
+
* Fix merge error when Equality LHS is non-attribute.
|
63
|
+
Backport of #7380.
|
75
64
|
|
76
|
-
*
|
65
|
+
*Karmes Alexander*
|
77
66
|
|
78
|
-
*
|
67
|
+
* Do not re-create destroyed association when saving the parent object.
|
79
68
|
|
80
|
-
|
69
|
+
Fixes #11450.
|
81
70
|
|
82
|
-
|
71
|
+
*Paul Nikitochkin*
|
83
72
|
|
84
|
-
*
|
85
|
-
to the query. *GH 3672*
|
73
|
+
* Do not shallow the original exception in `exec_cache` on PostgreSQL adapter.
|
86
74
|
|
87
|
-
|
75
|
+
Fixes #11260.
|
88
76
|
|
89
|
-
*
|
77
|
+
*Rafael Mendonça França*
|
90
78
|
|
91
|
-
* Fix
|
79
|
+
* Fix `ActiveRecord::Store` incorrectly tracking changes of its attributes.
|
80
|
+
Fixes #10373.
|
92
81
|
|
93
|
-
*
|
82
|
+
*Janko Marohnić*
|
94
83
|
|
95
|
-
|
84
|
+
* Fix a bug that prevented the use of the default STI inheritance column
|
85
|
+
(ActiveRecord::Base.inheritance_column = 'some_column'.)
|
96
86
|
|
97
|
-
*
|
98
|
-
*GH #3232*
|
87
|
+
*chapmajs + Takehiro Adachi*
|
99
88
|
|
100
|
-
|
89
|
+
* Fix mysql2 adapter raises the correct exception when executing a query on a
|
90
|
+
closed connection.
|
101
91
|
|
102
|
-
*
|
103
|
-
were not being stripped from the schema names after the first.
|
92
|
+
*Yves Senn*
|
104
93
|
|
105
|
-
|
94
|
+
* Fixes bug where `Company.new.contract_ids` would incorrectly load
|
95
|
+
all non-associated contracts.
|
106
96
|
|
107
|
-
|
97
|
+
Example:
|
108
98
|
|
109
|
-
|
99
|
+
company = Company.new # Company has many :contracts
|
110
100
|
|
111
|
-
|
101
|
+
# before
|
102
|
+
company.contract_ids # => SELECT ... WHERE `contracts`.`company_id` IS NULL
|
112
103
|
|
113
|
-
|
104
|
+
# after
|
105
|
+
company.contract_ids # => []
|
114
106
|
|
115
|
-
*
|
107
|
+
*Jared Armstrong*
|
116
108
|
|
117
|
-
|
109
|
+
* Fix the `:primary_key` option for `has_many` associations.
|
110
|
+
Fixes #10693.
|
118
111
|
|
119
|
-
*
|
112
|
+
*Yves Senn*
|
120
113
|
|
121
|
-
|
114
|
+
* fixes bug introduced by #3329. Now, when autosaving associations,
|
115
|
+
deletions happen before inserts and saves. This prevents a 'duplicate
|
116
|
+
unique value' database error that would occur if a record being created had
|
117
|
+
the same value on a unique indexed field as that of a record being destroyed.
|
122
118
|
|
123
|
-
|
124
|
-
modify the conditions of the through and/or source association. If you have experienced
|
125
|
-
bugs with conditions appearing in the wrong queries when using nested through associations,
|
126
|
-
this probably solves your problems. *GH #3271*
|
119
|
+
Backport of #10417
|
127
120
|
|
128
|
-
*
|
121
|
+
*Johnny Holton*
|
129
122
|
|
130
|
-
*
|
131
|
-
|
123
|
+
* Fix that under some conditions, Active Record could produce invalid SQL of the sort:
|
124
|
+
"SELECT DISTINCT DISTINCT".
|
132
125
|
|
133
|
-
|
126
|
+
Backport of #6792.
|
134
127
|
|
135
|
-
*
|
128
|
+
*Ben Woosley*
|
136
129
|
|
137
|
-
|
130
|
+
* Require `ActiveRecord::Base` in railtie hooks for rake_tasks, console and runner to
|
131
|
+
avoid circular constant loading issues.
|
138
132
|
|
139
|
-
|
133
|
+
Backport #7695.
|
140
134
|
|
141
|
-
|
135
|
+
Fixes #7683 and #882
|
142
136
|
|
143
|
-
*
|
144
|
-
*Kenny J*
|
137
|
+
*Ben Holley*
|
145
138
|
|
146
|
-
|
139
|
+
* Maintain context for joins within ActiveRecord::Relation merges.
|
140
|
+
Backport #10164.
|
147
141
|
|
148
|
-
*
|
149
|
-
but unknown. Fixes #3207.
|
142
|
+
*Neeraj Singh + Andrew Horner*
|
150
143
|
|
151
|
-
|
144
|
+
* Make sure the `EXPLAIN` command is never triggered by a `select_db` call.
|
152
145
|
|
153
|
-
*
|
146
|
+
*Daniel Schierbeck*
|
154
147
|
|
155
|
-
|
148
|
+
* Revert changes on `pluck` that was ignoring the select clause when the relation already
|
149
|
+
has one. This caused a regression since it changed the behavior in a stable release.
|
156
150
|
|
157
|
-
|
151
|
+
Fixes #9777.
|
158
152
|
|
159
|
-
*
|
153
|
+
*Rafael Mendonça França*
|
160
154
|
|
161
|
-
*
|
162
|
-
\#2923.
|
155
|
+
* Confirm a record has not already been destroyed before decrementing counter cache.
|
163
156
|
|
164
|
-
*
|
157
|
+
*Ben Tucker*
|
165
158
|
|
166
|
-
*
|
159
|
+
* Default values for PostgreSQL bigint types now get parsed and dumped to the
|
160
|
+
schema correctly.
|
161
|
+
Backport #10098.
|
167
162
|
|
168
|
-
*
|
163
|
+
*Erik Peterson*
|
169
164
|
|
170
|
-
*
|
171
|
-
|
165
|
+
* Removed warning when `auto_explain_threshold_in_seconds` is set and the
|
166
|
+
connection adapter doesn't support explain.
|
167
|
+
This is causing a regression since the Active Record Railtie is trying to
|
168
|
+
connect to the development database in the application boot.
|
172
169
|
|
173
|
-
*
|
170
|
+
*Rafael Mendonça França*
|
174
171
|
|
175
|
-
*
|
172
|
+
* Do not reset `inheritance_column` when it's set explicitly.
|
173
|
+
Backport of #5327.
|
176
174
|
|
177
|
-
*
|
178
|
-
keys are per process id.
|
179
|
-
* lib/active_record/connection_adapters/sqlite_adapter.rb: ditto
|
175
|
+
*kennyj + Fred Wu*
|
180
176
|
|
181
|
-
|
177
|
+
* Fix a problem wrong exception is occured
|
178
|
+
when raising no translatable exception in PostgreSQL.
|
182
179
|
|
183
|
-
*
|
184
|
-
prepared statments on the database. The limit defaults to 1000, but can
|
185
|
-
be adjusted in your database config by changing 'statement_limit'.
|
180
|
+
*kennyj*
|
186
181
|
|
187
|
-
*
|
188
|
-
|
182
|
+
* Resets the postgres search path in the structure.sql after the structure
|
183
|
+
is dumped in order to find schema_migrations table when multiples schemas
|
184
|
+
are used.
|
185
|
+
Fixes #9796.
|
189
186
|
|
190
|
-
*
|
191
|
-
Fixes GH #2755, where a counter cache could be decremented twice as far as it was supposed to be.
|
187
|
+
*Juan M. Cuello + Dembskiy Alexander*
|
192
188
|
|
193
|
-
|
189
|
+
* Reload the association target if it's stale. `@stale_state` should be nil
|
190
|
+
when a model isn't saved.
|
191
|
+
Fixes #7526.
|
194
192
|
|
195
|
-
*
|
196
|
-
GH #2828. *Georg Friedrich*
|
193
|
+
*Larry Lv*
|
197
194
|
|
198
|
-
*
|
195
|
+
* Don't read CSV files during execution of `db:fixtures:load`. CSV support for
|
196
|
+
fixtures was removed some time ago but the task was still loading them, even
|
197
|
+
though later the code was looking for the related yaml file instead.
|
199
198
|
|
200
|
-
*
|
201
|
-
in an abstract class. See GH #2791. *Akira Matsuda*
|
199
|
+
*kennyj*
|
202
200
|
|
203
|
-
* Psych errors with poor yaml formatting are proxied. Fixes GH #2645 and
|
204
|
-
GH #2731
|
205
201
|
|
206
|
-
|
202
|
+
## Rails 3.2.13 (Mar 18, 2013) ##
|
207
203
|
|
208
|
-
|
204
|
+
* Chaining multiple preloaded scopes will correctly preload all the scopes
|
205
|
+
at the same time.
|
209
206
|
|
210
|
-
*
|
211
|
-
extensions to access information about the association. This replaces proxy_owner etc with
|
212
|
-
proxy_association.owner.
|
207
|
+
*Chris Geihsler*
|
213
208
|
|
214
|
-
|
209
|
+
* Reverted 921a296a3390192a71abeec6d9a035cc6d1865c8, 'Quote numeric values
|
210
|
+
compared to string columns.' This caused several regressions.
|
211
|
+
|
212
|
+
*Steve Klabnik*
|
215
213
|
|
216
|
-
*
|
214
|
+
* Fix overriding of attributes by `default_scope` on `ActiveRecord::Base#dup`.
|
217
215
|
|
218
|
-
*
|
219
|
-
to use, though be warned that this is not really a public API.
|
216
|
+
*Hiroshige UMINO*
|
220
217
|
|
221
|
-
|
222
|
-
|
218
|
+
* Fix issue with overriding Active Record reader methods with a composed object
|
219
|
+
and using that attribute as the scope of a `uniqueness_of` validation.
|
220
|
+
Backport #7072.
|
223
221
|
|
224
|
-
*
|
222
|
+
*Peter Brown*
|
225
223
|
|
226
|
-
*
|
224
|
+
* Sqlite now preserves custom primary keys when copying or altering tables.
|
225
|
+
Fixes #9367.
|
226
|
+
Backport #2312.
|
227
227
|
|
228
|
-
|
229
|
-
After: def build_association(*options, &block)
|
228
|
+
*Sean Scally + Yves Senn*
|
230
229
|
|
231
|
-
|
232
|
-
|
230
|
+
* Preloading `has_many :through` associations with conditions won't
|
231
|
+
cache the `:through` association. This will prevent invalid
|
232
|
+
subsets to be cached.
|
233
|
+
Fixes #8423.
|
234
|
+
Backport #9252.
|
233
235
|
|
234
|
-
|
236
|
+
Example:
|
235
237
|
|
236
|
-
|
237
|
-
|
238
|
+
class User
|
239
|
+
has_many :posts
|
240
|
+
has_many :recent_comments, -> { where('created_at > ?', 1.week.ago) }, :through => :posts
|
241
|
+
end
|
238
242
|
|
239
|
-
|
243
|
+
a_user = User.includes(:recent_comments).first
|
240
244
|
|
241
|
-
|
245
|
+
# this is preloaded
|
246
|
+
a_user.recent_comments
|
242
247
|
|
243
|
-
|
244
|
-
|
248
|
+
# fetching the recent_comments through the posts association won't preload it.
|
249
|
+
a_user.posts
|
250
|
+
|
251
|
+
*Yves Senn*
|
252
|
+
|
253
|
+
* Fix handling of dirty time zone aware attributes
|
254
|
+
|
255
|
+
Previously, when `time_zone_aware_attributes` were enabled, after
|
256
|
+
changing a datetime or timestamp attribute and then changing it back
|
257
|
+
to the original value, `changed_attributes` still tracked the
|
258
|
+
attribute as changed. This caused `[attribute]_changed?` and
|
259
|
+
`changed?` methods to return true incorrectly.
|
260
|
+
|
261
|
+
Example:
|
262
|
+
|
263
|
+
in_time_zone 'Paris' do
|
264
|
+
order = Order.new
|
265
|
+
original_time = Time.local(2012, 10, 10)
|
266
|
+
order.shipped_at = original_time
|
267
|
+
order.save
|
268
|
+
order.changed? # => false
|
269
|
+
|
270
|
+
# changing value
|
271
|
+
order.shipped_at = Time.local(2013, 1, 1)
|
272
|
+
order.changed? # => true
|
273
|
+
|
274
|
+
# reverting to original value
|
275
|
+
order.shipped_at = original_time
|
276
|
+
order.changed? # => false, used to return true
|
245
277
|
end
|
246
278
|
|
247
|
-
|
279
|
+
Backport of #9073
|
280
|
+
Fixes #8898
|
281
|
+
|
282
|
+
*Lilibeth De La Cruz*
|
283
|
+
|
284
|
+
* Fix counter cache columns not updated when replacing `has_many :through`
|
285
|
+
associations.
|
286
|
+
Backport #8400.
|
287
|
+
Fix #7630.
|
288
|
+
|
289
|
+
*Matthew Robertson*
|
290
|
+
|
291
|
+
* Don't update `column_defaults` when calling destructive methods on column with default value.
|
292
|
+
Backport c517602.
|
293
|
+
Fix #6115.
|
294
|
+
|
295
|
+
*Piotr Sarnacki + Aleksey Magusev + Alan Daud*
|
296
|
+
|
297
|
+
* When `#count` is used in conjunction with `#uniq` we perform `count(:distinct => true)`.
|
298
|
+
Fix #6865.
|
299
|
+
|
300
|
+
Example:
|
301
|
+
|
302
|
+
relation.uniq.count # => SELECT COUNT(DISTINCT *)
|
303
|
+
|
304
|
+
*Yves Senn + Kaspar Schiess*
|
305
|
+
|
306
|
+
* Fix `ActiveRecord::Relation#pluck` when columns or tables are reserved words.
|
307
|
+
Backport #7536.
|
308
|
+
Fix #8968.
|
309
|
+
|
310
|
+
*Ian Lesperance + Yves Senn + Kaspar Schiess*
|
311
|
+
|
312
|
+
* Don't run explain on slow queries for database adapters that don't support it.
|
313
|
+
Backport #6197.
|
314
|
+
|
315
|
+
*Blake Smith*
|
316
|
+
|
317
|
+
* Revert round usec when comparing timestamp attributes in the dirty tracking.
|
318
|
+
Fixes #8460.
|
319
|
+
|
320
|
+
*Andrew White*
|
321
|
+
|
322
|
+
* Revert creation of through association models when using `collection=[]`
|
323
|
+
on a `has_many :through` association from an unsaved model.
|
324
|
+
Fix #7661, #8269.
|
325
|
+
|
326
|
+
*Ernie Miller*
|
327
|
+
|
328
|
+
* Fix undefined method `to_i` when calling `new` on a scope that uses an
|
329
|
+
Array; Fix FloatDomainError when setting integer column to NaN.
|
330
|
+
Fixes #8718, #8734, #8757.
|
331
|
+
|
332
|
+
*Jason Stirk + Tristan Harward*
|
333
|
+
|
334
|
+
* Serialized attributes can be serialized in integer columns.
|
335
|
+
Fix #8575.
|
336
|
+
|
337
|
+
*Rafael Mendonça França*
|
248
338
|
|
249
|
-
*
|
339
|
+
* Keep index names when using `alter_table` with sqlite3.
|
340
|
+
Fix #3489.
|
341
|
+
Backport #8522.
|
342
|
+
|
343
|
+
*Yves Senn*
|
344
|
+
|
345
|
+
* Recognize migrations placed in directories containing numbers and 'rb'.
|
346
|
+
Fix #8492.
|
347
|
+
Backport of #8500.
|
348
|
+
|
349
|
+
*Yves Senn*
|
350
|
+
|
351
|
+
* Add `ActiveRecord::Base.cache_timestamp_format` class attribute to control
|
352
|
+
the format of the timestamp value in the cache key.
|
353
|
+
This allows users to improve the precision of the cache key.
|
354
|
+
Fixes #8195.
|
355
|
+
|
356
|
+
*Rafael Mendonça França*
|
357
|
+
|
358
|
+
* Add `:nsec` date format. This can be used to improve the precision of cache key.
|
359
|
+
Please note that this format only works with Ruby 1.9, Ruby 1.8 will ignore it completely.
|
360
|
+
|
361
|
+
*Jamie Gaskins*
|
362
|
+
|
363
|
+
* Unscope `update_column(s)` query to ignore default scope.
|
364
|
+
|
365
|
+
When applying `default_scope` to a class with a where clause, using
|
366
|
+
`update_column(s)` could generate a query that would not properly update
|
367
|
+
the record due to the where clause from the `default_scope` being applied
|
368
|
+
to the update query.
|
250
369
|
|
251
370
|
class User < ActiveRecord::Base
|
252
|
-
|
371
|
+
default_scope where(active: true)
|
253
372
|
end
|
254
373
|
|
255
|
-
user
|
374
|
+
user = User.first
|
375
|
+
user.active = false
|
376
|
+
user.save!
|
256
377
|
|
257
|
-
|
378
|
+
user.update_column(:active, true) # => false
|
258
379
|
|
259
|
-
|
380
|
+
In this situation we want to skip the default_scope clause and just
|
381
|
+
update the record based on the primary key. With this change:
|
260
382
|
|
261
|
-
|
383
|
+
user.update_column(:active, true) # => true
|
262
384
|
|
263
|
-
|
264
|
-
to specify which role to consider when assigning attributes. This is built on top of ActiveModel's
|
265
|
-
new mass assignment capabilities:
|
385
|
+
Backport of #8436 fix.
|
266
386
|
|
267
|
-
|
268
|
-
attr_accessible :title
|
269
|
-
attr_accessible :title, :published_at, :as => :admin
|
270
|
-
end
|
387
|
+
*Carlos Antonio da Silva*
|
271
388
|
|
272
|
-
|
389
|
+
* Fix performance problem with primary_key method in PostgreSQL adapter when having many schemas.
|
390
|
+
Uses pg_constraint table instead of pg_depend table which has many records in general.
|
391
|
+
Fix #8414
|
273
392
|
|
274
|
-
|
393
|
+
*kennyj*
|
275
394
|
|
276
|
-
|
395
|
+
* Do not instantiate intermediate Active Record objects when eager loading.
|
396
|
+
These records caused `after_find` to run more than expected.
|
397
|
+
Fix #3313
|
398
|
+
Backport of #8403
|
277
399
|
|
278
|
-
*
|
400
|
+
*Yves Senn*
|
279
401
|
|
280
|
-
*
|
281
|
-
evaluation:
|
402
|
+
* Fix `pluck` to work with joins. Backport of #4942.
|
282
403
|
|
283
|
-
|
284
|
-
default_scope lambda { ... }
|
285
|
-
default_scope method(:foo)
|
404
|
+
*Carlos Antonio da Silva*
|
286
405
|
|
287
|
-
|
288
|
-
|
289
|
-
The relevant lighthouse ticket is #1812.
|
406
|
+
* Fix a problem with `translate_exception` method in a non English environment.
|
407
|
+
Backport of #6397.
|
290
408
|
|
291
|
-
*
|
292
|
-
scopes would be created which would implicitly contain the default scope, which would then
|
293
|
-
be impossible to get rid of via Model.unscoped.
|
409
|
+
*kennyj*
|
294
410
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
411
|
+
* Fix dirty attribute checks for TimeZoneConversion with nil and blank
|
412
|
+
datetime attributes. Setting a nil datetime to a blank string should not
|
413
|
+
result in a change being flagged.
|
414
|
+
Fixes #8310.
|
415
|
+
Backport of #8311.
|
299
416
|
|
300
|
-
*
|
417
|
+
*Alisdair McDiarmid*
|
301
418
|
|
302
|
-
*
|
303
|
-
|
304
|
-
|
419
|
+
* Prevent mass assignment to the type column of polymorphic associations when using `build`.
|
420
|
+
Fixes #8265.
|
421
|
+
Backport of #8291.
|
305
422
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
423
|
+
*Yves Senn*
|
424
|
+
|
425
|
+
* When running migrations on Postgresql, the `:limit` option for `binary` and `text` columns is
|
426
|
+
silently dropped.
|
427
|
+
Previously, these migrations caused sql exceptions, because Postgresql doesn't support limits
|
428
|
+
on these types.
|
429
|
+
|
430
|
+
*Victor Costan*
|
431
|
+
|
432
|
+
* `#pluck` can be used on a relation with `select` clause.
|
433
|
+
Fixes #7551.
|
434
|
+
Backport of #8176.
|
435
|
+
|
436
|
+
Example:
|
437
|
+
|
438
|
+
Topic.select([:approved, :id]).order(:id).pluck(:id)
|
439
|
+
|
440
|
+
*Yves Senn*
|
441
|
+
|
442
|
+
* Use `nil?` instead of `blank?` to check whether dynamic finder with a bang
|
443
|
+
should raise RecordNotFound.
|
444
|
+
Fixes #7238.
|
445
|
+
|
446
|
+
*Nikita Afanasenko*
|
447
|
+
|
448
|
+
* Fix deleting from a HABTM join table upon destroying an object of a model
|
449
|
+
with optimistic locking enabled.
|
450
|
+
Fixes #5332.
|
451
|
+
|
452
|
+
*Nick Rogers*
|
453
|
+
|
454
|
+
* Use query cache/uncache when using ENV["DATABASE_URL"].
|
455
|
+
Fixes #6951.
|
456
|
+
Backport of #8074.
|
457
|
+
|
458
|
+
*kennyj*
|
459
|
+
|
460
|
+
* Do not create useless database transaction when building `has_one` association.
|
461
|
+
|
462
|
+
Example:
|
463
|
+
|
464
|
+
User.has_one :profile
|
465
|
+
User.new.build_profile
|
466
|
+
|
467
|
+
Backport of #8154.
|
468
|
+
|
469
|
+
*Bogdan Gusiev*
|
470
|
+
|
471
|
+
* `AR::Base#attributes_before_type_cast` now returns unserialized values for serialized attributes.
|
472
|
+
|
473
|
+
*Nikita Afanasenko*
|
474
|
+
|
475
|
+
* Fix issue that raises `NameError` when overriding the `accepts_nested_attributes` in child classes.
|
476
|
+
|
477
|
+
Before:
|
478
|
+
|
479
|
+
class Shared::Person < ActiveRecord::Base
|
480
|
+
has_one :address
|
481
|
+
|
482
|
+
accepts_nested_attributes :address, :reject_if => :all_blank
|
310
483
|
end
|
311
484
|
|
312
|
-
|
485
|
+
class Person < Shared::Person
|
486
|
+
accepts_nested_attributes :address
|
487
|
+
end
|
488
|
+
|
489
|
+
Person
|
490
|
+
#=> NameError: method `address_attributes=' not defined in Person
|
491
|
+
|
492
|
+
After:
|
493
|
+
|
494
|
+
Person
|
495
|
+
#=> Person(id: integer, ...)
|
496
|
+
|
497
|
+
Fixes #8131.
|
313
498
|
|
314
|
-
*
|
499
|
+
*Gabriel Sobrinho, Ricardo Henrique*
|
315
500
|
|
316
|
-
* ConnectionManagement middleware is changed to clean up the connection pool
|
317
|
-
after the rack body has been flushed.
|
318
501
|
|
319
|
-
|
320
|
-
|
321
|
-
|
502
|
+
## Rails 3.2.12 (Feb 11, 2013) ##
|
503
|
+
|
504
|
+
* Quote numeric values being compared to non-numeric columns. Otherwise,
|
505
|
+
in some database, the string column values will be coerced to a numeric
|
506
|
+
allowing 0, 0.0 or false to match any string starting with a non-digit.
|
507
|
+
|
322
508
|
Example:
|
323
509
|
|
324
|
-
|
510
|
+
App.where(apikey: 0) # => SELECT * FROM users WHERE apikey = '0'
|
325
511
|
|
326
|
-
*
|
512
|
+
*Dylan Smith*
|
327
513
|
|
328
|
-
* Associations with a :through option can now use *any* association as the
|
329
|
-
through or source association, including other associations which have a
|
330
|
-
:through option and has_and_belongs_to_many associations
|
331
514
|
|
332
|
-
|
515
|
+
## Rails 3.2.11 (Jan 8, 2013) ##
|
333
516
|
|
334
|
-
*
|
335
|
-
ActiveRecord::Base.connection_config. *fxn*
|
517
|
+
* Fix querying with an empty hash *Damien Mathieu* [CVE-2013-0155]
|
336
518
|
|
337
|
-
* limits and offsets are removed from COUNT queries unless both are supplied.
|
338
|
-
For example:
|
339
519
|
|
340
|
-
|
341
|
-
People.offset(1).count # => 'SELECT COUNT(*) FROM people'
|
342
|
-
People.limit(1).offset(1).count # => 'SELECT COUNT(*) FROM people LIMIT 1 OFFSET 1'
|
520
|
+
## Rails 3.2.10 (Jan 2, 2013) ##
|
343
521
|
|
344
|
-
|
522
|
+
* CVE-2012-5664 options hashes should only be extracted if there are extra
|
523
|
+
parameters
|
345
524
|
|
346
|
-
* ActiveRecord::Associations::AssociationProxy has been split. There is now an Association class
|
347
|
-
(and subclasses) which are responsible for operating on associations, and then a separate,
|
348
|
-
thin wrapper called CollectionProxy, which proxies collection associations.
|
349
525
|
|
350
|
-
|
526
|
+
## Rails 3.2.9 (Nov 12, 2012) ##
|
351
527
|
|
352
|
-
|
353
|
-
the associated record or nil. This means that you should not use undocumented methods such
|
354
|
-
as bob.mother.create - use bob.create_mother instead.
|
528
|
+
* Fix `find_in_batches` crashing when IDs are strings and start option is not specified.
|
355
529
|
|
356
|
-
*
|
530
|
+
*Alexis Bernard*
|
531
|
+
|
532
|
+
* Fix issue with collection associations calling first(n)/last(n) and attempting
|
533
|
+
to set the inverse association when `:inverse_of` was used. Fixes #8087.
|
534
|
+
|
535
|
+
*Carlos Antonio da Silva*
|
536
|
+
|
537
|
+
* Fix bug when Column is trying to type cast boolean values to integer.
|
538
|
+
Fixes #8067.
|
539
|
+
|
540
|
+
*Rafael Mendonça França*
|
541
|
+
|
542
|
+
* Fix bug where `rake db:test:prepare` tries to load the structure.sql into development database.
|
543
|
+
Fixes #8032.
|
544
|
+
|
545
|
+
*Grace Liu + Rafael Mendonça França*
|
546
|
+
|
547
|
+
* Fixed support for `DATABASE_URL` environment variable for rake db tasks. *Grace Liu*
|
548
|
+
|
549
|
+
* Fix bug where `update_columns` and `update_column` would not let you update the primary key column.
|
550
|
+
|
551
|
+
*Henrik Nyh*
|
552
|
+
|
553
|
+
* Decode URI encoded attributes on database connection URLs.
|
554
|
+
|
555
|
+
*Shawn Veader*
|
556
|
+
|
557
|
+
* Fix AR#dup to nullify the validation errors in the dup'ed object. Previously the original
|
558
|
+
and the dup'ed object shared the same errors.
|
559
|
+
|
560
|
+
*Christian Seiler*
|
561
|
+
|
562
|
+
* Synchronize around deleting from the reserved connections hash.
|
563
|
+
Fixes #7955
|
564
|
+
|
565
|
+
* PostgreSQL adapter correctly fetches default values when using
|
566
|
+
multiple schemas and domains in a db. Fixes #7914
|
567
|
+
|
568
|
+
*Arturo Pie*
|
357
569
|
|
358
|
-
*
|
359
|
-
|
570
|
+
* Fix deprecation notice when loading a collection association that
|
571
|
+
selects columns from other tables, if a new record was previously
|
572
|
+
built using that association.
|
360
573
|
|
361
|
-
|
362
|
-
has_many :taggings
|
363
|
-
has_many :tags, :through => :taggings
|
364
|
-
end
|
574
|
+
*Ernie Miller*
|
365
575
|
|
366
|
-
|
367
|
-
|
368
|
-
belongs_to :tag, :inverse_of => :tagging # :inverse_of must be set!
|
369
|
-
end
|
576
|
+
* The postgres adapter now supports tables with capital letters.
|
577
|
+
Fix #5920
|
370
578
|
|
371
|
-
|
372
|
-
has_many :taggings
|
373
|
-
has_many :posts, :through => :taggings
|
374
|
-
end
|
579
|
+
*Yves Senn*
|
375
580
|
|
376
|
-
|
377
|
-
|
378
|
-
|
581
|
+
* `CollectionAssociation#count` returns `0` without querying if the
|
582
|
+
parent record is not persisted.
|
583
|
+
|
584
|
+
Before:
|
585
|
+
|
586
|
+
person.pets.count
|
587
|
+
# SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" IS NULL
|
588
|
+
# => 0
|
589
|
+
|
590
|
+
After:
|
591
|
+
|
592
|
+
person.pets.count
|
593
|
+
# fires without sql query
|
594
|
+
# => 0
|
595
|
+
|
596
|
+
*Francesco Rodriguez*
|
597
|
+
|
598
|
+
* Fix `reset_counters` crashing on `has_many :through` associations.
|
599
|
+
Fix #7822.
|
600
|
+
|
601
|
+
*lulalala*
|
602
|
+
|
603
|
+
* ConnectionPool recognizes checkout_timeout spec key as taking
|
604
|
+
precedence over legacy wait_timeout spec key, can be used to avoid
|
605
|
+
conflict with mysql2 use of wait_timeout. Closes #7684.
|
606
|
+
|
607
|
+
*jrochkind*
|
608
|
+
|
609
|
+
* Rename field_changed? to _field_changed? so that users can create a field named field
|
610
|
+
|
611
|
+
*Akira Matsuda*, backported by *Steve Klabnik*
|
612
|
+
|
613
|
+
* Fix creation of through association models when using `collection=[]`
|
614
|
+
on a `has_many :through` association from an unsaved model.
|
615
|
+
Fix #7661.
|
616
|
+
|
617
|
+
*Ernie Miller*
|
618
|
+
|
619
|
+
* Explain only normal CRUD sql (select / update / insert / delete).
|
620
|
+
Fix problem that explains unexplainable sql. Closes #7544 #6458.
|
621
|
+
|
622
|
+
*kennyj*
|
623
|
+
|
624
|
+
* Backport test coverage to ensure that PostgreSQL auto-reconnect functionality
|
625
|
+
remains healthy.
|
626
|
+
|
627
|
+
*Steve Jorgensen*
|
628
|
+
|
629
|
+
* Use config['encoding'] instead of config['charset'] when executing
|
630
|
+
databases.rake in the mysql/mysql2. A correct option for a database.yml
|
631
|
+
is 'encoding'.
|
632
|
+
|
633
|
+
*kennyj*
|
634
|
+
|
635
|
+
* Fix ConnectionAdapters::Column.type_cast_code integer conversion,
|
636
|
+
to always convert values to integer calling #to_i. Fixes #7509.
|
637
|
+
|
638
|
+
*Thiago Pradi*
|
639
|
+
|
640
|
+
* Fix time column type casting for invalid time string values to correctly return nil.
|
641
|
+
|
642
|
+
*Adam Meehan*
|
643
|
+
|
644
|
+
* Fix `becomes` when using a configured `inheritance_column`.
|
645
|
+
|
646
|
+
*Yves Senn*
|
647
|
+
|
648
|
+
* Fix `reset_counters` when there are multiple `belongs_to` association with the
|
649
|
+
same foreign key and one of them have a counter cache.
|
650
|
+
Fixes #5200.
|
651
|
+
|
652
|
+
*Dave Desrochers*
|
653
|
+
|
654
|
+
* Round usec when comparing timestamp attributes in the dirty tracking.
|
655
|
+
Fixes #6975.
|
656
|
+
|
657
|
+
*kennyj*
|
658
|
+
|
659
|
+
* Use inversed parent for first and last child of has_many association.
|
660
|
+
|
661
|
+
*Ravil Bayramgalin*
|
662
|
+
|
663
|
+
* Fix Column.microseconds and Column.fast_string_to_date to avoid converting
|
664
|
+
timestamp seconds to a float, since it occasionally results in inaccuracies
|
665
|
+
with microsecond-precision times. Fixes #7352.
|
666
|
+
|
667
|
+
*Ari Pollak*
|
668
|
+
|
669
|
+
* Fix `increment!`, `decrement!`, `toggle!` that was skipping callbacks.
|
670
|
+
Fixes #7306.
|
671
|
+
|
672
|
+
*Rafael Mendonça França*
|
673
|
+
|
674
|
+
* Fix AR#create to return an unsaved record when AR::RecordInvalid is
|
675
|
+
raised. Fixes #3217.
|
676
|
+
|
677
|
+
*Dave Yeu*
|
678
|
+
|
679
|
+
* Remove unnecessary transaction when assigning has_one associations with a nil or equal value.
|
680
|
+
Fix #7191.
|
681
|
+
|
682
|
+
*kennyj*
|
683
|
+
|
684
|
+
* Allow store to work with an empty column.
|
685
|
+
Fix #4840.
|
686
|
+
|
687
|
+
*Jeremy Walker*
|
688
|
+
|
689
|
+
* Remove prepared statement from system query in postgresql adapter.
|
690
|
+
Fix #5872.
|
691
|
+
|
692
|
+
*Ivan Evtuhovich*
|
693
|
+
|
694
|
+
* Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load`
|
695
|
+
Fixes #4772.
|
696
|
+
|
697
|
+
*Seamus Abshere*
|
698
|
+
|
699
|
+
|
700
|
+
## Rails 3.2.8 (Aug 9, 2012) ##
|
701
|
+
|
702
|
+
* Do not consider the numeric attribute as changed if the old value is zero and the new value
|
703
|
+
is not a string.
|
704
|
+
Fixes #7237.
|
705
|
+
|
706
|
+
*Rafael Mendonça França*
|
707
|
+
|
708
|
+
* Removes the deprecation of `update_attribute`. *fxn*
|
709
|
+
|
710
|
+
* Reverted the deprecation of `composed_of`. *Rafael Mendonça França*
|
711
|
+
|
712
|
+
* Reverted the deprecation of `*_sql` association options. They will
|
713
|
+
be deprecated in 4.0 instead. *Jon Leighton*
|
714
|
+
|
715
|
+
* Do not eager load AR session store. ActiveRecord::SessionStore depends on the abstract store
|
716
|
+
in Action Pack. Eager loading this class would break client code that eager loads Active Record
|
717
|
+
standalone.
|
718
|
+
Fixes #7160
|
719
|
+
|
720
|
+
*Xavier Noria*
|
721
|
+
|
722
|
+
* Do not set RAILS_ENV to "development" when using `db:test:prepare` and related rake tasks.
|
723
|
+
This was causing the truncation of the development database data when using RSpec.
|
724
|
+
Fixes #7175.
|
725
|
+
|
726
|
+
*Rafael Mendonça França*
|
727
|
+
|
728
|
+
## Rails 3.2.7 (Jul 26, 2012) ##
|
729
|
+
|
730
|
+
* `:finder_sql` and `:counter_sql` options on collection associations
|
731
|
+
are deprecated. Please transition to using scopes.
|
379
732
|
|
380
733
|
*Jon Leighton*
|
381
734
|
|
382
|
-
*
|
383
|
-
|
384
|
-
|
385
|
-
works at all if the source reflection is a belongs_to. For other situations, you should directly
|
386
|
-
modify the through association.
|
735
|
+
* `:insert_sql` and `:delete_sql` options on `has_and_belongs_to_many`
|
736
|
+
associations are deprecated. Please transition to using `has_many
|
737
|
+
:through`
|
387
738
|
|
388
739
|
*Jon Leighton*
|
389
740
|
|
390
|
-
*
|
391
|
-
|
392
|
-
|
741
|
+
* `composed_of` has been deprecated. You'll have to write your own accessor
|
742
|
+
and mutator methods if you'd like to use value objects to represent some
|
743
|
+
portion of your models.
|
744
|
+
|
745
|
+
*Steve Klabnik*
|
746
|
+
|
747
|
+
* `update_attribute` has been deprecated. Use `update_column` if
|
748
|
+
you want to bypass mass-assignment protection, validations, callbacks,
|
749
|
+
and touching of updated_at. Otherwise please use `update_attributes`.
|
393
750
|
|
394
|
-
|
395
|
-
would not delete any records in the join table. Now, it deletes the records in the join table.
|
751
|
+
*Steve Klabnik*
|
396
752
|
|
397
|
-
|
398
|
-
records in the join table. [Note: This has not always been the case; previous version of Rails
|
399
|
-
only deleted the records themselves.] Now, it destroys only the records in the join table.
|
753
|
+
## Rails 3.2.6 (Jun 12, 2012) ##
|
400
754
|
|
401
|
-
|
402
|
-
|
403
|
-
|
755
|
+
* protect against the nesting of hashes changing the
|
756
|
+
table context in the next call to build_from_hash. This fix
|
757
|
+
covers this case as well.
|
404
758
|
|
405
|
-
|
759
|
+
CVE-2012-2695
|
760
|
+
|
761
|
+
* Revert earlier 'perf fix' (see 3.2.4 changelog / GH #6289). This
|
762
|
+
change introduced a regression (GH #6609). assoc.clear and
|
763
|
+
assoc.delete_all have loaded the association before doing the delete
|
764
|
+
since at least Rails 2.3. Doing the delete without loading the
|
765
|
+
records means that the `before_remove` and `after_remove` callbacks do
|
766
|
+
not get invoked. Therefore, this change was less a fix a more an
|
767
|
+
optimisation, which should only have gone into master.
|
406
768
|
|
407
769
|
*Jon Leighton*
|
408
770
|
|
409
|
-
|
771
|
+
## Rails 3.2.5 (Jun 1, 2012) ##
|
410
772
|
|
411
|
-
|
773
|
+
* Restore behavior of Active Record 3.2.3 scopes.
|
774
|
+
A series of commits relating to preloading and scopes caused a regression.
|
412
775
|
|
413
|
-
|
414
|
-
t.string :company_name
|
415
|
-
t.change :birthdate, :datetime
|
416
|
-
end
|
776
|
+
*Andrew White*
|
417
777
|
|
418
|
-
This will now result in:
|
419
778
|
|
420
|
-
|
779
|
+
## Rails 3.2.4 (May 31, 2012) ##
|
421
780
|
|
422
|
-
*
|
423
|
-
|
424
|
-
*Jon Leighton*
|
781
|
+
* Perf fix: Don't load the records when doing assoc.delete_all.
|
782
|
+
GH #6289. *Jon Leighton*
|
425
783
|
|
426
|
-
*
|
784
|
+
* Association preloading shouldn't be affected by the current scoping.
|
785
|
+
This could cause infinite recursion and potentially other problems.
|
786
|
+
See GH #5667. *Jon Leighton*
|
427
787
|
|
428
|
-
*
|
429
|
-
(for example, add_name_to_users) use the reversible migration's `change`
|
430
|
-
method instead of the ordinary `up` and `down` methods. *Prem Sichanugrist*
|
788
|
+
* Datetime attributes are forced to be changed. GH #3965
|
431
789
|
|
432
|
-
*
|
433
|
-
use a proc, like so:
|
790
|
+
* Fix attribute casting. GH #5549
|
434
791
|
|
435
|
-
|
792
|
+
* Fix #5667. Preloading should ignore scoping.
|
436
793
|
|
437
|
-
|
794
|
+
* Predicate builder should not recurse for determining where columns.
|
795
|
+
Thanks to Ben Murphy for reporting this! CVE-2012-2661
|
438
796
|
|
439
|
-
After:
|
440
797
|
|
441
|
-
|
798
|
+
## Rails 3.2.3 (March 30, 2012) ##
|
442
799
|
|
443
|
-
|
444
|
-
eager loading the association, in which case 'self' is the class which the association is within.
|
800
|
+
* Added find_or_create_by_{attribute}! dynamic method. *Andrew White*
|
445
801
|
|
446
|
-
|
802
|
+
* Whitelist all attribute assignment by default. Change the default for newly generated applications to whitelist all attribute assignment. Also update the generated model classes so users are reminded of the importance of attr_accessible. *NZKoz*
|
447
803
|
|
448
|
-
|
804
|
+
* Update ActiveRecord::AttributeMethods#attribute_present? to return false for empty strings. *Jacobkg*
|
449
805
|
|
450
|
-
|
451
|
-
'record' to get the record being inserted or deleted. This is now passed as an argument to
|
452
|
-
the proc.
|
806
|
+
* Fix associations when using per class databases. *larskanis*
|
453
807
|
|
454
|
-
*
|
808
|
+
* Revert setting NOT NULL constraints in add_timestamps *fxn*
|
455
809
|
|
456
|
-
|
457
|
-
class User < ActiveRecord::Base
|
458
|
-
has_secure_password
|
459
|
-
end
|
810
|
+
* Fix mysql to use proper text types. Fixes #3931. *kennyj*
|
460
811
|
|
461
|
-
|
462
|
-
user.save # => false, password required
|
463
|
-
user.password = "mUc3m00RsqyRe"
|
464
|
-
user.save # => false, confirmation doesn't match
|
465
|
-
user.password_confirmation = "mUc3m00RsqyRe"
|
466
|
-
user.save # => true
|
467
|
-
user.authenticate("notright") # => false
|
468
|
-
user.authenticate("mUc3m00RsqyRe") # => user
|
469
|
-
User.find_by_name("david").try(:authenticate, "notright") # => nil
|
470
|
-
User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
|
812
|
+
* Fix #5069 - Protect foreign key from mass assignment through association builder. *byroot*
|
471
813
|
|
472
814
|
|
473
|
-
|
815
|
+
## Rails 3.2.2 (March 1, 2012) ##
|
474
816
|
|
475
|
-
|
817
|
+
* No changes.
|
476
818
|
|
477
|
-
class CreatePosts < ActiveRecord::Migration
|
478
|
-
def change
|
479
|
-
create_table :posts do |t|
|
480
|
-
t.belongs_to :user
|
481
|
-
t.timestamps
|
482
|
-
end
|
483
|
-
add_index :posts, :user_id
|
484
|
-
end
|
485
|
-
end
|
486
819
|
|
487
|
-
|
820
|
+
## Rails 3.2.1 (January 26, 2012) ##
|
488
821
|
|
489
|
-
*
|
490
|
-
object. *#2989 state:resolved*
|
822
|
+
* The threshold for auto EXPLAIN is ignored if there's no logger. *fxn*
|
491
823
|
|
492
|
-
*
|
493
|
-
|
824
|
+
* Call `to_s` on the value passed to `table_name=`, in particular symbols
|
825
|
+
are supported (regression). *Sergey Nartimov*
|
494
826
|
|
495
|
-
*
|
496
|
-
|
827
|
+
* Fix possible race condition when two threads try to define attribute
|
828
|
+
methods for the same class. *Jon Leighton*
|
497
829
|
|
498
|
-
* Calling ActiveRecord::Base#dup will duplicate the record, including calling
|
499
|
-
after initialize hooks. Frozen state will not be copied, and all associations
|
500
|
-
will be cleared. A duped record will return true for new_record?, have a nil
|
501
|
-
id field, and is saveable.
|
502
830
|
|
503
|
-
|
504
|
-
will figure out how to reverse your migration. To use reversible migrations,
|
505
|
-
just define the "change" method. For example:
|
831
|
+
## Rails 3.2.0 (January 20, 2012) ##
|
506
832
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
833
|
+
* Added a `with_lock` method to ActiveRecord objects, which starts
|
834
|
+
a transaction, locks the object (pessimistically) and yields to the block.
|
835
|
+
The method takes one (optional) parameter and passes it to `lock!`.
|
836
|
+
|
837
|
+
Before:
|
838
|
+
|
839
|
+
class Order < ActiveRecord::Base
|
840
|
+
def cancel!
|
841
|
+
transaction do
|
842
|
+
lock!
|
843
|
+
# ... cancelling logic
|
512
844
|
end
|
513
845
|
end
|
514
846
|
end
|
515
847
|
|
516
|
-
|
517
|
-
reverse those things, you should define 'up' and 'down' in your migration. If
|
518
|
-
you define something in `change` that cannot be reversed, an
|
519
|
-
IrreversibleMigration exception will be raised when going down.
|
848
|
+
After:
|
520
849
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
850
|
+
class Order < ActiveRecord::Base
|
851
|
+
def cancel!
|
852
|
+
with_lock do
|
853
|
+
# ... cancelling logic
|
854
|
+
end
|
525
855
|
end
|
526
856
|
end
|
527
857
|
|
528
|
-
*
|
858
|
+
*Olek Janiszewski*
|
859
|
+
|
860
|
+
* 'on' and 'ON' boolean columns values are type casted to true
|
861
|
+
*Santiago Pastorino*
|
862
|
+
|
863
|
+
* Added ability to run migrations only for given scope, which allows
|
864
|
+
to run migrations only from one engine (for example to revert changes
|
865
|
+
from engine that you want to remove).
|
866
|
+
|
867
|
+
Example:
|
868
|
+
rake db:migrate SCOPE=blog
|
869
|
+
|
870
|
+
*Piotr Sarnacki*
|
871
|
+
|
872
|
+
* Migrations copied from engines are now scoped with engine's name,
|
873
|
+
for example 01_create_posts.blog.rb. *Piotr Sarnacki*
|
874
|
+
|
875
|
+
* Implements `AR::Base.silence_auto_explain`. This method allows the user to
|
876
|
+
selectively disable automatic EXPLAINs within a block. *fxn*
|
877
|
+
|
878
|
+
* Implements automatic EXPLAIN logging for slow queries.
|
879
|
+
|
880
|
+
A new configuration parameter `config.active_record.auto_explain_threshold_in_seconds`
|
881
|
+
determines what's to be considered a slow query. Setting that to `nil` disables
|
882
|
+
this feature. Defaults are 0.5 in development mode, and `nil` in test and production
|
883
|
+
modes.
|
884
|
+
|
885
|
+
As of this writing there's support for SQLite, MySQL (mysql2 adapter), and
|
886
|
+
PostgreSQL.
|
887
|
+
|
888
|
+
*fxn*
|
889
|
+
|
890
|
+
* Implemented ActiveRecord::Relation#pluck method
|
891
|
+
|
892
|
+
Method returns Array of column value from table under ActiveRecord model
|
893
|
+
|
894
|
+
Client.pluck(:id)
|
895
|
+
|
896
|
+
*Bogdan Gusiev*
|
897
|
+
|
898
|
+
* Automatic closure of connections in threads is deprecated. For example
|
899
|
+
the following code is deprecated:
|
900
|
+
|
901
|
+
Thread.new { Post.find(1) }.join
|
902
|
+
|
903
|
+
It should be changed to close the database connection at the end of
|
904
|
+
the thread:
|
905
|
+
|
906
|
+
Thread.new {
|
907
|
+
Post.find(1)
|
908
|
+
Post.connection.close
|
909
|
+
}.join
|
910
|
+
|
911
|
+
Only people who spawn threads in their application code need to worry
|
912
|
+
about this change.
|
913
|
+
|
914
|
+
* Deprecated:
|
915
|
+
|
916
|
+
* `set_table_name`
|
917
|
+
* `set_inheritance_column`
|
918
|
+
* `set_sequence_name`
|
919
|
+
* `set_primary_key`
|
920
|
+
* `set_locking_column`
|
921
|
+
|
922
|
+
Use an assignment method instead. For example, instead of `set_table_name`, use `self.table_name=`:
|
923
|
+
|
924
|
+
class Project < ActiveRecord::Base
|
925
|
+
self.table_name = "project"
|
926
|
+
end
|
927
|
+
|
928
|
+
Or define your own `self.table_name` method:
|
929
|
+
|
930
|
+
class Post < ActiveRecord::Base
|
931
|
+
def self.table_name
|
932
|
+
"special_" + super
|
933
|
+
end
|
934
|
+
end
|
935
|
+
Post.table_name # => "special_posts"
|
936
|
+
|
937
|
+
*Jon Leighton*
|
938
|
+
|
939
|
+
* Generated association methods are created within a separate module to allow overriding and
|
940
|
+
composition using `super`. For a class named `MyModel`, the module is named
|
941
|
+
`MyModel::GeneratedFeatureMethods`. It is included into the model class immediately after
|
942
|
+
the `generated_attributes_methods` module defined in ActiveModel, so association methods
|
943
|
+
override attribute methods of the same name. *Josh Susser*
|
944
|
+
|
945
|
+
* Implemented ActiveRecord::Relation#explain. *fxn*
|
946
|
+
|
947
|
+
* Add ActiveRecord::Relation#uniq for generating unique queries.
|
948
|
+
|
949
|
+
Before:
|
950
|
+
|
951
|
+
Client.select('DISTINCT name')
|
952
|
+
|
953
|
+
After:
|
954
|
+
|
955
|
+
Client.select(:name).uniq
|
956
|
+
|
957
|
+
This also allows you to revert the unqueness in a relation:
|
958
|
+
|
959
|
+
Client.select(:name).uniq.uniq(false)
|
960
|
+
|
961
|
+
*Jon Leighton*
|
962
|
+
|
963
|
+
* Support index sort order in sqlite, mysql and postgres adapters. *Vlad Jebelev*
|
964
|
+
|
965
|
+
* Allow the :class_name option for associations to take a symbol (:Client) in addition to
|
966
|
+
a string ('Client').
|
967
|
+
|
968
|
+
This is to avoid confusing newbies, and to be consistent with the fact that other options
|
969
|
+
like :foreign_key already allow a symbol or a string.
|
970
|
+
|
971
|
+
*Jon Leighton*
|
972
|
+
|
973
|
+
* In development mode the db:drop task also drops the test database. For symmetry with
|
974
|
+
the db:create task. *Dmitriy Kiriyenko*
|
975
|
+
|
976
|
+
* Added ActiveRecord::Base.store for declaring simple single-column key/value stores *DHH*
|
977
|
+
|
978
|
+
class User < ActiveRecord::Base
|
979
|
+
store :settings, accessors: [ :color, :homepage ]
|
980
|
+
end
|
981
|
+
|
982
|
+
u = User.new(color: 'black', homepage: '37signals.com')
|
983
|
+
u.color # Accessor stored attribute
|
984
|
+
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
|
985
|
+
|
986
|
+
|
987
|
+
* MySQL: case-insensitive uniqueness validation avoids calling LOWER when
|
988
|
+
the column already uses a case-insensitive collation. Fixes #561.
|
989
|
+
|
990
|
+
*Joseph Palermo*
|
991
|
+
|
992
|
+
* Transactional fixtures enlist all active database connections. You can test
|
993
|
+
models on different connections without disabling transactional fixtures.
|
529
994
|
|
530
|
-
*
|
531
|
-
of a single after_save. *fxn*
|
995
|
+
*Jeremy Kemper*
|
532
996
|
|
533
|
-
*
|
997
|
+
* Add first_or_create, first_or_create!, first_or_initialize methods to Active Record. This is a
|
998
|
+
better approach over the old find_or_create_by dynamic methods because it's clearer which
|
999
|
+
arguments are used to find the record and which are used to create it:
|
534
1000
|
|
535
|
-
|
1001
|
+
User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson")
|
536
1002
|
|
537
|
-
|
1003
|
+
*Andrés Mejía*
|
538
1004
|
|
539
|
-
|
1005
|
+
* Fix nested attributes bug where _destroy parameter is taken into account
|
1006
|
+
during :reject_if => :all_blank (fixes #2937)
|
540
1007
|
|
541
|
-
|
542
|
-
like this:
|
1008
|
+
*Aaron Christy*
|
543
1009
|
|
544
|
-
|
1010
|
+
* Add ActiveSupport::Cache::NullStore for use in development and testing.
|
545
1011
|
|
546
|
-
*
|
1012
|
+
*Brian Durand*
|
547
1013
|
|
548
|
-
Please check [3-
|
1014
|
+
Please check [3-1-stable](https://github.com/rails/rails/blob/3-1-stable/activerecord/CHANGELOG.md) for previous changes.
|