Skip to content
This repository
Newer
Older
100644 548 lines (351 sloc) 20.845 kb
2821f953 » steveklabnik
2013-02-26 Revert "Merge pull request #9208 from dylanahsmith/3-2-mysql-quote-nu…
1 ## unreleased ##
2
3 * Reverted 921a296a3390192a71abeec6d9a035cc6d1865c8, 'Quote numeric values
4 compared to string columns.' This caused several regressions.
5
6 *Steve Klabnik*
7
967591bd » carlosantoniodasilva
2013-02-14 Fix changelog typos [ci skip]
8 ## Rails 3.1.11 (Feb 11, 2011) ##
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
9
26e13c3c » dylanahsmith
2013-02-06 active_record: Quote numeric values compared to string columns.
10 * Quote numeric values being compared to non-numeric columns. Otherwise,
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.
13
14 Example:
15
16 App.where(apikey: 0) # => SELECT * FROM users WHERE apikey = '0'
17
18 *Dylan Smith*
19
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
20 ## Rails 3.1.10 (Jan 8, 2013) ##
7e5cc965 » tenderlove
2013-01-04 * Strip nils from collections on JSON and XML posts. [CVE-2013-0155] …
21
22 * Fix querying with an empty hash *Damien Mathieu* [CVE-2013-0155]
23
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
24 ## Rails 3.1.9 (Jan 2, 2013) ##
fbe436b6 » tenderlove
2012-12-22 updating changelogs
25
26 * CVE-2012-5664 ensure that options are never taken from the first parameter
27
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
28 ## Rails 3.1.8 (Aug 9, 2012) ##
e8d78e78 » spastorino
2012-08-09 Add CHANGELOG entries
29
30 * No changes.
31
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
32 ## Rails 3.1.7 (Jul 26, 2012) ##
a4b8a7e8 » tenderlove
2012-07-23 updating changelog
33
34 * No changes.
35
1b35a852 » carlosantoniodasilva
2013-01-09 Update changelogs with release dates and minor improvements [ci skip]
36 ## Rails 3.1.6 (Jun 12, 2012) ##
75d039f1 » tenderlove
2012-06-11 adding version number to changelogs
37
bee42f3a » tenderlove
2012-06-11 updating changelogs with security fixes
38 * protect against the nesting of hashes changing the
39 table context in the next call to build_from_hash. This fix
40 covers this case as well.
75d039f1 » tenderlove
2012-06-11 adding version number to changelogs
41
63dce162 » tenderlove
2012-06-12 updating changelogs
42 CVE-2012-2695
43
a7ed1981 » tenderlove
2012-05-31 updating the CHANGELOG
44 ## Rails 3.1.5 (May 31, 2012) ##
45
46 * Fix type_to_sql with text and limit on mysql/mysql2. Fix GH #3931.
47
48 * only log an error if there is a logger. fixes #5226
49
50 * fix activerecord query_method regression with offset into Fixnum
51
52 * predicate builder should not recurse for determining where columns.
53 Thanks to Ben Murphy for reporting this! CVE-2012-2661
54
5f27545e » pimeys
2011-11-30 If the table behind has no primary key, do not ask again and just ret…
55 ## Rails 3.1.4 (unreleased) ##
56
df932c4a » jonleighton
2011-12-15 Fix #3987.
57 * Fix a custom primary key regression *GH 3987*
58
59 *Jon Leighton*
60
b6ae05e6 » jonleighton
2011-12-14 Fix #3672 again (dependent: delete_all perf)
61 * Perf fix (second try): don't load records for `has many :dependent =>
62 :delete_all` *GH 3672*
63
64 *Jon Leighton*
65
63293d1b » jonleighton
2011-12-08 Fix #3890. (Calling proxy_association in scope chain.)
66 * Fix accessing `proxy_association` method from an association extension
67 where the calls are chained. *GH #3890*
68
69 (E.g. `post.comments.where(bla).my_proxy_method`)
70
71 *Jon Leighton*
72
8d55a6d4 » kennyj
2011-11-22 Use show create table.
73 * Perf fix: MySQL primary key lookup was still slow for very large
74 tables. *GH 3678*
75
76 *Kenny J*
77
5f27545e » pimeys
2011-11-30 If the table behind has no primary key, do not ask again and just ret…
78 * Perf fix: If a table has no primary key, don't repeatedly ask the database for it.
79
80 *Julius de Bruijn*
81
c5197d47 » jonleighton
2011-11-19 Verify that #3690 has been closed by previous changes to the mysql
82 ## Rails 3.1.3 (unreleased) ##
83
cb0c3e45 » jonleighton
2011-11-19 Perf fix
84 * Perf fix: If we're deleting all records in an association, don't add a IN(..) clause
85 to the query. *GH 3672*
86
87 *Jon Leighton*
88
c5197d47 » jonleighton
2011-11-19 Verify that #3690 has been closed by previous changes to the mysql
89 * Fix bug with referencing other mysql databases in set_table_name. *GH 3690*
90
da327fc5 » jonleighton
2011-11-19 Add missing CHANGELOG entry for #3678. Closes #3678.
91 * Fix performance bug with mysql databases on a server with lots of other databses. *GH 3678*
92
93 *Christos Zisopoulos and Kenny J*
94
43486e0c » jonleighton
2011-11-04 Convert CHANGELOGs to Markdown format.
95 ## Rails 3.1.2 (unreleased) ##
96
b02daec7 » Juanmcuello
2011-10-05 Backport #3232 to 3-1-stable.
97 * Fix problem with prepared statements and PostgreSQL when multiple schemas are used.
98 *GH #3232*
99
100 *Juan M. Cuello*
101
e6d8ed57 » jonleighton
2011-11-14 Add missing CHANGELOG entries
102 * Fix bug with PostgreSQLAdapter#indexes. When the search path has multiple schemas, spaces
103 were not being stripped from the schema names after the first.
104
105 *Sean Kirby*
106
107 * Preserve SELECT columns on the COUNT for finder_sql when possible. *GH 3503*
108
109 *Justin Mazzi*
110
111 * Reset prepared statement cache when schema changes impact statement results. *GH 3335*
112
113 *Aaron Patterson*
114
115 * Postgres: Do not attempt to deallocate a statement if the connection is no longer active.
116
117 *Ian Leitch*
118
119 * Prevent QueryCache leaking database connections. *GH 3243*
120
121 *Mark J. Titorenko*
122
43486e0c » jonleighton
2011-11-04 Convert CHANGELOGs to Markdown format.
123 * Fix bug where building the conditions of a nested through association could potentially
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*
127
128 *Jon Leighton*
129
130 * If a record is removed from a has_many :through, all of the join records relating to that
131 record should also be removed from the through association's target.
132
133 *Jon Leighton*
134
135 * Fix adding multiple instances of the same record to a has_many :through. *GH #3425*
136
137 *Jon Leighton*
138
139 * Fix creating records in a through association with a polymorphic source type. *GH #3247*
140
141 *Jon Leighton*
142
fb734233 » kennyj
2011-11-06 Barckport to 3-1-stable: fixed an issue id false option is ignored on…
143 * MySQL: use the information_schema than the describe command when we look for a primary key. *GH #3440*
144 *Kenny J*
145
43486e0c » jonleighton
2011-11-04 Convert CHANGELOGs to Markdown format.
146 ## Rails 3.1.1 (October 7, 2011) ##
147
148 * Raise an exception if the primary key of a model in an association is needed
149 but unknown. Fixes #3207.
150
151 *Jon Leighton*
152
153 * Add deprecation for the preload_associations method. Fixes #3022.
154
155 *Jon Leighton*
156
157 * Don't require a DB connection when loading a model that uses set_primary_key. GH #2807.
158
159 *Jon Leighton*
160
161 * Fix using select() with a habtm association, e.g. Person.friends.select(:name). GH #3030 and
162 \#2923.
163
164 *Hendy Tanata*
165
166 * Fix belongs_to polymorphic with custom primary key on target. GH #3104.
167
168 *Jon Leighton*
169
170 * CollectionProxy#replace should change the DB records rather than just mutating the array.
171 Fixes #3020.
172
173 *Jon Leighton*
174
175 * LRU cache in mysql and sqlite are now per-process caches.
176
177 * lib/active_record/connection_adapters/mysql_adapter.rb: LRU cache
178 keys are per process id.
179 * lib/active_record/connection_adapters/sqlite_adapter.rb: ditto
180
181 *Aaron Patterson*
182
183 * Database adapters use a statement pool for limiting the number of open
184 prepared statments on the database. The limit defaults to 1000, but can
185 be adjusted in your database config by changing 'statement_limit'.
186
187 * Fix clash between using 'preload', 'joins' or 'eager_load' in a default scope and including the
188 default scoped model in a nested through association. (GH #2834.) *Jon Leighton*
189
190 * Ensure we are not comparing a string with a symbol in HasManyAssociation#inverse_updates_counter_cache?.
191 Fixes GH #2755, where a counter cache could be decremented twice as far as it was supposed to be.
192
193 *Jon Leighton*
194
195 * Don't send any queries to the database when the foreign key of a belongs_to is nil. Fixes
196 GH #2828. *Georg Friedrich*
197
198 * Fixed find_in_batches method to not include order from default_scope. See GH #2832 *Arun Agrawal*
199
200 * Don't compute table name for abstract classes. Fixes problem with setting the primary key
201 in an abstract class. See GH #2791. *Akira Matsuda*
202
203 * Psych errors with poor yaml formatting are proxied. Fixes GH #2645 and
204 GH #2731
205
206 * Use the LIMIT word with the methods #last and #first. Fixes GH #2783 *Damien Mathieu*
207
208 ## Rails 3.1.0 (August 30, 2011) ##
209
210 * Add a proxy_association method to association proxies, which can be called by association
211 extensions to access information about the association. This replaces proxy_owner etc with
212 proxy_association.owner.
213
214 *Jon Leighton*
215
216 * Active Record's dynamic finder will now show a deprecation warning if you passing in less number of arguments than what you call in method signature. This behavior will raise ArgumentError in the next version of Rails *Prem Sichanugrist*
217
218 * Deprecated the AssociationCollection constant. CollectionProxy is now the appropriate constant
219 to use, though be warned that this is not really a public API.
220
221 This should solve upgrade problems with the will_paginate plugin (and perhaps others). Thanks
222 Paul Battley for reporting.
223
224 *Jon Leighton*
225
226 * ActiveRecord::MacroReflection::AssociationReflection#build_record has a new method signature.
227
228 Before: def build_association(*options)
229 After: def build_association(*options, &block)
230
231 Users who are redefining this method to extend functionality should ensure that the block is
232 passed through to ActiveRecord::Base#new.
233
234 This change is necessary to fix https://github.com/rails/rails/issues/1842.
235
236 A deprecation warning and workaround has been added to 3.1, but authors will need to update
237 their code for it to work correctly in 3.2.
238
239 *Jon Leighton*
240
241 * AR#pluralize_table_names can be used to singularize/pluralize table name of an individual model:
242
243 class User < ActiveRecord::Base
244 self.pluralize_table_names = false
245 end
246
247 Previously this could only be set globally for all models through ActiveRecord::Base.pluralize_table_names. *Guillermo Iguaran*
248
249 * Add block setting of attributes to singular associations:
250
251 class User < ActiveRecord::Base
252 has_one :account
253 end
254
255 user.build_account{ |a| a.credit_limit => 100.0 }
256
257 The block is called after the instance has been initialized. *Andrew White*
258
259 * Add ActiveRecord::Base.attribute_names to return a list of attribute names. This will return an empty array if the model is abstract or table does not exists. *Prem Sichanugrist*
260
261 * CSV Fixtures are deprecated and support will be removed in Rails 3.2.0
262
263 * AR#new, AR#create, AR#create!, AR#update_attributes and AR#update_attributes! all accept a second hash as option that allows you
264 to specify which role to consider when assigning attributes. This is built on top of ActiveModel's
265 new mass assignment capabilities:
266
267 class Post < ActiveRecord::Base
268 attr_accessible :title
269 attr_accessible :title, :published_at, :as => :admin
270 end
271
272 Post.new(params[:post], :as => :admin)
273
274 assign_attributes() with similar API was also added and attributes=(params, guard) was deprecated.
275
276 Please note that this changes the method signatures for AR#new, AR#create, AR#create!, AR#update_attributes and AR#update_attributes!. If you have overwritten these methods you should update them accordingly.
277
278 *Josh Kalderimis*
279
280 * default_scope can take a block, lambda, or any other object which responds to `call` for lazy
281 evaluation:
282
283 default_scope { ... }
284 default_scope lambda { ... }
285 default_scope method(:foo)
286
287 This feature was originally implemented by Tim Morgan, but was then removed in favour of
288 defining a 'default_scope' class method, but has now been added back in by Jon Leighton.
289 The relevant lighthouse ticket is #1812.
290
291 * Default scopes are now evaluated at the latest possible moment, to avoid problems where
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.
294
295 Note that this means that if you are inspecting the internal structure of an
296 ActiveRecord::Relation, it will *not* contain the default scope, though the resulting
297 query will do. You can get a relation containing the default scope by calling
298 ActiveRecord#with_default_scope, though this is not part of the public API.
299
300 *Jon Leighton*
301
302 * If you wish to merge default scopes in special ways, it is recommended to define your default
303 scope as a class method and use the standard techniques for sharing code (inheritance, mixins,
304 etc.):
305
306 class Post < ActiveRecord::Base
307 def self.default_scope
308 where(:published => true).where(:hidden => false)
309 end
310 end
311
312 *Jon Leighton*
313
314 * PostgreSQL adapter only supports PostgreSQL version 8.2 and higher.
315
316 * ConnectionManagement middleware is changed to clean up the connection pool
317 after the rack body has been flushed.
318
319 * Added an update_column method on ActiveRecord. This new method updates a given attribute on an object, skipping validations and callbacks.
320 It is recommended to use #update_attribute unless you are sure you do not want to execute any callback, including the modification of
321 the updated_at column. It should not be called on new records.
322 Example:
323
324 User.first.update_column(:name, "sebastian") # => true
325
326 *Sebastian Martinez*
327
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
332 *Jon Leighton*
333
334 * The configuration for the current database connection is now accessible via
335 ActiveRecord::Base.connection_config. *fxn*
336
337 * limits and offsets are removed from COUNT queries unless both are supplied.
338 For example:
339
340 People.limit(1).count # => 'SELECT COUNT(*) FROM people'
341 People.offset(1).count # => 'SELECT COUNT(*) FROM people'
342 People.limit(1).offset(1).count # => 'SELECT COUNT(*) FROM people LIMIT 1 OFFSET 1'
343
344 *lighthouse #6262*
345
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
350 This prevents namespace pollution, separates concerns, and will allow further refactorings.
351
352 Singular associations (has_one, belongs_to) no longer have a proxy at all. They simply return
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.
355
356 *Jon Leighton*
357
358 * Make has_many :through associations work correctly when you build a record and then save it. This
359 requires you to set the :inverse_of option on the source reflection on the join model, like so:
360
361 class Post < ActiveRecord::Base
362 has_many :taggings
363 has_many :tags, :through => :taggings
364 end
365
366 class Tagging < ActiveRecord::Base
367 belongs_to :post
368 belongs_to :tag, :inverse_of => :tagging # :inverse_of must be set!
369 end
370
371 class Tag < ActiveRecord::Base
372 has_many :taggings
373 has_many :posts, :through => :taggings
374 end
375
376 post = Post.first
377 tag = post.tags.build :name => "ruby"
378 tag.save # will save a Taggable linking to the post
379
380 *Jon Leighton*
381
382 * Support the :dependent option on has_many :through associations. For historical and practical
383 reasons, :delete_all is the default deletion strategy employed by association.delete(*records),
384 despite the fact that the default strategy is :nullify for regular has_many. Also, this only
385 works at all if the source reflection is a belongs_to. For other situations, you should directly
386 modify the through association.
387
388 *Jon Leighton*
389
390 * Changed the behaviour of association.destroy for has_and_belongs_to_many and has_many :through.
391 From now on, 'destroy' or 'delete' on an association will be taken to mean 'get rid of the link',
392 not (necessarily) 'get rid of the associated records'.
393
394 Previously, has_and_belongs_to_many.destroy(*records) would destroy the records themselves. It
395 would not delete any records in the join table. Now, it deletes the records in the join table.
396
397 Previously, has_many_through.destroy(*records) would destroy the records themselves, and the
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.
400
401 Note that this change is backwards-incompatible to an extent, but there is unfortunately no
402 way to 'deprecate' it before changing it. The change is being made in order to have
403 consistency as to the meaning of 'destroy' or 'delete' across the different types of associations.
404
405 If you wish to destroy the records themselves, you can do records.association.each(&:destroy)
406
407 *Jon Leighton*
408
409 * Add :bulk => true option to change_table to make all the schema changes defined in change_table block using a single ALTER statement. *Pratik Naik*
410
411 Example:
412
413 change_table(:users, :bulk => true) do |t|
414 t.string :company_name
415 t.change :birthdate, :datetime
416 end
417
418 This will now result in:
419
420 ALTER TABLE `users` ADD COLUMN `company_name` varchar(255), CHANGE `updated_at` `updated_at` datetime DEFAULT NULL
421
422 * Removed support for accessing attributes on a has_and_belongs_to_many join table. This has been
423 documented as deprecated behaviour since April 2006. Please use has_many :through instead.
424 *Jon Leighton*
425
426 * Added a create_association! method for has_one and belongs_to associations. *Jon Leighton*
427
428 * Migration files generated from model and constructive migration generators
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*
431
432 * Removed support for interpolating string SQL conditions on associations. Instead, you should
433 use a proc, like so:
434
435 Before:
436
437 has_many :things, :conditions => 'foo = #{bar}'
438
439 After:
440
441 has_many :things, :conditions => proc { "foo = #{bar}" }
442
443 Inside the proc, 'self' is the object which is the owner of the association, unless you are
444 eager loading the association, in which case 'self' is the class which the association is within.
445
446 You can have any "normal" conditions inside the proc, so the following will work too:
447
448 has_many :things, :conditions => proc { ["foo = ?", bar] }
449
450 Previously :insert_sql and :delete_sql on has_and_belongs_to_many association allowed you to call
451 'record' to get the record being inserted or deleted. This is now passed as an argument to
452 the proc.
453
454 * Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with BCrypt encryption and salting [DHH]. Example:
455
456 # Schema: User(name:string, password_digest:string, password_salt:string)
457 class User < ActiveRecord::Base
458 has_secure_password
459 end
460
461 user = User.new(:name => "david", :password => "", :password_confirmation => "nomatch")
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
471
472
473 * When a model is generated add_index is added by default for belongs_to or references columns
474
475 rails g model post user:belongs_to will generate the following:
476
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
487 *Santiago Pastorino*
488
489 * Setting the id of a belongs_to object will update the reference to the
490 object. *#2989 state:resolved*
491
492 * ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed
493 to closer match normal Ruby dup and clone semantics.
494
495 * Calling ActiveRecord::Base#clone will result in a shallow copy of the record,
496 including copying the frozen state. No callbacks will be called.
497
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
503 * Migrations can be defined as reversible, meaning that the migration system
504 will figure out how to reverse your migration. To use reversible migrations,
505 just define the "change" method. For example:
506
507 class MyMigration < ActiveRecord::Migration
508 def change
509 create_table(:horses) do
510 t.column :content, :text
511 t.column :remind_at, :datetime
512 end
513 end
514 end
515
516 Some things cannot be automatically reversed for you. If you know how to
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.
520
521 * Migrations should use instance methods rather than class methods:
522 class FooMigration < ActiveRecord::Migration
523 def up
524 ...
525 end
526 end
527
528 *Aaron Patterson*
529
530 * has_one maintains the association with separate after_create/after_update instead
531 of a single after_save. *fxn*
532
533 * The following code:
534
535 Model.limit(10).scoping { Model.count }
536
537 now generates the following SQL:
538
539 SELECT COUNT(*) FROM models LIMIT 10
540
541 This may not return what you want. Instead, you may with to do something
542 like this:
543
544 Model.limit(10).scoping { Model.all.size }
545
546 *Aaron Patterson*
547
e6e9e565 » fxn
2012-08-28 CHANGELOGs are now per branch
548 Please check [3-0-stable](https://github.com/rails/rails/blob/3-0-stable/activerecord/CHANGELOG) for previous changes.
Something went wrong with that request. Please try again.