Froze rails gems
[depot.git] / vendor / rails / activerecord / CHANGELOG
1 *2.2 (November 21st, 2008)*
2
3 * Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster]
4
5 * Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
6
7 * Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper]
8
9 * Add Model#delete instance method, similar to Model.delete class method. #1086 [Hongli Lai]
10
11 * MySQL: cope with quirky default values for not-null text columns. #1043 [Frederick Cheung]
12
13 * Multiparameter attributes skip time zone conversion for time-only columns [#1030 state:resolved] [Geoff Buesing]
14
15 * Base.skip_time_zone_conversion_for_attributes uses class_inheritable_accessor, so that subclasses don't overwrite Base [#346 state:resolved] [miloops]
16
17 * Added find_last_by dynamic finder #762 [miloops]
18
19 * Internal API: configurable association options and build_association method for reflections so plugins may extend and override. #985 [Hongli Lai]
20
21 * Changed benchmarks to be reported in milliseconds [DHH]
22
23 * Connection pooling. #936 [Nick Sieger]
24
25 * Merge scoped :joins together instead of overwriting them. May expose scoping bugs in your code! #501 [Andrew White]
26
27 * before_save, before_validation and before_destroy callbacks that return false will now ROLLBACK the transaction. Previously this would have been committed before the processing was aborted. #891 [Xavier Noria]
28
29 * Transactional migrations for databases which support them. #834 [divoxx, Adam Wiggins, Tarmo Tänav]
30
31 * Set config.active_record.timestamped_migrations = false to have migrations with numeric prefix instead of UTC timestamp. #446. [Andrew Stone, Nik Wakelin]
32
33 * change_column_default preserves the not-null constraint. #617 [Tarmo Tänav]
34
35 * Fixed that create database statements would always include "DEFAULT NULL" (Nick Sieger) [#334]
36
37 * Add :tokenizer option to validates_length_of to specify how to split up the attribute string. #507. [David Lowenfels] Example :
38
39 # Ensure essay contains at least 100 words.
40 validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %d words."), :tokenizer => lambda {|str| str.scan(/\w+/) }
41
42 * Allow conditions on multiple tables to be specified using hash. [Pratik Naik]. Example:
43
44 User.all :joins => :items, :conditions => { :age => 10, :items => { :color => 'black' } }
45 Item.first :conditions => { :items => { :color => 'red' } }
46
47 * Always treat integer :limit as byte length. #420 [Tarmo Tänav]
48
49 * Partial updates don't update lock_version if nothing changed. #426 [Daniel Morrison]
50
51 * Fix column collision with named_scope and :joins. #46 [Duncan Beevers, Mark Catley]
52
53 * db:migrate:down and :up update schema_migrations. #369 [Michael Raidel, RaceCondition]
54
55 * PostgreSQL: support :conditions => [':foo::integer', { :foo => 1 }] without treating the ::integer typecast as a bind variable. [Tarmo Tänav]
56
57 * MySQL: rename_column preserves column defaults. #466 [Diego Algorta]
58
59 * Add :from option to calculations. #397 [Ben Munat]
60
61 * Add :validate option to associations to enable/disable the automatic validation of associated models. Resolves #301. [Jan De Poorter]
62
63 * PostgreSQL: use 'INSERT ... RETURNING id' for 8.2 and later. [Jeremy Kemper]
64
65 * Added SQL escaping for :limit and :offset in MySQL [Jonathan Wiess]
66
67
68 *2.1.0 (May 31st, 2008)*
69
70 * Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [rick]
71
72 * Add first/last methods to associations/named_scope. Resolved #226. [Ryan Bates]
73
74 * Added SQL escaping for :limit and :offset #288 [Aaron Bedra, Steven Bristol, Jonathan Wiess]
75
76 * Added first/last methods to associations/named_scope. Resolved #226. [Ryan Bates]
77
78 * Ensure hm:t preloading honours reflection options. Resolves #137. [Frederick Cheung]
79
80 * Added protection against duplicate migration names (Aslak Hellesøy) [#112]
81
82 * Base#instantiate_time_object: eliminate check for Time.zone, since we can assume this is set if time_zone_aware_attributes is set to true [Geoff Buesing]
83
84 * Time zone aware attribute methods use Time.zone.parse instead of #to_time for String arguments, so that offset information in String is respected. Resolves #105. [Scott Fleckenstein, Geoff Buesing]
85
86 * Added change_table for migrations (Jeff Dean) [#71]. Example:
87
88 change_table :videos do |t|
89 t.timestamps # adds created_at, updated_at
90 t.belongs_to :goat # adds goat_id integer
91 t.string :name, :email, :limit => 20 # adds name and email both with a 20 char limit
92 t.remove :name, :email # removes the name and email columns
93 end
94
95 * Fixed has_many :through .create with no parameters caused a "can't dup NilClass" error (Steven Soroka) [#85]
96
97 * Added block-setting of attributes for Base.create like Base.new already has (Adam Meehan) [#39]
98
99 * Fixed that pessimistic locking you reference the quoted table name (Josh Susser) [#67]
100
101 * Fixed that change_column should be able to use :null => true on a field that formerly had false [Nate Wiger] [#26]
102
103 * Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [DHH]
104
105 * Change validates_uniqueness_of :case_sensitive option default back to true (from [9160]). Love your database columns, don't LOWER them. [rick]
106
107 * Add support for interleaving migrations by storing which migrations have run in the new schema_migrations table. Closes #11493 [jordi]
108
109 * ActiveRecord::Base#sum defaults to 0 if no rows are returned. Closes #11550 [kamal]
110
111 * Ensure that respond_to? considers dynamic finder methods. Closes #11538. [floehopper]
112
113 * Ensure that save on parent object fails for invalid has_one association. Closes #10518. [Pratik]
114
115 * Remove duplicate code from associations. [Pratik]
116
117 * Refactor HasManyThroughAssociation to inherit from HasManyAssociation. Association callbacks and <association>_ids= now work with hm:t. #11516 [rubyruy]
118
119 * Ensure HABTM#create and HABTM#build do not load entire association. [Pratik]
120
121 * Improve documentation. [Xavier Noria, Jack Danger Canty, leethal]
122
123 * Tweak ActiveRecord::Base#to_json to include a root value in the returned hash: {"post": {"title": ...}} [rick]
124
125 Post.find(1).to_json # => {"title": ...}
126 config.active_record.include_root_in_json = true
127 Post.find(1).to_json # => {"post": {"title": ...}}
128
129 * Add efficient #include? to AssociationCollection (for has_many/has_many :through/habtm). [stopdropandrew]
130
131 * PostgreSQL: create_ and drop_database support. #9042 [ez, pedz, nicksieger]
132
133 * Ensure that validates_uniqueness_of works with with_scope. Closes #9235. [nik.wakelin, cavalle]
134
135 * Partial updates include only unsaved attributes. Off by default; set YourClass.partial_updates = true to enable. [Jeremy Kemper]
136
137 * Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing]
138
139 * Fixed that validates_size_of :within works in associations #11295, #10019 [cavalle]
140
141 * Track changes to unsaved attributes. [Jeremy Kemper]
142
143 * Switched to UTC-timebased version numbers for migrations and the schema. This will as good as eliminate the problem of multiple migrations getting the same version assigned in different branches. Also added rake db:migrate:up/down to apply individual migrations that may need to be run when you merge branches #11458 [jbarnette]
144
145 * Fixed that has_many :through would ignore the hash conditions #11447 [miloops]
146
147 * Fix issue where the :uniq option of a has_many :through association is ignored when find(:all) is called. Closes #9407 [cavalle]
148
149 * Fix duplicate table alias error when including an association with a has_many :through association on the same join table. Closes #7310 [cavalle]
150
151 * More efficient association preloading code that compacts a through_records array in a central location. Closes #11427 [danger]
152
153 * Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
154
155 * Fixed that ActiveRecord#Base.find_or_create/initialize would not honor attr_protected/accessible when used with a hash #11422 [miloops]
156
157 * Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) #11413 [nkallen, thechrisoshow]
158
159 * Merge the has_finder gem, renamed as 'named_scope'. #11404 [nkallen]
160
161 class Article < ActiveRecord::Base
162 named_scope :published, :conditions => {:published => true}
163 named_scope :popular, :conditions => ...
164 end
165
166 Article.published.paginate(:page => 1)
167 Article.published.popular.count
168 Article.popular.find(:first)
169 Article.popular.find(:all, :conditions => {...})
170
171 See http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries
172
173 * Add has_one :through support. #4756 [thechrisoshow]
174
175 * Migrations: create_table supports primary_key_prefix_type. #10314 [student, thechrisoshow]
176
177 * Added logging for dependency load errors with fixtures #11056 [stuthulhu]
178
179 * Time zone aware attributes use Time#in_time_zone [Geoff Buesing]
180
181 * Fixed that scoped joins would not always be respected #6821 [Theory/Danger]
182
183 * Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle]
184
185 * Added add/remove_timestamps to the schema statements for adding the created_at/updated_at columns on existing tables #11129 [jramirez]
186
187 * Added ActiveRecord::Base.find(:last) #11338 [miloops]
188
189 * test_native_types expects DateTime.local_offset instead of DateTime.now.offset; fixes test breakage due to dst transition [Geoff Buesing]
190
191 * Add :readonly option to HasManyThrough associations. #11156 [miloops]
192
193 * Improve performance on :include/:conditions/:limit queries by selectively joining in the pre-query. #9560 [dasil003]
194
195 * Perf fix: Avoid the use of named block arguments. Closes #11109 [adymo]
196
197 * PostgreSQL: support server versions 7.4 through 8.0 and the ruby-pg driver. #11127 [jdavis]
198
199 * Ensure association preloading doesn't break when an association returns nil. ##11145 [GMFlash]
200
201 * Make dynamic finders respect the :include on HasManyThrough associations. #10998. [cpytel]
202
203 * Base#instantiate_time_object only uses Time.zone when Base.time_zone_aware_attributes is true; leverages Time#time_with_datetime_fallback for readability [Geoff Buesing]
204
205 * Refactor ConnectionAdapters::Column.new_time: leverage DateTime failover behavior of Time#time_with_datetime_fallback [Geoff Buesing]
206
207 * Improve associations performance by using symbol callbacks instead of string callbacks. #11108 [adymo]
208
209 * Optimise the BigDecimal conversion code. #11110 [adymo]
210
211 * Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [miloops]
212
213 * Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing]
214
215 * Base#instantiate_time_object uses Time.zone.local() [Geoff Buesing]
216
217 * Add timezone-aware attribute readers and writers. #10982 [Geoff Buesing]
218
219 * Instantiating time objects in multiparameter attributes uses Time.zone if available. #10982 [rick]
220
221 * Add note about how ActiveRecord::Observer classes are initialized in a Rails app. #10980 [fxn]
222
223 * MySQL: omit text/blob defaults from the schema instead of using an empty string. #10963 [mdeiters]
224
225 * belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney]
226
227 * Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aleksey Kondratenko, codafoo]
228
229 * Support aggregations in finder conditions. #10572 [Ryan Kinderman]
230
231 * Organize and clean up the Active Record test suite. #10742 [John Barnette]
232
233 * Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews]
234
235 * Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu]
236
237 * Fixtures: removed support for the ancient pre-YAML file format. #10736 [John Barnette]
238
239 * More thoroughly quote table names. #10698 [dimdenis, lotswholetime, Jeremy Kemper]
240
241 * update_all ignores scoped :order and :limit, so post.comments.update_all doesn't try to include the comment order in the update statement. #10686 [Brendan Ribera]
242
243 * Added ActiveRecord::Base.cache_key to make it easier to cache Active Records in combination with the new ActiveSupport::Cache::* libraries [DHH]
244
245 * Make sure CSV fixtures are compatible with ruby 1.9's new csv implementation. [JEG2]
246
247 * Added by parameter to increment, decrement, and their bang varieties so you can do player1.increment!(:points, 5) #10542 [Sam]
248
249 * Optimize ActiveRecord::Base#exists? to use #select_all instead of #find. Closes #10605 [jamesh, fcheung, protocool]
250
251 * Don't unnecessarily load has_many associations in after_update callbacks. Closes #6822 [stopdropandrew, canadaduane]
252
253 * Eager belongs_to :include infers the foreign key from the association name rather than the class name. #10517 [Jonathan Viney]
254
255 * SQLite: fix rename_ and remove_column for columns with unique indexes. #10576 [Brandon Keepers]
256
257 * Ruby 1.9 compatibility. #10655 [Jeremy Kemper, Dirkjan Bussink]
258
259
260 *2.0.2* (December 16th, 2007)
261
262 * Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [rick]
263
264 * Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases. Closes #10379 [brynary]
265
266 * Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [hasmanyjosh]
267
268 * Ensure that the :uniq option for has_many :through associations retains the order. #10463 [remvee]
269
270 * Base.exists? doesn't rescue exceptions to avoid hiding SQL errors. #10458 [Michael Klishin]
271
272 * Documentation: Active Record exceptions, destroy_all and delete_all. #10444, #10447 [Michael Klishin]
273
274
275 *2.0.1* (December 7th, 2007)
276
277 * Removed query cache rescue as it could cause code to be run twice (closes #10408) [DHH]
278
279
280 *2.0.0* (December 6th, 2007)
281
282 * Anchor DateTimeTest to fixed DateTime instead of a variable value based on Time.now#advance#to_datetime, so that this test passes on 64-bit platforms running Ruby 1.8.6+ [Geoff Buesing]
283
284 * Fixed that the Query Cache should just be ignored if the database is misconfigured (so that the "About your applications environment" works even before the database has been created) [DHH]
285
286 * Fixed that the truncation of strings longer than 50 chars should use inspect
287 so newlines etc are escaped #10385 [Norbert Crombach]
288
289 * Fixed that habtm associations should be able to set :select as part of their definition and have that honored [DHH]
290
291 * Document how the :include option can be used in Calculations::calculate. Closes #7446 [adamwiggins, ultimoamore]
292
293 * Fix typo in documentation for polymorphic associations w/STI. Closes #7461 [johnjosephbachir]
294
295 * Reveal that the type option in migrations can be any supported column type for your database but also include caveat about agnosticism. Closes #7531 [adamwiggins, mikong]
296
297 * More complete documentation for find_by_sql. Closes #7912 [fearoffish]
298
299 * Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [DHH]. Example:
300
301 render :partial => @client.becomes(Company) # renders companies/company instead of clients/client
302
303 * Fixed that to_xml should not automatically pass :procs to associations included with :include #10162 [Cheah Chu Yeow]
304
305 * Fix documentation typo introduced in [8250]. Closes #10339 [Henrik N]
306
307 * Foxy fixtures: support single-table inheritance. #10234 [tom]
308
309 * Foxy fixtures: allow mixed usage to make migration easier and more attractive. #10004 [lotswholetime]
310
311 * Make the record_timestamps class-inheritable so it can be set per model. #10004 [tmacedo]
312
313 * Allow validates_acceptance_of to use a real attribute instead of only virtual (so you can record that the acceptance occured) #7457 [ambethia]
314
315 * DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing]
316
317 * Dynamic finders on association collections respect association :order and :limit. #10211, #10227 [Patrick Joyce, Rick Olson, Jack Danger Canty]
318
319 * Add 'foxy' support for fixtures of polymorphic associations. #10183 [John Barnette, David Lowenfels]
320
321 * validates_inclusion_of and validates_exclusion_of allow formatted :message strings. #8132 [devrieda, Mike Naberezny]
322
323 * attr_readonly behaves well with optimistic locking. #10188 [Nick Bugajski]
324
325 * Base#to_xml supports the nil="true" attribute like Hash#to_xml. #8268 [Catfish]
326
327 * Change plings to the more conventional quotes in the documentation. Closes #10104 [danger]
328
329 * Fix HasManyThrough Association so it uses :conditions on the HasMany Association. Closes #9729 [danger]
330
331 * Ensure that column names are quoted. Closes #10134 [wesley.moxam]
332
333 * Smattering of grammatical fixes to documentation. Closes #10083 [BobSilva]
334
335 * Enhance explanation with more examples for attr_accessible macro. Closes #8095 [fearoffish, Marcel Molina]
336
337 * Update association/method mapping table to refected latest collection methods for has_many :through. Closes #8772 [Pratik Naik]
338
339 * Explain semantics of having several different AR instances in a transaction block. Closes #9036 [jacobat, Marcel Molina]
340
341 * Update Schema documentation to use updated sexy migration notation. Closes #10086 [sjgman9]
342
343 * Make fixtures work with the new test subclasses. [Tarmo Tänav, Koz]
344
345 * Introduce finder :joins with associations. Same :include syntax but with inner rather than outer joins. #10012 [RubyRedRick]
346 # Find users with an avatar
347 User.find(:all, :joins => :avatar)
348
349 # Find posts with a high-rated comment.
350 Post.find(:all, :joins => :comments, :conditions => 'comments.rating > 3')
351
352 * Associations: speedup duplicate record check. #10011 [Pratik Naik]
353
354 * Make sure that << works on has_many associations on unsaved records. Closes #9989 [hasmanyjosh]
355
356 * Allow association redefinition in subclasses. #9346 [wildchild]
357
358 * Fix has_many :through delete with custom foreign keys. #6466 [naffis]
359
360 * Foxy fixtures, from rathole (http://svn.geeksomnia.com/rathole/trunk/README)
361 - stable, autogenerated IDs
362 - specify associations (belongs_to, has_one, has_many) by label, not ID
363 - specify HABTM associations as inline lists
364 - autofill timestamp columns
365 - support YAML defaults
366 - fixture label interpolation
367 Enabled for fixtures that correspond to a model class and don't specify a primary key value. #9981 [John Barnette]
368
369 * Add docs explaining how to protect all attributes using attr_accessible with no arguments. Closes #9631 [boone, rmm5t]
370
371 * Update add_index documentation to use new options api. Closes #9787 [Kamal Fariz Mahyuddin]
372
373 * Allow find on a has_many association defined with :finder_sql to accept id arguments as strings like regular find does. Closes #9916 [krishna]
374
375 * Use VALID_FIND_OPTIONS when resolving :find scoping rather than hard coding the list of valid find options. Closes #9443 [sur]
376
377 * Limited eager loading no longer ignores scoped :order. Closes #9561 [danger, Josh Peek]
378
379 * Assigning an instance of a foreign class to a composed_of aggregate calls an optional conversion block. Refactor and simplify composed_of implementation. #6322 [brandon, Chris Cruft]
380
381 * Assigning nil to a composed_of aggregate also sets its immediate value to nil. #9843 [Chris Cruft]
382
383 * Ensure that mysql quotes table names with database names correctly. Closes #9911 [crayz]
384
385 "foo.bar" => "`foo`.`bar`"
386
387 * Complete the assimilation of Sexy Migrations from ErrFree [Chris Wanstrath, PJ Hyett]
388 http://errtheblog.com/post/2381
389
390 * Qualified column names work in hash conditions, like :conditions => { 'comments.created_at' => ... }. #9733 [danger]
391
392 * Fix regression where the association would not construct new finder SQL on save causing bogus queries for "WHERE owner_id = NULL" even after owner was saved. #8713 [Bryan Helmkamp]
393
394 * Refactor association create and build so before & after callbacks behave consistently. #8854 [Pratik Naik, mortent]
395
396 * Quote table names. Defaults to column quoting. #4593 [Justin Lynn, gwcoffey, eadz, Dmitry V. Sabanin, Jeremy Kemper]
397
398 * Alias association #build to #new so it behaves predictably. #8787 [Pratik Naik]
399
400 * Add notes to documentation regarding attr_readonly behavior with counter caches and polymorphic associations. Closes #9835 [saimonmoore, rick]
401
402 * Observers can observe model names as symbols properly now. Closes #9869 [queso]
403
404 * find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Luetke]
405
406 * belongs_to infers the foreign key from the association name instead of from the class name. [Jeremy Kemper]
407
408 * PostgreSQL: support multiline default values. #7533 [Carl Lerche, aguynamedryan, Rein Henrichs, Tarmo Tänav]
409
410 * MySQL: fix change_column on not-null columns that don't accept dfeault values of ''. #6663 [Jonathan Viney, Tarmo Tänav]
411
412 * validates_uniqueness_of behaves well with abstract superclasses and
413 single-table inheritance. #3833, #9886 [Gabriel Gironda, rramdas, François Beausoleil, Josh Peek, Tarmo Tänav, pat]
414
415 * Warn about protected attribute assigments in development and test environments when mass-assigning to an attr_protected attribute. #9802 [Henrik N]
416
417 * Speedup database date/time parsing. [Jeremy Kemper, Tarmo Tänav]
418
419 * Fix calling .clear on a has_many :dependent=>:delete_all association. [Tarmo Tänav]
420
421 * Allow change_column to set NOT NULL in the PostgreSQL adapter [Tarmo Tänav]
422
423 * Fix that ActiveRecord would create attribute methods and override custom attribute getters if the method is also defined in Kernel.methods. [Rick]
424
425 * Don't call attr_readonly on polymorphic belongs_to associations, in case it matches the name of some other non-ActiveRecord class/module. [Rick]
426
427 * Try loading activerecord-<adaptername>-adapter gem before trying a plain require so you can use custom gems for the bundled adapters. Also stops gems from requiring an adapter from an old Active Record gem. [Jeremy Kemper, Derrick Spell]
428
429
430 *2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.14.2 - 1.15.3]
431
432 * Add attr_readonly to specify columns that are skipped during a normal ActiveRecord #save operation. Closes #6896 [dcmanges]
433
434 class Comment < ActiveRecord::Base
435 # Automatically sets Article#comments_count as readonly.
436 belongs_to :article, :counter_cache => :comments_count
437 end
438
439 class Article < ActiveRecord::Base
440 attr_readonly :approved_comments_count
441 end
442
443 * Make size for has_many :through use counter cache if it exists. Closes #9734 [xaviershay]
444
445 * Remove DB2 adapter since IBM chooses to maintain their own adapter instead. [Jeremy Kemper]
446
447 * Extract Oracle, SQLServer, and Sybase adapters into gems. [Jeremy Kemper]
448
449 * Added fixture caching that'll speed up a normal fixture-powered test suite between 50% and 100% #9682 [Frederick Cheung]
450
451 * Correctly quote id list for limited eager loading. #7482 [tmacedo]
452
453 * Fixed that using version-targetted migrates would fail on loggers other than the default one #7430 [valeksenko]
454
455 * Fixed rename_column for SQLite when using symbols for the column names #8616 [drodriguez]
456
457 * Added the possibility of using symbols in addition to concrete classes with ActiveRecord::Observer#observe. #3998 [Robby Russell, Tarmo Tänav]
458
459 * Added ActiveRecord::Base#to_json/from_json [DHH, Cheah Chu Yeow]
460
461 * Added ActiveRecord::Base#from_xml [DHH]. Example:
462
463 xml = "<person><name>David</name></person>"
464 Person.new.from_xml(xml).name # => "David"
465
466 * Define dynamic finders as real methods after first usage. [bscofield]
467
468 * Deprecation: remove deprecated threaded_connections methods. Use allow_concurrency instead. [Jeremy Kemper]
469
470 * Associations macros accept extension blocks alongside modules. #9346 [Josh Peek]
471
472 * Speed up and simplify query caching. [Jeremy Kemper]
473
474 * connection.select_rows 'sql' returns an array (rows) of arrays (field values). #2329 [Michael Schuerig]
475
476 * Eager loading respects explicit :joins. #9496 [dasil003]
477
478 * Extract Firebird, FrontBase, and OpenBase adapters into gems. #9508, #9509, #9510 [Jeremy Kemper]
479
480 * RubyGem database adapters: expects a gem named activerecord-<database>-adapter with active_record/connection_adapters/<database>_adapter.rb in its load path. [Jeremy Kemper]
481
482 * Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon]
483
484 * Fix association writer with :dependent => :nullify. #7314 [Jonathan Viney]
485
486 * OpenBase: update for new lib and latest Rails. Support migrations. #8748 [dcsesq]
487
488 * Moved acts_as_tree into a plugin of the same name on the official Rails svn. #9514 [Pratik Naik]
489
490 * Moved acts_as_nested_set into a plugin of the same name on the official Rails svn. #9516 [Josh Peek]
491
492 * Moved acts_as_list into a plugin of the same name on the official Rails svn. [Josh Peek]
493
494 * Explicitly require active_record/query_cache before using it. [Jeremy Kemper]
495
496 * Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick, marclove]
497
498 * Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper]
499
500 * Fixed that eager loading queries and with_scope should respect the :group option [DHH]
501
502 * Improve performance and functionality of the postgresql adapter. Closes #8049 [roderickvd]
503
504 For more information see: http://dev.rubyonrails.org/ticket/8049
505
506 * Don't clobber includes passed to has_many.count [danger]
507
508 * Make sure has_many uses :include when counting [danger]
509
510 * Change the implementation of ActiveRecord's attribute reader and writer methods [nzkoz]
511 - Generate Reader and Writer methods which cache attribute values in hashes. This is to avoid repeatedly parsing the same date or integer columns.
512 - Change exception raised when users use find with :select then try to access a skipped column. Plugins could override missing_attribute() to lazily load the columns.
513 - Move method definition to the class, instead of the instance
514 - Always generate the readers, writers and predicate methods.
515
516 * Perform a deep #dup on query cache results so that modifying activerecord attributes does not modify the cached attributes. [Rick]
517
518 # Ensure that has_many :through associations use a count query instead of loading the target when #size is called. Closes #8800 [Pratik Naik]
519
520 * Added :unless clause to validations #8003 [monki]. Example:
521
522 def using_open_id?
523 !identity_url.blank?
524 end
525
526 validates_presence_of :identity_url, :if => using_open_id?
527 validates_presence_of :username, :unless => using_open_id?
528 validates_presence_of :password, :unless => using_open_id?
529
530 * Fix #count on a has_many :through association so that it recognizes the :uniq option. Closes #8801 [Pratik Naik]
531
532 * Fix and properly document/test count(column_name) usage. Closes #8999 [Pratik Naik]
533
534 * Remove deprecated count(conditions=nil, joins=nil) usage. Closes #8993 [Pratik Naik]
535
536 * Change belongs_to so that the foreign_key assumption is taken from the association name, not the class name. Closes #8992 [hasmanyjosh]
537
538 OLD
539 belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is user_id
540
541 NEW
542 belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is visitor_id
543
544 * Remove spurious tests from deprecated_associations_test, most of these aren't deprecated, and are duplicated in associations_test. Closes #8987 [Pratik Naik]
545
546 * Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [Pratik Naik]
547
548 * Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003]
549
550 * Don't call unsupported methods on associated objects when using :include, :method with to_xml #7307, [manfred, jwilger]
551
552 * Define collection singular ids method for has_many :through associations. #8763 [Pratik Naik]
553
554 * Array attribute conditions work with proxied association collections. #8318 [Kamal Fariz Mahyuddin, theamazingrando]
555
556 * Fix polymorphic has_one associations declared in an abstract class. #8638 [Pratik Naik, Dax Huiberts]
557
558 * Fixed validates_associated should not stop on the first error. #4276 [mrj, Manfred Stienstra, Josh Peek]
559
560 * Rollback if commit raises an exception. #8642 [kik, Jeremy Kemper]
561
562 * Update tests' use of fixtures for the new collections api. #8726 [Kamal Fariz Mahyuddin]
563
564 * Save associated records only if the association is already loaded. #8713 [blaine]
565
566 * MySQL: fix show_variable. #8448 [matt, Jeremy Kemper]
567
568 * Fixtures: correctly delete and insert fixtures in a single transaction. #8553 [Michael Schuerig]
569
570 * Fixtures: people(:technomancy, :josh) returns both fixtures. #7880 [technomancy, Josh Peek]
571
572 * Calculations support non-numeric foreign keys. #8154 [Kamal Fariz Mahyuddin]
573
574 * with_scope is protected. #8524 [Josh Peek]
575
576 * Quickref for association methods. #7723 [marclove, Mindsweeper]
577
578 * Calculations: return nil average instead of 0 when there are no rows to average. #8298 [davidw]
579
580 * acts_as_nested_set: direct_children is sorted correctly. #4761 [Josh Peek, rails@33lc0.net]
581
582 * Raise an exception if both attr_protected and attr_accessible are declared. #8507 [stellsmi]
583
584 * SQLite, MySQL, PostgreSQL, Oracle: quote column names in column migration SQL statements. #8466 [marclove, lorenjohnson]
585
586 * Allow nil serialized attributes with a set class constraint. #7293 [sandofsky]
587
588 * Oracle: support binary fixtures. #7987 [Michael Schoen]
589
590 * Fixtures: pull fixture insertion into the database adapters. #7987 [Michael Schoen]
591
592 * Announce migration versions as they're performed. [Jeremy Kemper]
593
594 * find gracefully copes with blank :conditions. #7599 [Dan Manges, johnnyb]
595
596 * validates_numericality_of takes :greater_than, :greater_than_or_equal_to, :equal_to, :less_than, :less_than_or_equal_to, :odd, and :even options. #3952 [Bob Silva, Dan Kubb, Josh Peek]
597
598 * MySQL: create_database takes :charset and :collation options. Charset defaults to utf8. #8448 [matt]
599
600 * Find with a list of ids supports limit/offset. #8437 [hrudududu]
601
602 * Optimistic locking: revert the lock version when an update fails. #7840 [plang]
603
604 * Migrations: add_column supports custom column types. #7742 [jsgarvin, Theory]
605
606 * Load database adapters on demand. Eliminates config.connection_adapters and RAILS_CONNECTION_ADAPTERS. Add your lib directory to the $LOAD_PATH and put your custom adapter in lib/active_record/connection_adapters/adaptername_adapter.rb. This way you can provide custom adapters as plugins or gems without modifying Rails. [Jeremy Kemper]
607
608 * Ensure that associations with :dependent => :delete_all respect :conditions option. Closes #8034 [danger, Josh Peek, Rick]
609
610 * belongs_to assignment creates a new proxy rather than modifying its target in-place. #8412 [mmangino@elevatedrails.com]
611
612 * Fix column type detection while loading fixtures. Closes #7987 [roderickvd]
613
614 * Document deep eager includes. #6267 [Josh Susser, Dan Manges]
615
616 * Document warning that associations names shouldn't be reserved words. #4378 [murphy@cYcnus.de, Josh Susser]
617
618 * Sanitize Base#inspect. #8392, #8623 [Nik Wakelin, jnoon]
619
620 * Replace the transaction {|transaction|..} semantics with a new Exception ActiveRecord::Rollback. [Koz]
621
622 * Oracle: extract column length for CHAR also. #7866 [ymendel]
623
624 * Document :allow_nil option for validates_acceptance_of since it defaults to true. [tzaharia]
625
626 * Update documentation for :dependent declaration so that it explicitly uses the non-deprecated API. [danger]
627
628 * Add documentation caveat about when to use count_by_sql. [fearoffish]
629
630 * Enhance documentation for increment_counter and decrement_counter. [fearoffish]
631
632 * Provide brief introduction to what optimistic locking is. [fearoffish]
633
634 * Add documentation for :encoding option to mysql adapter. [marclove]
635
636 * Added short-hand declaration style to migrations (inspiration from Sexy Migrations, http://errtheblog.com/post/2381) [DHH]. Example:
637
638 create_table "products" do |t|
639 t.column "shop_id", :integer
640 t.column "creator_id", :integer
641 t.column "name", :string, :default => "Untitled"
642 t.column "value", :string, :default => "Untitled"
643 t.column "created_at", :datetime
644 t.column "updated_at", :datetime
645 end
646
647 ...can now be written as:
648
649 create_table :products do |t|
650 t.integer :shop_id, :creator_id
651 t.string :name, :value, :default => "Untitled"
652 t.timestamps
653 end
654
655 * Use association name for the wrapper element when using .to_xml. Previous behavior lead to non-deterministic situations with STI and polymorphic associations. [Koz, jstrachan]
656
657 * Improve performance of calling .create on has_many :through associations. [evan]
658
659 * Improved cloning performance by relying less on exception raising #8159 [Blaine]
660
661 * Added ActiveRecord::Base.inspect to return a column-view like #<Post id:integer, title:string, body:text> [DHH]
662
663 * Added yielding of Builder instance for ActiveRecord::Base#to_xml calls [DHH]
664
665 * Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally]
666
667 * Add helpful debugging info to the ActiveRecord::StatementInvalid exception in ActiveRecord::ConnectionAdapters::SqliteAdapter#table_structure. Closes #7925. [court3nay]
668
669 * SQLite: binary escaping works with $KCODE='u'. #7862 [tsuka]
670
671 * Base#to_xml supports serialized attributes. #7502 [jonathan]
672
673 * Base.update_all :order and :limit options. Useful for MySQL updates that must be ordered to avoid violating unique constraints. [Jeremy Kemper]
674
675 * Remove deprecated object transactions. People relying on this functionality should install the object_transactions plugin at http://code.bitsweat.net/svn/object_transactions. Closes #5637 [Koz, Jeremy Kemper]
676
677 * PostgreSQL: remove DateTime -> Time downcast. Warning: do not enable translate_results for the C bindings if you have timestamps outside Time's domain. [Jeremy Kemper]
678
679 * find_or_create_by_* takes a hash so you can create with more attributes than are in the method name. For example, Person.find_or_create_by_name(:name => 'Henry', :comments => 'Hi new user!') is equivalent to Person.find_by_name('Henry') || Person.create(:name => 'Henry', :comments => 'Hi new user!'). #7368 [Josh Susser]
680
681 * Make sure with_scope takes both :select and :joins into account when setting :readonly. Allows you to save records you retrieve using method_missing on a has_many :through associations. [Koz]
682
683 * Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool]
684
685 * Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges]
686
687 * Oracle: fix quoted primary keys and datetime overflow. #7798 [Michael Schoen]
688
689 * Consistently quote primary key column names. #7763 [toolmantim]
690
691 * Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley]
692
693 * DateTimes assume the default timezone. #7764 [Geoff Buesing]
694
695 * Sybase: hide timestamp columns since they're inherently read-only. #7716 [Mike Joyce]
696
697 * Oracle: overflow Time to DateTime. #7718 [Michael Schoen]
698
699 * PostgreSQL: don't use async_exec and async_query with postgres-pr. #7727, #7762 [flowdelic, toolmantim]
700
701 * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins]
702
703 * Test DateTime native type in migrations, including an edge case with dates
704 during calendar reform. #7649, #7724 [fedot, Geoff Buesing]
705
706 * SQLServer: correctly schema-dump tables with no indexes or descending indexes. #7333, #7703 [Jakob S, Tom Ward]
707
708 * SQLServer: recognize real column type as Ruby float. #7057 [sethladd, Tom Ward]
709
710 * Added fixtures :all as a way of loading all fixtures in the fixture directory at once #7214 [manfred]
711
712 * Added database connection as a yield parameter to ActiveRecord::Base.transaction so you can manually rollback [DHH]. Example:
713
714 transaction do |transaction|
715 david.withdrawal(100)
716 mary.deposit(100)
717 transaction.rollback! # rolls back the transaction that was otherwise going to be successful
718 end
719
720 * Made increment_counter/decrement_counter play nicely with optimistic locking, and added a more general update_counters method [Jamis Buck]
721
722 * Reworked David's query cache to be available as Model.cache {...}. For the duration of the block no select query should be run more then once. Any inserts/deletes/executes will flush the whole cache however [Tobias Luetke]
723 Task.cache { Task.find(1); Task.find(1) } #=> 1 query
724
725 * When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck]
726
727 * Oracle: fix lob and text default handling. #7344 [gfriedrich, Michael Schoen]
728
729 * SQLServer: don't choke on strings containing 'null'. #7083 [Jakob S]
730
731 * MySQL: blob and text columns may not have defaults in 5.x. Update fixtures schema for strict mode. #6695 [Dan Kubb]
732
733 * update_all can take a Hash argument. sanitize_sql splits into two methods for conditions and assignment since NULL values and delimiters are handled differently. #6583, #7365 [sandofsky, Assaf]
734
735 * MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc]
736
737 * Use Date#to_s(:db) for quoted dates. #7411 [Michael Schoen]
738
739 * Don't create instance writer methods for class attributes. Closes #7401 [Rick]
740
741 * Docs: validations examples. #7343 [zackchandler]
742
743 * Add missing tests ensuring callbacks work with class inheritance. Closes #7339 [sandofsky]
744
745 * Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
746
747 * Remove useless code in #attribute_present? since 0 != blank?. Closes #7249 [Josh Susser]
748
749 * Fix minor doc typos. Closes #7157 [Josh Susser]
750
751 * Fix incorrect usage of #classify when creating the eager loading join statement. Closes #7044 [Josh Susser]
752
753 * SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
754
755 * Subclasses of an abstract class work with single-table inheritance. #5704, #7284 [BertG, nick+rails@ag.arizona.edu]
756
757 * Make sure sqlite3 driver closes open connections on disconnect [Rob Rasmussen]
758
759 * [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [jeremymcanally]
760
761 * change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [Dan Manges, Jeremy Kemper]
762
763 * MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, manfred, altano@bigfoot.com]
764
765 * Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen]
766
767 * MySQL: retain SSL settings on reconnect. #6976 [randyv2]
768
769 * Apply scoping during initialize instead of create. Fixes setting of foreign key when using find_or_initialize_by with scoping. [Cody Fauser]
770
771 * SQLServer: handle [quoted] table names. #6635 [rrich]
772
773 * acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser]
774
775 * PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen]
776
777 * Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [Dan Manges]
778 Student.find(:all, :conditions => { :grade => 9..12 })
779
780 * Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler]
781
782 * [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell]
783
784 * [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot]
785
786 * Bring the sybase adapter up to scratch for 1.2 release. [jsheets]
787
788 * Rollback new_record? and id when an exception is raised in a save callback. #6910 [Ben Curren, outerim]
789
790 * Pushing a record on an association collection doesn't unnecessarily load all the associated records. [Obie Fernandez, Jeremy Kemper]
791
792 * Oracle: fix connection reset failure. #6846 [leonlleslie]
793
794 * Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper]
795
796 * fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool]
797
798 * Consolidated different create and create! versions to call through to the base class with scope. This fixes inconsistencies, especially related to protected attribtues. Closes #5847 [Alexander Dymo, Tobias Luetke]
799
800 * find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper]
801
802 * Add AssociationCollection#create! to be consistent with AssociationCollection#create when dealing with a foreign key that is a protected attribute [Cody Fauser]
803
804 * Added counter optimization for AssociationCollection#any? so person.friends.any? won't actually load the full association if we have the count in a cheaper form [DHH]
805
806 * Change fixture_path to a class inheritable accessor allowing test cases to have their own custom set of fixtures. #6672 [zdennis]
807
808 * Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov]
809
810 * Simplify query_attribute by typecasting the attribute value and checking whether it's nil, false, zero or blank. #6659 [Jonathan Viney]
811
812 * validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz]
813
814 * Run validations in the order they were declared. #6657 [obrie]
815
816 * MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper]
817
818 * Simplify association proxy implementation by factoring construct_scope out of method_missing. #6643 [martin]
819
820 * Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen]
821
822 * Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen]
823
824 * Don't inspect unloaded associations. #2905 [lmarlow]
825
826 * SQLite: use AUTOINCREMENT primary key in >= 3.1.0. #6588, #6616 [careo, lukfugl]
827
828 * Cache inheritance_column. #6592 [Stefan Kaes]
829
830 * Firebird: decimal/numeric support. #6408 [macrnic]
831
832 * make add_order a tad faster. #6567 [Stefan Kaes]
833
834 * Find with :include respects scoped :order. #5850
835
836 * Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper]
837 find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil }
838
839 * Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si]
840
841 * SQLite: fix calculations workaround, remove count(distinct) query rewrite, cleanup test connection scripts. [Jeremy Kemper]
842
843 * SQLite: count(distinct) queries supported in >= 3.2.6. #6544 [Bob Silva]
844
845 * Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes]
846
847 * Deprecation: object transactions warning. [Jeremy Kemper]
848
849 * has_one :dependent => :nullify ignores nil associates. #4848, #6528 [bellis@deepthought.org, janovetz, Jeremy Kemper]
850
851 * Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen]
852
853 * Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie]
854
855 * Document other options available to migration's add_column. #6419 [grg]
856
857 * MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper]
858
859 * Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney]
860
861 * fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick]
862
863 * Restore eager condition interpolation, document it's differences [Rick]
864
865 * Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper]
866
867 * Add #delete support to has_many :through associations. Closes #6049 [Martin Landers]
868
869 * Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick]
870
871 * Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com]
872
873 * Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com]
874
875 * Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan]
876
877 * Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [BobSilva]
878
879 * The has_many create method works with polymorphic associations. #6361 [Dan Peterson]
880
881 * MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes]
882
883 * save! shouldn't validate twice. #6324 [maiha, Bob Silva]
884
885 * Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig]
886
887 * Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson]
888
889 * Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva]
890
891 * has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper]
892
893 * Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Koz]
894
895 * Add a :namespace option to AR::Base#to_xml [Koz]
896
897 * Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper]
898
899 * Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson]
900
901 * Improve yaml fixtures error reporting. #6205 [Bruce Williams]
902
903 * Rename AR::Base#quote so people can use that name in their models. #3628 [Koz]
904
905 * Add deprecation warning for inferred foreign key. #6029 [Josh Susser]
906
907 * Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com]
908
909 * Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser]
910
911 * Document validates_presences_of behavior with booleans: you probably want validates_inclusion_of :attr, :in => [true, false]. #2253 [Bob Silva]
912
913 * Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward]
914
915 * to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher]
916
917 * Deprecation: update docs. #5998 [jakob@mentalized.net, Kevin Clark]
918
919 * Add some XmlSerialization tests for ActiveRecord [Rick Olson]
920
921 * has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com]
922
923 * Tighten rescue clauses. #5985 [james@grayproductions.net]
924
925 * Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck]
926
927 * has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney]
928
929 * Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney]
930
931 * SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi]
932
933 * SQLServer: fix eager association test. #5901 [Tom Ward]
934
935 * Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark]
936
937 * Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com]
938
939 * Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com]
940
941 * MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward]
942
943 * to_xml: correct naming of included associations. #5831 [josh.starcher@gmail.com]
944
945 * Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [josh@hasmanythrough.com]
946
947 * Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper]
948
949 # Create a tagging to associate the post and tag.
950 post.tags << Tag.find_by_name('old')
951 post.tags.create! :name => 'general'
952
953 # Would have been:
954 post.taggings.create!(:tag => Tag.find_by_name('finally')
955 transaction do
956 post.taggings.create!(:tag => Tag.create!(:name => 'general'))
957 end
958
959 * Cache nil results for :included has_one associations also. #5787 [Michael Schoen]
960
961 * Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Luetke]
962
963 * Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper]
964 Example: Invoice::Lineitem is given table name invoice_lineitems
965
966 * Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper]
967 # people_active_last_name_index, people_active_deactivated_at_index
968 add_index :people, [:active, :last_name]
969 add_index :people, [:active, :deactivated_at]
970 remove_index :people, [:active, :last_name]
971 remove_index :people, [:active, :deactivated_at]
972
973 WARNING: backward-incompatibility. Multicolumn indexes created before this
974 revision were named using the first column name only. Now they're uniquely
975 named using all indexed columns.
976
977 To remove an old multicolumn index, remove_index :table_name, :first_column
978
979 * Fix for deep includes on the same association. [richcollins@gmail.com]
980
981 * Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark]
982
983 * Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson]
984
985 * Document find's :from option. Closes #5762. [andrew@redlinesoftware.com]
986
987 * PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com]
988
989 * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
990
991 * Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael A. Schoen]
992
993 * Add documentation for how to disable timestamps on a per model basis. Closes #5684. [matt@mattmargolis.net Marcel Molina Jr.]
994
995 * Don't save has_one associations unnecessarily. #5735 [Jonathan Viney]
996
997 * Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson]
998
999 * Formally deprecate the deprecated finders. [Koz]
1000
1001 * Formally deprecate rich associations. [Koz]
1002
1003 * Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com]
1004
1005 * Fix announcement of very long migration names. #5722 [blake@near-time.com]
1006
1007 * The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com]
1008
1009 * Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com]
1010
1011 * Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples:
1012
1013 assert (Topic.exists?(:author_name => "David"))
1014 assert (Topic.exists?(:author_name => "Mary", :approved => true))
1015 assert (Topic.exists?(["parent_id = ?", 1]))
1016
1017 * Schema dumper quotes date :default values. [Dave Thomas]
1018
1019 * Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson]
1020
1021 * Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper]
1022
1023 * Patch sql injection vulnerability when using integer or float columns. [Jamis Buck]
1024
1025 * Allow #count through a has_many association to accept :include. [Dan Peterson]
1026
1027 * create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw]
1028
1029 * PostgreSQL: return array fields as strings. #4664 [Robby Russell]
1030
1031 * SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward]
1032
1033 * SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers]
1034
1035 * Oracle: BigDecimal support. #5667 [schoenm@earthlink.net]
1036
1037 * Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk]
1038
1039 * Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>]
1040
1041 * PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com]
1042
1043 * Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>]
1044
1045 * PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net]
1046
1047 * PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com]
1048
1049 * Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net]
1050
1051 * Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [schoenm@earthlink.net]
1052
1053 * Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [schoenm@earthlink.net]
1054
1055 * Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org]
1056
1057 * Minor tweak to improve performance of ActiveRecord::Base#to_param.
1058
1059 * Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au]
1060
1061 * Removed deprecated timestamps_gmt class methods. [Jeremy Kemper]
1062
1063 * rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com]
1064
1065 * PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com]
1066
1067 * Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum.
1068
1069 * Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson]
1070
1071 * Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda]
1072 # Obtain an exclusive lock on person 1 so we can safely increment visits.
1073 Person.transaction do
1074 # select * from people where id=1 for update
1075 person = Person.find(1, :lock => true)
1076 person.visits += 1
1077 person.save!
1078 end
1079
1080 * PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper]
1081
1082 * Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper]
1083
1084 * Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar]
1085
1086 * Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de)
1087
1088 * Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [DHH]
1089
1090 * Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [hcatlin@gmail.com]. Example:
1091
1092 Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2)
1093
1094 ...is the same as:
1095
1096 Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2)
1097
1098 This makes it easier to pass in the options from a form or otherwise outside.
1099
1100
1101 * Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com]
1102
1103 * Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net]
1104
1105 * Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com]
1106
1107 * Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com]
1108
1109 * Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp]
1110
1111 * Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net]
1112
1113 * Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>]
1114
1115 * PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp]
1116
1117 * Records and arrays of records are bound as quoted ids. [Jeremy Kemper]
1118 Foo.find(:all, :conditions => ['bar_id IN (?)', bars])
1119 Foo.find(:first, :conditions => ['bar_id = ?', bar])
1120
1121 * Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [DHH]
1122
1123 * Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick]
1124
1125 * Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [josh@hasmanythrough.com]
1126
1127 * Provide Association Extensions access to the instance that the association is being accessed from.
1128 Closes #4433 [josh@hasmanythrough.com]
1129
1130 * Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell]
1131
1132 * Add a quick note about :select and eagerly included associations. [Rick]
1133
1134 * Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com]
1135
1136 * Fixed that has_many collections shouldn't load the entire association to do build or create [DHH]
1137
1138 * Added :allow_nil option for aggregations #5091 [ian.w.white@gmail.com]
1139
1140 * Fix Oracle boolean support and tests. Closes #5139. [schoenm@earthlink.net]
1141
1142 * create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper]
1143
1144 * Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com]
1145
1146 * Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk]
1147
1148 * PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org]
1149
1150 * Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com]
1151
1152 * Allow :uniq => true with has_many :through associations. [Jeremy Kemper]
1153
1154 * Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.]
1155
1156 * Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com]
1157
1158 * Replace superfluous name_to_class_name variant with camelize. [Marcel Molina Jr.]
1159
1160 * Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
1161
1162 * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
1163
1164 * Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>]
1165
1166 * Update FrontBase adapter to check binding version. Closes #4920. [mlaster@metavillage.com]
1167
1168 * New Frontbase connections don't start in auto-commit mode. Closes #4922. [mlaster@metavillage.com]
1169
1170 * When grouping, use the appropriate option key. [Marcel Molina Jr.]
1171
1172 * Only modify the sequence name in the FrontBase adapter if the FrontBase adapter is actually being used. [Marcel Molina Jr.]
1173
1174 * Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com]
1175
1176 * Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>]
1177
1178 * Fix syntax error in documentation. Closes #4679. [mislav@nippur.irb.hr]
1179
1180 * Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu]
1181
1182 * Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com]
1183
1184 * Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net]
1185
1186 * Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>]
1187
1188 * Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com]
1189
1190 * Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net]
1191
1192 * Fix bug where calculations with long alias names return null. [Rick]
1193
1194 * Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick]
1195
1196 @post.tags << @tag # BAD
1197 @post.taggings.create(:tag => @tag) # GOOD
1198
1199 * Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick]
1200
1201 * Update inconsistent migrations documentation. #4683 [machomagna@gmail.com]
1202
1203 * Add ActiveRecord::Errors#to_xml [Jamis Buck]
1204
1205 * Properly quote index names in migrations (closes #4764) [John Long]
1206
1207 * Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick]
1208
1209 * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
1210
1211 * Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick]
1212
1213 * DRY up association collection reader method generation. [Marcel Molina Jr.]
1214
1215 * DRY up and tweak style of the validation error object. [Marcel Molina Jr.]
1216
1217 * Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick]
1218
1219 class Account < ActiveRecord::Base
1220 validates_uniqueness_of :email, :case_sensitive => false
1221 end
1222
1223 * Allow multiple association extensions with :extend option (closes #4666) [Josh Susser]
1224
1225 class Account < ActiveRecord::Base
1226 has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
1227 end
1228
1229 *1.15.3* (March 12th, 2007)
1230
1231 * Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool]
1232
1233 * Consistently quote primary key column names. #7763 [toolmantim]
1234
1235 * Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley]
1236
1237 * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins]
1238
1239
1240 *1.15.2* (February 5th, 2007)
1241
1242 * Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [dcmanges]
1243 Student.find(:all, :conditions => { :grade => 9..12 })
1244
1245 * Don't create instance writer methods for class attributes. [Rick]
1246
1247 * When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck]
1248
1249 * SQLServer: don't choke on strings containing 'null'. #7083 [Jakob S]
1250
1251 * Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si]
1252
1253 * MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc]
1254
1255 * Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
1256
1257 * SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
1258
1259
1260 *1.15.1* (January 17th, 2007)
1261
1262 * Fix nodoc breaking of adapters
1263
1264
1265 *1.15.0* (January 16th, 2007)
1266
1267 * [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [jeremymcanally]
1268
1269 * change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [dcmanges, Jeremy Kemper]
1270
1271 * MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, manfred, altano@bigfoot.com]
1272
1273 * Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen]
1274
1275 * MySQL: retain SSL settings on reconnect. #6976 [randyv2]
1276
1277 * SQLServer: handle [quoted] table names. #6635 [rrich]
1278
1279 * acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser]
1280
1281 * PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen]
1282
1283 * Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler]
1284
1285 * [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell]
1286
1287 * [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot]
1288
1289 * Bring the sybase adapter up to scratch for 1.2 release. [jsheets]
1290
1291 * Oracle: fix connection reset failure. #6846 [leonlleslie]
1292
1293 * Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper]
1294
1295 * fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool]
1296
1297 * find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper]
1298
1299 * Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper]
1300 find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil }
1301
1302 * Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov]
1303
1304 * MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper]
1305
1306 * validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz]
1307
1308 * Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen]
1309
1310 * Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen]
1311
1312 * Firebird: decimal/numeric support. #6408 [macrnic]
1313
1314 * Find with :include respects scoped :order. #5850
1315
1316 * Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes]
1317
1318 * Deprecation: object transactions warning. [Jeremy Kemper]
1319
1320 * has_one :dependent => :nullify ignores nil associates. #6528 [janovetz, Jeremy Kemper]
1321
1322 * Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen]
1323
1324 * Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie]
1325
1326 * Document other options available to migration's add_column. #6419 [grg]
1327
1328 * MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper]
1329
1330 * Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney]
1331
1332 * fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick]
1333
1334 * Restore eager condition interpolation, document it's differences [Rick]
1335
1336 * Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper]
1337
1338 * Add #delete support to has_many :through associations. Closes #6049 [Martin Landers]
1339
1340 * Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick]
1341
1342 * Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com]
1343
1344 * Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com]
1345
1346 * Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan]
1347
1348 * Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [BobSilva]
1349
1350 * The has_many create method works with polymorphic associations. #6361 [Dan Peterson]
1351
1352 * MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes]
1353
1354 * save! shouldn't validate twice. #6324 [maiha, Bob Silva]
1355
1356 * Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig]
1357
1358 * Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson]
1359
1360 * Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva]
1361
1362 * has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper]
1363
1364 * Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Koz]
1365
1366 * Add a :namespace option to AR::Base#to_xml [Koz]
1367
1368 * Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper]
1369
1370 * Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson]
1371
1372 * Improve yaml fixtures error reporting. #6205 [Bruce Williams]
1373
1374 * Rename AR::Base#quote so people can use that name in their models. #3628 [Koz]
1375
1376 * Add deprecation warning for inferred foreign key. #6029 [Josh Susser]
1377
1378 * Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com]
1379
1380 * Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser]
1381
1382 * Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward]
1383
1384 * to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher]
1385
1386 * has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com]
1387
1388 * Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck]
1389
1390 * has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney]
1391
1392 * Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney]
1393
1394 * SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi]
1395
1396 * Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark]
1397
1398 * Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com]
1399
1400 * Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com]
1401
1402 * MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward]
1403
1404 * to_xml: correct naming of included associations. #5831 [josh.starcher@gmail.com]
1405
1406 * Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [josh@hasmanythrough.com]
1407
1408 * Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper]
1409
1410 # Create a tagging to associate the post and tag.
1411 post.tags << Tag.find_by_name('old')
1412 post.tags.create! :name => 'general'
1413
1414 # Would have been:
1415 post.taggings.create!(:tag => Tag.find_by_name('finally')
1416 transaction do
1417 post.taggings.create!(:tag => Tag.create!(:name => 'general'))
1418 end
1419
1420 * Cache nil results for :included has_one associations also. #5787 [Michael Schoen]
1421
1422 * Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Luetke]
1423
1424 * Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper]
1425 Example: Invoice::Lineitem is given table name invoice_lineitems
1426
1427 * Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper]
1428 # people_active_last_name_index, people_active_deactivated_at_index
1429 add_index :people, [:active, :last_name]
1430 add_index :people, [:active, :deactivated_at]
1431 remove_index :people, [:active, :last_name]
1432 remove_index :people, [:active, :deactivated_at]
1433
1434 WARNING: backward-incompatibility. Multicolumn indexes created before this
1435 revision were named using the first column name only. Now they're uniquely
1436 named using all indexed columns.
1437
1438 To remove an old multicolumn index, remove_index :table_name, :first_column
1439
1440 * Fix for deep includes on the same association. [richcollins@gmail.com]
1441
1442 * Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark]
1443
1444 * Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson]
1445
1446 * PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com]
1447
1448 * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
1449
1450 * Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael A. Schoen]
1451
1452 * Don't save has_one associations unnecessarily. #5735 [Jonathan Viney]
1453
1454 * Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson]
1455
1456 * Formally deprecate the deprecated finders. [Koz]
1457
1458 * Formally deprecate rich associations. [Koz]
1459
1460 * Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com]
1461
1462 * Fix announcement of very long migration names. #5722 [blake@near-time.com]
1463
1464 * The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com]
1465
1466 * Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com]
1467
1468 * Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples:
1469
1470 assert (Topic.exists?(:author_name => "David"))
1471 assert (Topic.exists?(:author_name => "Mary", :approved => true))
1472 assert (Topic.exists?(["parent_id = ?", 1]))
1473
1474 * Schema dumper quotes date :default values. [Dave Thomas]
1475
1476 * Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson]
1477
1478 * Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper]
1479
1480 * Patch sql injection vulnerability when using integer or float columns. [Jamis Buck]
1481
1482 * Allow #count through a has_many association to accept :include. [Dan Peterson]
1483
1484 * create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw]
1485
1486 * PostgreSQL: return array fields as strings. #4664 [Robby Russell]
1487
1488 * SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward]
1489
1490 * SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers]
1491
1492 * Oracle: BigDecimal support. #5667 [schoenm@earthlink.net]
1493
1494 * Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk]
1495
1496 * Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>]
1497
1498 * PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com]
1499
1500 * PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net]
1501
1502 * PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com]
1503
1504 * Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net]
1505
1506 * Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [schoenm@earthlink.net]
1507
1508 * Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [schoenm@earthlink.net]
1509
1510 * Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org]
1511
1512 * Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au]
1513
1514 * Removed deprecated timestamps_gmt class methods. [Jeremy Kemper]
1515
1516 * rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com]
1517
1518 * PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com]
1519
1520 * Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum.
1521
1522 * Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson]
1523
1524 * Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda]
1525 # Obtain an exclusive lock on person 1 so we can safely increment visits.
1526 Person.transaction do
1527 # select * from people where id=1 for update
1528 person = Person.find(1, :lock => true)
1529 person.visits += 1
1530 person.save!
1531 end
1532
1533 * PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper]
1534
1535 * Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper]
1536
1537 * Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar]
1538
1539 * Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de)
1540
1541 * Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [DHH]
1542
1543 * Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [hcatlin@gmail.com]. Example:
1544
1545 Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2)
1546
1547 ...is the same as:
1548
1549 Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2)
1550
1551 This makes it easier to pass in the options from a form or otherwise outside.
1552
1553
1554 * Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com]
1555
1556 * Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net]
1557
1558 * Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com]
1559
1560 * Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com]
1561
1562 * Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp]
1563
1564 * Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net]
1565
1566 * Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>]
1567
1568 * PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp]
1569
1570 * Records and arrays of records are bound as quoted ids. [Jeremy Kemper]
1571 Foo.find(:all, :conditions => ['bar_id IN (?)', bars])
1572 Foo.find(:first, :conditions => ['bar_id = ?', bar])
1573
1574 * Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [DHH]
1575
1576 * Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick]
1577
1578 * Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [josh@hasmanythrough.com]
1579
1580 * Provide Association Extensions access to the instance that the association is being accessed from.
1581 Closes #4433 [josh@hasmanythrough.com]
1582
1583 * Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell]
1584
1585 * Add a quick note about :select and eagerly included associations. [Rick]
1586
1587 * Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com]
1588
1589 * Fixed that has_many collections shouldn't load the entire association to do build or create [DHH]
1590
1591 * Added :allow_nil option for aggregations #5091 [ian.w.white@gmail.com]
1592
1593 * Fix Oracle boolean support and tests. Closes #5139. [schoenm@earthlink.net]
1594
1595 * create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper]
1596
1597 * Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com]
1598
1599 * Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk]
1600
1601 * PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org]
1602
1603 * Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com]
1604
1605 * Allow :uniq => true with has_many :through associations. [Jeremy Kemper]
1606
1607 * Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.]
1608
1609 * Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com]
1610
1611 * Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>]
1612
1613 * When grouping, use the appropriate option key. [Marcel Molina Jr.]
1614
1615 * Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com]
1616
1617 * Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>]
1618
1619 * Fix syntax error in documentation. Closes #4679. [mislav@nippur.irb.hr]
1620
1621 * Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu]
1622
1623 * Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com]
1624
1625 * Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net]
1626
1627 * Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>]
1628
1629 * Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com]
1630
1631 * Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net]
1632
1633 * Fix bug where calculations with long alias names return null. [Rick]
1634
1635 * Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick]
1636
1637 @post.tags << @tag # BAD
1638 @post.taggings.create(:tag => @tag) # GOOD
1639
1640 * Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick]
1641
1642 * Add ActiveRecord::Errors#to_xml [Jamis Buck]
1643
1644 * Properly quote index names in migrations (closes #4764) [John Long]
1645
1646 * Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick]
1647
1648 * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
1649
1650 * Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick]
1651
1652 * Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick]
1653
1654 class Account < ActiveRecord::Base
1655 validates_uniqueness_of :email, :case_sensitive => false
1656 end
1657
1658 * Allow multiple association extensions with :extend option (closes #4666) [Josh Susser]
1659
1660 class Account < ActiveRecord::Base
1661 has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
1662 end
1663
1664
1665 *1.14.4* (August 8th, 2006)
1666
1667 * Add warning about the proper way to validate the presence of a foreign key. #4147 [Francois Beausoleil <francois.beausoleil@gmail.com>]
1668
1669 * Fix syntax error in documentation. #4679 [mislav@nippur.irb.hr]
1670
1671 * Update inconsistent migrations documentation. #4683 [machomagna@gmail.com]
1672
1673
1674 *1.14.3* (June 27th, 2006)
1675
1676 * Fix announcement of very long migration names. #5722 [blake@near-time.com]
1677
1678 * Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>]
1679
1680 * Properly quote index names in migrations (closes #4764) [John Long]
1681
1682 * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
1683
1684 * Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick]
1685
1686
1687 *1.14.2* (April 9th, 2006)
1688
1689 * Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen]
1690
1691
1692 *1.14.1* (April 6th, 2006)
1693
1694 * Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar]
1695
1696 * Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
1697
1698 * Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
1699
1700 * Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick]
1701
1702 * Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr]
1703
1704 * Allow AR::Base#respond_to? to behave when @attributes is nil [zenspider]
1705
1706 * Support eager includes when going through a polymorphic has_many association. [Rick]
1707
1708 * Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick]
1709
1710 class Post < ActiveRecord::Base
1711 has_one :tagging, :as => :taggable
1712 end
1713
1714 Post.find :all, :include => :tagging
1715
1716 * Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick]
1717
1718 * Added support for going through a polymorphic has_many association: (closes #4401) [Rick]
1719
1720 class PhotoCollection < ActiveRecord::Base
1721 has_many :photos, :as => :photographic
1722 belongs_to :firm
1723 end
1724
1725 class Firm < ActiveRecord::Base
1726 has_many :photo_collections
1727 has_many :photos, :through => :photo_collections
1728 end
1729
1730 * Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com]
1731
1732 * Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber]
1733
1734 * Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan]
1735
1736 * Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick]
1737
1738 * DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH]
1739
1740 * Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [DHH]
1741
1742 * Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.]
1743
1744 * Fixed broken OCIAdapter #4457 [schoenm@earthlink.net]
1745
1746
1747 *1.14.0* (March 27th, 2006)
1748
1749 * Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar]
1750
1751 * Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
1752
1753 * Add support for :include to with_scope [andrew@redlinesoftware.com]
1754
1755 * Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [schoenm@earthlink.net]
1756
1757 * Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com]
1758
1759 * Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick]
1760
1761 * Fixed issue that kept :select options from being scoped [Rick]
1762
1763 * Fixed db_schema_import when binary types are present #3101 [DHH]
1764
1765 * Fixed that MySQL enums should always be returned as strings #3501 [DHH]
1766
1767 * Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson]
1768
1769 class Connection < ActiveRecord::Base
1770 belongs_to :user
1771 belongs_to :channel
1772 end
1773
1774 class Channel < ActiveRecord::Base
1775 has_many :connections
1776 has_many :contacts, :through => :connections, :class_name => 'User' # OLD
1777 has_many :contacts, :through => :connections, :source => :user # NEW
1778 end
1779
1780 * Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de]
1781
1782 * Allow overriding of find parameters in scoped has_many :through calls [Rick Olson]
1783
1784 In this example, :include => false disables the default eager association from loading. :select changes the standard
1785 select clause. :joins specifies a join that is added to the end of the has_many :through query.
1786
1787 class Post < ActiveRecord::Base
1788 has_many :tags, :through => :taggings, :include => :tagging do
1789 def add_joins_and_select
1790 find :all, :select => 'tags.*, authors.id as author_id', :include => false,
1791 :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id'
1792 end
1793 end
1794 end
1795
1796 * Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [DHH]
1797
1798 * Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [jonathan@bluewire.net.nz]
1799
1800 * Quit ignoring default :include options in has_many :through calls [Mark James]
1801
1802 * Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [jonathan@bluewire.net.nz]
1803
1804 * Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson]
1805
1806 * Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example:
1807
1808 class Firm < ActiveRecord::Base
1809 has_many :clients
1810 has_many :invoices, :through => :clients
1811 end
1812
1813 class Client < ActiveRecord::Base
1814 belongs_to :firm
1815 has_many :invoices
1816 end
1817
1818 class Invoice < ActiveRecord::Base
1819 belongs_to :client
1820 end
1821
1822 * Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [josh@hasmanythrough.com]
1823
1824 * Fixed has_many :through to include :conditions set on the :through association. closes #4020 [jonathan@bluewire.net.nz]
1825
1826 * Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick]
1827
1828 * SQL Server adapter gets some love #4298 [rtomayko@gmail.com]
1829
1830 * Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com]
1831
1832 * Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI):
1833
1834 Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body')
1835
1836 * Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick]
1837
1838 * Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Koz]
1839
1840 * Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Koz]
1841
1842 * Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom ward]
1843
1844 * Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com]
1845
1846 * Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck]
1847
1848 * Use association's :conditions when eager loading. [jeremyevans0@gmail.com] #4144
1849
1850 * Alias the has_and_belongs_to_many join table on eager includes. #4106 [jeremyevans0@gmail.com]
1851
1852 This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous.
1853
1854 Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL')
1855
1856 * Oracle adapter gets some love #4230 [schoenm@earthlink.net]
1857
1858 * Changes :text to CLOB rather than BLOB [Moses Hohman]
1859 * Fixes an issue with nil numeric length/scales (several)
1860 * Implements support for XMLTYPE columns [wilig / Kubo Takehiro]
1861 * Tweaks a unit test to get it all green again
1862 * Adds support for #current_database
1863
1864 * Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson]
1865
1866 class CachedModel < ActiveRecord::Base
1867 self.abstract_class = true
1868 end
1869
1870 class Post < CachedModel
1871 end
1872
1873 CachedModel.abstract_class?
1874 => true
1875
1876 Post.abstract_class?
1877 => false
1878
1879 Post.base_class
1880 => Post
1881
1882 Post.table_name
1883 => 'posts'
1884
1885 * Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson]
1886
1887 class Foo < ActiveRecord::Base
1888 has_many :attachments, :as => :attachable, :dependent => :delete_all
1889 end
1890
1891 * Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay@gmail.com]
1892
1893 * Upgrade to Transaction::Simple 1.3 [Jamis Buck]
1894
1895 * Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson]
1896
1897 * Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com]
1898
1899 * Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com]
1900
1901 * Dynamically set allow_concurrency. #4044 [Stefan Kaes]
1902
1903 * Added Base#to_xml that'll turn the current record into a XML representation [DHH]. Example:
1904
1905 topic.to_xml
1906
1907 ...returns:
1908
1909 <?xml version="1.0" encoding="UTF-8"?>
1910 <topic>
1911 <title>The First Topic</title>
1912 <author-name>David</author-name>
1913 <id type="integer">1</id>
1914 <approved type="boolean">false</approved>
1915 <replies-count type="integer">0</replies-count>
1916 <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time>
1917 <written-on type="datetime">2003-07-16 09:28:00</written-on>
1918 <content>Have a nice day</content>
1919 <author-email-address>david@loudthinking.com</author-email-address>
1920 <parent-id></parent-id>
1921 <last-read type="date">2004-04-15</last-read>
1922 </topic>
1923
1924 ...and you can configure with:
1925
1926 topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ])
1927
1928 ...that'll return:
1929
1930 <topic>
1931 <title>The First Topic</title>
1932 <author-name>David</author-name>
1933 <approved type="boolean">false</approved>
1934 <content>Have a nice day</content>
1935 <author-email-address>david@loudthinking.com</author-email-address>
1936 <parent-id></parent-id>
1937 <last-read type="date">2004-04-15</last-read>
1938 </topic>
1939
1940 You can even do load first-level associations as part of the document:
1941
1942 firm.to_xml :include => [ :account, :clients ]
1943
1944 ...that'll return something like:
1945
1946 <?xml version="1.0" encoding="UTF-8"?>
1947 <firm>
1948 <id type="integer">1</id>
1949 <rating type="integer">1</rating>
1950 <name>37signals</name>
1951 <clients>
1952 <client>
1953 <rating type="integer">1</rating>
1954 <name>Summit</name>
1955 </client>
1956 <client>
1957 <rating type="integer">1</rating>
1958 <name>Microsoft</name>
1959 </client>
1960 </clients>
1961 <account>
1962 <id type="integer">1</id>
1963 <credit-limit type="integer">50</credit-limit>
1964 </account>
1965 </firm>
1966
1967 * Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck]
1968
1969 * Documentation fixes for :dependent [robby@planetargon.com]
1970
1971 * Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney]
1972
1973 * Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org]
1974
1975 * Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson]
1976
1977 * Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>]
1978
1979 * Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson]
1980
1981 * The first time a table is referenced in a join, no alias is used.
1982 * After that, the parent class name and the reflection name are used.
1983
1984 Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ...
1985
1986 * Any additional join references get a numerical suffix like '_2', '_3', etc.
1987
1988 * Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to.
1989
1990 * Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples:
1991
1992 # cascaded in two levels
1993 >> Author.find(:all, :include=>{:posts=>:comments})
1994 => authors
1995 +- posts
1996 +- comments
1997
1998 # cascaded in two levels and normal association
1999 >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations])
2000 => authors
2001 +- posts
2002 +- comments
2003 +- categorizations
2004
2005 # cascaded in two levels with two has_many associations
2006 >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]})
2007 => authors
2008 +- posts
2009 +- comments
2010 +- categorizations
2011
2012 # cascaded in three levels
2013 >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}})
2014 => companies
2015 +- groups
2016 +- members
2017 +- favorites
2018
2019 * Make counter cache work when replacing an association #3245 [eugenol@gmail.com]
2020
2021 * Make migrations verbose [Jamis Buck]
2022
2023 * Make counter_cache work with polymorphic belongs_to [Jamis Buck]
2024
2025 * Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp]
2026
2027 * Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats:
2028
2029 * Does not support DATE SQL column types; use DATETIME instead.
2030 * Date columns on HABTM join tables are returned as String, not Time.
2031 * Insertions are potentially broken for :polymorphic join tables
2032 * BLOB column access not yet fully supported
2033
2034 * Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper]
2035
2036 * CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper]
2037
2038 * Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [schoenm@earthlink.net]
2039
2040 * Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [DHH]
2041
2042 * Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes]
2043
2044 * Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark]
2045
2046 * Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net]
2047
2048 * Define attribute query methods to avoid method_missing calls. #3677 [jonathan@bluewire.net.nz]
2049
2050 * ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward]
2051
2052 * Added support for nested scopes #3407 [anna@wota.jp]. Examples:
2053
2054 Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do
2055 Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10
2056
2057 # inner rule is used. (all previous parameters are ignored)
2058 Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do
2059 Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis')
2060 end
2061
2062 # parameters are merged
2063 Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do
2064 Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10
2065 end
2066 end
2067
2068 * Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com]
2069
2070 * Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh]
2071
2072 * Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [lars@pind.com]
2073
2074 * Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples:
2075
2076 Person.average :age
2077 Person.minimum :age
2078 Person.maximum :age
2079 Person.sum :salary, :group => :last_name
2080
2081 * Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [contact@lukeredpath.co.uk]
2082
2083 * Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper]
2084
2085 * Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net]
2086
2087 * Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de]
2088
2089 * Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [skaes]
2090
2091 * Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva]
2092
2093 * Allow :include to be used with has_many :through associations #3611 [Michael Schoen]
2094
2095 * PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac]
2096
2097 * SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward]
2098
2099 * Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson]
2100
2101 * PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org]
2102
2103 * Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark]
2104
2105 * ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Luetke]
2106
2107 * Using AssociationCollection#build with arrays of hashes should call build, not create [DHH]
2108
2109 * Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar]
2110
2111 * Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt]
2112
2113 * Support the :column option for remove_index with the PostgreSQL adapter. #3661 [shugo@ruby-lang.org]
2114
2115 * Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>]
2116
2117 * If the OCI library is not available, raise an exception indicating as much. #3593 [schoenm@earthlink.net]
2118
2119 * Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson]
2120
2121 * Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.]
2122
2123 * Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar]
2124
2125 * Make .count work for has_many associations with multi line finder sql [schoenm@earthlink.net]
2126
2127 * Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck]
2128
2129 * Allow configuration of the column used for optimistic locking [wilsonb@gmail.com]
2130
2131 * Don't hardcode 'id' in acts as list. [ror@philippeapril.com]
2132
2133 * Fix date errors for SQLServer in association tests. #3406 [kevin.clark@gmal.com]
2134
2135 * Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp]
2136
2137 * Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com]
2138
2139 * .with_scope imposed create parameters now bypass attr_protected [Tobias Luetke]
2140
2141 * Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.]
2142
2143 * Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de]
2144
2145 * Sanitize scoped conditions. [Marcel Molina Jr.]
2146
2147 * Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [DHH]
2148
2149 * Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [TobiasLuetke]
2150
2151 * SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [TobiasLuetke]
2152
2153 * Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber]
2154
2155 * Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron]
2156
2157 * removed :piggyback in favor of just allowing :select on :through associations. [Tobias Luetke]
2158
2159 * made method missing delegation to class methods on relation target work on :through associations. [Tobias Luetke]
2160
2161 * made .find() work on :through relations. [Tobias Luetke]
2162
2163 * Fix typo in association docs. #3296. [Blair Zajac]
2164
2165 * Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Luetke]
2166
2167 *1.13.2* (December 13th, 2005)
2168
2169 * Become part of Rails 1.0
2170
2171 * MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper]
2172
2173 * Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [DHH]. Example:
2174
2175 class Post
2176 has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author
2177 end
2178
2179 post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors
2180 post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors
2181 post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors
2182
2183 * Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [DHH]
2184
2185 * MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder]
2186
2187 * SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com]
2188
2189 * SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org]
2190
2191 * SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com]
2192
2193 * SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko]
2194
2195 * SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com]
2196
2197 * Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen]
2198
2199 * MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes]
2200
2201 * Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausoleil]
2202
2203 * Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond]
2204
2205 * PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson]
2206
2207 * Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen]
2208
2209 * MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper]
2210
2211 * Added preliminary support for polymorphic associations [DHH]
2212
2213 * Added preliminary support for join models [DHH]
2214
2215 * Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.]
2216
2217 * Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>]
2218
2219 * Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>]
2220
2221 * MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper]
2222
2223 * Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen]
2224
2225 * SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com]
2226
2227 * Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper]
2228
2229 * Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen]
2230
2231 * MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda]
2232
2233 * has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper]
2234
2235 * MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda]
2236
2237 * Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.]
2238
2239 * Correct boolean handling in generated reader methods. #2945 [don.park@gmail.com, Stefan Kaes]
2240
2241 * Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes]
2242
2243 * Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>]
2244
2245 * Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans]
2246
2247 * Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
2248
2249 * Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>]
2250
2251 * SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
2252
2253 * Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com]
2254
2255 * SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
2256
2257 * Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>]
2258
2259 * Correct documentation for Base.delete_all. #1568 [Newhydra]
2260
2261 * Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>]
2262
2263 * Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>]
2264
2265 * When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper]
2266
2267 * Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>]
2268
2269 * Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper]
2270
2271 * PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper]
2272
2273 * PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper]
2274
2275 * SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko]
2276
2277 * Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>]
2278
2279 * Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de]
2280
2281 * Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>]
2282
2283 * acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com]
2284
2285 * Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar]
2286
2287 * Fixed acts_as_list for definitions without an explicit :order #2803 [jonathan@bluewire.net.nz]
2288
2289 * Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper]
2290
2291 * Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.]
2292
2293 * Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com]
2294
2295 * Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper]
2296
2297 * Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper]
2298
2299 * More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>]
2300
2301
2302 *1.13.0* (November 7th, 2005)
2303
2304 * Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko]
2305
2306 * Added :include as an option for association declarations [DHH]. Example:
2307
2308 has_many :posts, :include => [ :author, :comments ]
2309
2310 * Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example:
2311
2312 Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do
2313 # Find where name = ? and active=true
2314 Comment.find :all, :conditions => ['name = ?', name]
2315 # Create comment associated with :post_id
2316 Comment.create :body => "Hello world"
2317 end
2318
2319 * Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko]
2320
2321 * Added constrain scoping for creates using a hash of attributes bound to the :creation key [DHH]. Example:
2322
2323 Comment.constrain(:creation => { :post_id => 5 }) do
2324 # Associated with :post_id
2325 Comment.create :body => "Hello world"
2326 end
2327
2328 This is rarely used directly, but allows for find_or_create on associations. So you can do:
2329
2330 # If the tag doesn't exist, a new one is created that's associated with the person
2331 person.tags.find_or_create_by_name("Summer")
2332
2333 * Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [DHH]. Example:
2334
2335 # No 'Summer' tag exists
2336 Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
2337
2338 # Now the 'Summer' tag does exist
2339 Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
2340
2341 * Added extension capabilities to has_many and has_and_belongs_to_many proxies [DHH]. Example:
2342
2343 class Account < ActiveRecord::Base
2344 has_many :people do
2345 def find_or_create_by_name(name)
2346 first_name, *last_name = name.split
2347 last_name = last_name.join " "
2348
2349 find_or_create_by_first_name_and_last_name(first_name, last_name)
2350 end
2351 end
2352 end
2353
2354 person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson")
2355 person.first_name # => "David"
2356 person.last_name # => "Heinemeier Hansson"
2357
2358 Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation).
2359
2360 * Omit internal dtproperties table from SQLServer table list. #2729 [rtomayko@gmail.com]
2361
2362 * Quote column names in generated SQL. #2728 [rtomayko@gmail.com]
2363
2364 * Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper]
2365
2366 * Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper]
2367
2368 * Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>]
2369
2370 * Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson]
2371
2372 * Added migration support for Oracle #2647 [Michael Schoen]
2373
2374 * Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>]
2375
2376 * Fixed SQL Server adapter to pass even more tests and do even better #2634 [rtomayko@gmail.com]
2377
2378 * Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward]
2379
2380 * Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward]
2381
2382 * Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com]
2383
2384 * Constraints are cloned so they can't be inadvertently modified while they're
2385 in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>]
2386
2387 * Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com]
2388
2389 * Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [schoenm@earthlink.net]
2390
2391 * Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt]
2392
2393
2394 *1.12.2* (October 26th, 2005)
2395
2396 * Allow symbols to rename columns when using SQLite adapter. #2531 [kevin.clark@gmail.com]
2397
2398 * Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>]
2399
2400 * Clarify semantics of ActiveRecord::Base#respond_to? #2560 [skaes@web.de]
2401
2402 * Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>]
2403
2404 * HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>]
2405
2406 * Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>]
2407
2408
2409 *1.12.1* (October 19th, 2005)
2410
2411 * Always parenthesize :conditions options so they may be safely combined with STI and constraints.
2412
2413 * Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com]
2414
2415 * Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations
2416
2417
2418 *1.12.0* (October 16th, 2005)
2419
2420 * Update/clean up documentation (rdoc)
2421
2422 * PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>]
2423
2424 * Change default logging colors to work on both white and black backgrounds. [Sam Stephenson]
2425
2426 * YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net]
2427
2428 * :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>]
2429
2430 * Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around.
2431
2432 * Avoid memleak in dev mode when using fcgi
2433
2434 * Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>]
2435
2436 * Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>]
2437
2438 * Fix errors caused by assigning a has-one or belongs-to property to itself
2439
2440 * Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson]
2441
2442 * Update DB2 adapter. #2206. [contact@maik-schmidt.de]
2443
2444 * Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com]
2445
2446 * Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency.
2447
2448 * Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>]
2449
2450 * Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code]
2451
2452 * Add test coverage for content_columns. #2432. [coffee2code]
2453
2454 * Speed up for unthreaded environments. #2431. [skaes@web.de]
2455
2456 * Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [skaes@web.de]
2457
2458 * Speed up the setting of table_name. #2428. [skaes@web.de]
2459
2460 * Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [skaes@web.de]
2461
2462 * Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>]
2463
2464 * Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [skaes@web.de]
2465
2466 * Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>]
2467
2468 * Add geometric type for postgresql adapter. #2233 [akaspick@gmail.com]
2469
2470 * Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [skaes@web.de]
2471
2472 * Add convenience predicate methods on Column class. In partial fullfilment of #1236. [skaes@web.de]
2473
2474 * Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar]
2475
2476 * Added :force option to create_table that'll try to drop the table if it already exists before creating
2477
2478 * Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar]
2479
2480 * Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>]
2481
2482 * model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>]
2483
2484 * Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman]
2485
2486 * Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>]
2487
2488 * Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>]
2489
2490 * Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>]
2491
2492 * Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>]
2493
2494 * Make update_attribute use the same writer method that update_attributes uses.
2495 #2237 [trevor@protocool.com]
2496
2497 * Make migrations honor table name prefixes and suffixes. #2298 [Jakob S, Marcel Molina]
2498
2499 * Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org]
2500
2501 * Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com]
2502
2503 * Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
2504
2505 * Added new symbol-driven approach to activating observers with Base#observers= [DHH]. Example:
2506
2507 ActiveRecord::Base.observers = :cacher, :garbage_collector
2508
2509 * Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com]
2510
2511 * Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck]
2512
2513 * Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck]
2514
2515 * Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck]
2516
2517 * Fixed migrations for Windows when using more than 10 [David Naseby]
2518
2519 * Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
2520
2521 * Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
2522
2523 * Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]
2524
2525 * Fixed that Observers didn't observe sub-classes #627 [Florian Weber]
2526
2527 * Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina]
2528
2529 * Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae]
2530
2531 * Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber]
2532
2533 * Added better exception error when unknown column types are used with migrations #1814 [fbeausoleil@ftml.net]
2534
2535 * Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com]
2536
2537 * Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg]
2538
2539 * Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward]
2540
2541 * Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code]
2542
2543 * Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net]
2544
2545 * Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/
2546
2547 * Make sure the schema_info table is created before querying the current version #1903
2548
2549 * Fixtures ignore table name prefix and suffix #1987 [Jakob S]
2550
2551 * Add documentation for index_type argument to add_index method for migrations #2005 [blaine@odeo.com]
2552
2553 * Modify read_attribute to allow a symbol argument #2024 [Ken Kunz]
2554
2555 * Make destroy return self #1913 [sebastian.kanthak@muehlheim.de]
2556
2557 * Fix typo in validations documentation #1938 [court3nay]
2558
2559 * Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org]
2560
2561 * Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky]
2562
2563 * Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
2564
2565 * Fix create_table so that id column is implicitly added [Rick Olson]
2566
2567 * Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798
2568
2569 * OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798
2570
2571 * Fixed the handling of camelCase columns names in Oracle #1798
2572
2573 * Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798
2574
2575 * Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798
2576
2577 * Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Luetke]
2578
2579 class Comment < AR:B
2580 def self.search(q)
2581 find(:all, :conditions => ["body = ?", q])
2582 end
2583 end
2584
2585 class Post < AR:B
2586 has_many :comments
2587 end
2588
2589 Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi'
2590
2591 NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as
2592 by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on
2593 details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself
2594 noticed :)
2595
2596 * Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson]
2597
2598 * Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar]
2599
2600 * Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions
2601
2602 * Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt]
2603
2604 * Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes]
2605
2606
2607 *1.11.1* (11 July, 2005)
2608
2609 * Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olsen]
2610
2611 * Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com]
2612
2613 * Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson]
2614
2615 * Correct reflected table name for singular associations. #1688 [court3nay@gmail.com]
2616
2617 * Fixed optimistic locking with SQL Server #1660 [tom@popdog.net]
2618
2619 * Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current
2620
2621 * Added better error message for "packets out of order" #1630 [courtenay]
2622
2623 * Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640
2624
2625
2626 *1.11.0* (6 July, 2005)
2627
2628 * Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar]
2629
2630 * Changed logging of SQL statements to use the DEBUG level instead of INFO
2631
2632 * Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Luetke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator.
2633
2634 * Added callback hooks to association collections #1549 [Florian Weber]. Example:
2635
2636 class Project
2637 has_and_belongs_to_many :developers, :before_add => :evaluate_velocity
2638
2639 def evaluate_velocity(developer)
2640 ...
2641 end
2642 end
2643
2644 ..raising an exception will cause the object not to be added (or removed, with before_remove).
2645
2646
2647 * Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry]
2648
2649 * Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato]
2650
2651 * Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber]
2652
2653 * Speed up ActiveRecord#method_missing for the common case (read_attribute).
2654
2655 * Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [skaes@web.de]
2656
2657 * Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath]
2658
2659 * Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
2660
2661 * Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [michael@schuerig.de]
2662
2663 * Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
2664
2665 * Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry]
2666
2667 * Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net]
2668
2669 * Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
2670
2671 * Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be:
2672
2673 Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
2674
2675 ...should instead be:
2676
2677 Developer.find(
2678 :all,
2679 :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
2680 :conditions => 'project_id=1'
2681 )
2682
2683 * Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina]
2684
2685 * Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon]
2686
2687 * Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
2688
2689 * Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid]
2690
2691 * Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice
2692
2693 * Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper]
2694
2695 * Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak].
2696 Example:
2697
2698 david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")]
2699 david.save
2700
2701 If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new
2702 project is saved when david.save is called.
2703
2704 Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do:
2705
2706 david.project_ids = [1, 5, 7]
2707
2708 * Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com]
2709
2710 * Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Luetke]
2711
2712 * Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org]
2713
2714 * Corrected @@configurations typo #1410 [david@ruppconsulting.com]
2715
2716 * Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com]
2717
2718 * Allow before/after update hooks to work on models using optimistic locking
2719
2720 * Eager loading of dependent has_one associations won't delete the association #1212
2721
2722 * Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it.
2723
2724 * Using transactional fixtures now causes the data to be loaded only once.
2725
2726 * Added fixture accessor methods that can be used when instantiated fixtures are disabled.
2727
2728 fixtures :web_sites
2729
2730 def test_something
2731 assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
2732 end
2733
2734 * Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]
2735
2736 * Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
2737
2738 * CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309
2739
2740 * Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead
2741
2742 * Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples:
2743
2744 Conditional validations such as the following are made possible:
2745 validates_numericality_of :income, :if => :employed?
2746
2747 Conditional validations can also solve the salted login generator problem:
2748 validates_confirmation_of :password, :if => :new_password?
2749
2750 Using blocks:
2751 validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 }
2752
2753 * Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
2754
2755 * Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
2756
2757 * Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper]
2758
2759 * Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed.
2760
2761 * Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first.
2762
2763 * Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example:
2764
2765 # SELECT * FROM topics WHERE title IN ('First', 'Second')
2766 Topic.find_all_by_title(["First", "Second"])
2767
2768 * Added compatibility with camelCase column names for dynamic finders #533 [Dee.Zsombor]
2769
2770 * Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
2771
2772 * Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid]
2773
2774 * Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com]
2775
2776 * Added encoding and min_messages options for PostgreSQL #1205 [shugo]. Configuration example:
2777
2778 development:
2779 adapter: postgresql
2780 database: rails_development
2781 host: localhost
2782 username: postgres
2783 password:
2784 encoding: UTF8
2785 min_messages: ERROR
2786
2787 * Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck]
2788
2789 * Added validates_exclusion_of as a negative of validates_inclusion_of
2790
2791 * Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls
2792
2793
2794 *1.10.1* (20th April, 2005)
2795
2796 * Fixed frivilous database queries being triggered with eager loading on empty associations and other things
2797
2798 * Fixed order of loading in eager associations
2799
2800 * Fixed stray comma when using eager loading and ordering together from has_many associations #1143
2801
2802
2803 *1.10.0* (19th April, 2005)
2804
2805 * Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example:
2806
2807 for post in Post.find(:all, :limit => 100)
2808 puts "Post: " + post.title
2809 puts "Written by: " + post.author.name
2810 puts "Last comment on: " + post.comments.first.created_on
2811 end
2812
2813 This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as:
2814
2815 for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ])
2816
2817 ...and the number of database queries needed is now 1.
2818
2819 * Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples:
2820
2821 Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
2822 Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC")
2823 Person.find(:first, :order => "created_on DESC", :offset => 5)
2824 Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
2825 Person.find(:all, :offset => 10, :limit => 10)
2826
2827 * Added acts_as_nested_set #1000 [wschenk]. Introduction:
2828
2829 This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with
2830 the added feature that you can select the children and all of it's descendants with
2831 a single query. A good use case for this is a threaded post system, where you want
2832 to display every reply to a comment without multiple selects.
2833
2834 * Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [After much pestering from Dave Thomas]
2835
2836 * Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com]
2837
2838 * Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com]
2839
2840 * Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com]
2841
2842 * Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher]
2843
2844 * Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle]
2845
2846 * Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com]
2847
2848 * Added insert_at(position) to acts_as_list #1083 [DeLynnB]
2849
2850 * Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order)
2851
2852 * Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com]
2853
2854 * Fixed boolean saving on Oracle #1093 [mparrish@pearware.org]
2855
2856 * Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864
2857
2858 * Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]
2859
2860 * Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
2861
2862 * Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
2863
2864 * Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
2865
2866 * Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org]
2867
2868 * Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper]
2869
2870 * Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]
2871
2872 * Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]
2873
2874 * Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
2875
2876 * Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas]
2877
2878 * Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias)
2879
2880
2881 *1.9.1* (27th March, 2005)
2882
2883 * Fixed that Active Record objects with float attribute could not be cloned #808
2884
2885 * Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar]
2886
2887 * Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count
2888
2889 * Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron]
2890
2891 * Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb]
2892
2893
2894 *1.9.0* (22th March, 2005)
2895
2896 * Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example:
2897
2898 Developer.find_all nil, 'id ASC', 5 # return the first five developers
2899 Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward
2900
2901 This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged.
2902
2903 * Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson]
2904
2905 * Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins]
2906
2907 * Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org]
2908
2909 * Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel]
2910
2911 * Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid]
2912
2913 * Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com]
2914
2915 * Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net]
2916
2917 * Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak]
2918
2919 * Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak]
2920
2921 * Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm]
2922
2923 * Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
2924
2925 * Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body)
2926
2927
2928 *1.8.0* (7th March, 2005)
2929
2930 * Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default)
2931
2932 * Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron]
2933
2934 * Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation:
2935
2936 * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
2937 +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
2938 objects that should be inspected to determine which attributes triggered the errors.
2939 * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
2940 You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
2941
2942 * Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k]
2943
2944 * Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper]
2945
2946 * Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example:
2947
2948 class Account < ActiveRecord::Base
2949 has_one :credit_card, :dependent => true
2950 end
2951 class CreditCard < ActiveRecord::Base
2952 belongs_to :account
2953 end
2954
2955 account.credit_card # => returns existing credit card, lets say id = 12
2956 account.credit_card = CreditCard.create("number" => "123")
2957 account.save # => CC with id = 12 is destroyed
2958
2959
2960 * Added validates_numericality_of #716 [skanthak/c.r.mcgrath]. Docuemntation:
2961
2962 Validates whether the value of the specified attribute is numeric by trying to convert it to
2963 a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression
2964 <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true).
2965
2966 class Person < ActiveRecord::Base
2967 validates_numericality_of :value, :on => :create
2968 end
2969
2970 Configuration options:
2971 * <tt>message</tt> - A custom error message (default is: "is not a number")
2972 * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
2973 * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false)
2974
2975
2976 * Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron]
2977
2978 * Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed)
2979
2980 * Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com]
2981
2982
2983 *1.7.0* (24th February, 2005)
2984
2985 * Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck]
2986
2987 * Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes:
2988
2989 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple
2990 and safe way of passing table-specific sequence information to the adapter.)
2991 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to
2992 resort to some hacks to get data converted to Date or Time in Ruby.
2993 If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the
2994 hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time.
2995 This is nasty - but if you use Duck Typing you'll probably not care very much.
2996 In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is
2997 valid - too many databases use DATE for both.
2998 Timezones and sub-second precision on timestamps are not supported.
2999 3. Default values that are functions (such as "SYSDATE") are not supported. This is a
3000 restriction of the way active record supports default values.
3001 4. Referential integrity constraints are not fully supported. Under at least
3002 some circumstances, active record appears to delete parent and child records out of
3003 sequence and out of transaction scope. (Or this may just be a problem of test setup.)
3004
3005 The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/
3006
3007 * Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke]
3008
3009 * Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm]
3010
3011 * Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka]
3012
3013 * Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar]
3014
3015 * Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com]
3016
3017 * Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
3018
3019 * Fixed that find_by_* would fail when column names had numbers #670 [demetrius]
3020
3021 * Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn]
3022
3023 1. Created a new columns method that is much cleaner.
3024 2. Corrected a problem with the select and select_all methods
3025 that didn't account for the LIMIT clause being passed into raw SQL statements.
3026 3. Implemented the string_to_time method in order to create proper instances of the time class.
3027 4. Added logic to the simplified_type method that allows the database to specify the scale of float data.
3028 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string.
3029
3030 * Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow@yahoo.com]
3031
3032 * Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example:
3033
3034 class Person < ActiveRecord::Base
3035 validates_each :first_name, :last_name do |record, attr|
3036 record.errors.add attr, 'starts with z.' if attr[0] == ?z
3037 end
3038 end
3039
3040 * Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper]
3041
3042 * Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example:
3043
3044 class Person < ActiveRecord::Base
3045 validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID }
3046 end
3047
3048 * Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates]
3049
3050 * Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example:
3051
3052 class Project < ActiveRecord::Base
3053 primary_key "sysid"
3054 table_name "XYZ_PROJECT"
3055 inheritance_column { original_inheritance_column + "_id" }
3056 end
3057
3058 * Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu]
3059
3060
3061 *1.6.0* (January 25th, 2005)
3062
3063 * Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once.
3064
3065 * Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336
3066
3067 * Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once.
3068
3069 * Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example
3070
3071 people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
3072 Person.update(people.keys, people.values)
3073
3074 * Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron]
3075
3076 * Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat]
3077
3078 * Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius]
3079
3080 * Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper]
3081
3082 * Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson]
3083
3084 * Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson]
3085
3086 * Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not
3087
3088 * Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription
3089
3090 * Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius]
3091
3092 * Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron]
3093
3094
3095 *1.5.1* (January 18th, 2005)
3096
3097 * Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates]
3098
3099 * Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle]
3100
3101
3102 *1.5.0* (January 17th, 2005)
3103
3104 * Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel]
3105
3106 * Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example:
3107
3108 class Book < ActiveRecord::Base
3109 has_many :pages
3110 belongs_to :library
3111
3112 validates_associated :pages, :library
3113 end
3114
3115 * Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition:
3116
3117 == Unsaved objects and associations
3118
3119 You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be
3120 aware of, mostly involving the saving of associated objects.
3121
3122 === One-to-one associations
3123
3124 * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in
3125 order to update their primary keys - except if the parent object is unsaved (new_record? == true).
3126 * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment
3127 is cancelled.
3128 * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below).
3129 * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does
3130 not save the parent either.
3131
3132 === Collections
3133
3134 * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object
3135 (the owner of the collection) is not yet stored in the database.
3136 * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false.
3137 * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below).
3138 * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved.
3139
3140 * Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates]
3141
3142 * Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates]
3143
3144 * Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates]
3145
3146 * Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates]
3147
3148 * Fixed binary support for PostgreSQL #444 [alex@byzantine.no]
3149
3150 * Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the
3151 collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If
3152 it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards,
3153 it'll take one less SELECT query if you use length.
3154
3155 * Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de]
3156
3157 * Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson]
3158
3159 * Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey]
3160
3161 * Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz]
3162
3163 * Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper]
3164
3165 * Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower]
3166
3167 * Added that Observers can use the observes class method instead of overwriting self.observed_class().
3168
3169 Before:
3170 class ListSweeper < ActiveRecord::Base
3171 def self.observed_class() [ List, Item ]
3172 end
3173
3174 After:
3175 class ListSweeper < ActiveRecord::Base
3176 observes List, Item
3177 end
3178
3179 * Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is
3180
3181 * Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name
3182
3183 * Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag.
3184
3185 Before: topic.update_attribute(:approved, !approved?)
3186 After : topic.toggle!(:approved)
3187
3188 * Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example:
3189
3190 page.views # => 1
3191 page.increment!(:views) # executes an UPDATE statement
3192 page.views # => 2
3193
3194 page.increment(:views).increment!(:views)
3195 page.views # => 4
3196
3197 * Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns.
3198
3199
3200
3201
3202 *1.14.2* (April 9th, 2005)
3203
3204 * Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen]
3205
3206
3207 *1.14.1* (April 6th, 2006)
3208
3209 * Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar]
3210
3211 * Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
3212
3213 * Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
3214
3215 * Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick]
3216
3217 * Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr]
3218
3219 * Allow AR::Base#respond_to? to behave when @attributes is nil [zenspider]
3220
3221 * Support eager includes when going through a polymorphic has_many association. [Rick]
3222
3223 * Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick]
3224
3225 class Post < ActiveRecord::Base
3226 has_one :tagging, :as => :taggable
3227 end
3228
3229 Post.find :all, :include => :tagging
3230
3231 * Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick]
3232
3233 * Added support for going through a polymorphic has_many association: (closes #4401) [Rick]
3234
3235 class PhotoCollection < ActiveRecord::Base
3236 has_many :photos, :as => :photographic
3237 belongs_to :firm
3238 end
3239
3240 class Firm < ActiveRecord::Base
3241 has_many :photo_collections
3242 has_many :photos, :through => :photo_collections
3243 end
3244
3245 * Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com]
3246
3247 * Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber]
3248
3249 * Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan]
3250
3251 * Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick]
3252
3253 * DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH]
3254
3255 * Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [DHH]
3256
3257 * Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.]
3258
3259 * Fixed broken OCIAdapter #4457 [schoenm@earthlink.net]
3260
3261
3262 *1.14.0* (March 27th, 2006)
3263
3264 * Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar]
3265
3266 * Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
3267
3268 * Add support for :include to with_scope [andrew@redlinesoftware.com]
3269
3270 * Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [schoenm@earthlink.net]
3271
3272 * Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com]
3273
3274 * Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick]
3275
3276 * Fixed issue that kept :select options from being scoped [Rick]
3277
3278 * Fixed db_schema_import when binary types are present #3101 [DHH]
3279
3280 * Fixed that MySQL enums should always be returned as strings #3501 [DHH]
3281
3282 * Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson]
3283
3284 class Connection < ActiveRecord::Base
3285 belongs_to :user
3286 belongs_to :channel
3287 end
3288
3289 class Channel < ActiveRecord::Base
3290 has_many :connections
3291 has_many :contacts, :through => :connections, :class_name => 'User' # OLD
3292 has_many :contacts, :through => :connections, :source => :user # NEW
3293 end
3294
3295 * Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de]
3296
3297 * Allow overriding of find parameters in scoped has_many :through calls [Rick Olson]
3298
3299 In this example, :include => false disables the default eager association from loading. :select changes the standard
3300 select clause. :joins specifies a join that is added to the end of the has_many :through query.
3301
3302 class Post < ActiveRecord::Base
3303 has_many :tags, :through => :taggings, :include => :tagging do
3304 def add_joins_and_select
3305 find :all, :select => 'tags.*, authors.id as author_id', :include => false,
3306 :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id'
3307 end
3308 end
3309 end
3310
3311 * Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [DHH]
3312
3313 * Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [jonathan@bluewire.net.nz]
3314
3315 * Quit ignoring default :include options in has_many :through calls [Mark James]
3316
3317 * Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [jonathan@bluewire.net.nz]
3318
3319 * Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson]
3320
3321 * Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example:
3322
3323 class Firm < ActiveRecord::Base
3324 has_many :clients
3325 has_many :invoices, :through => :clients
3326 end
3327
3328 class Client < ActiveRecord::Base
3329 belongs_to :firm
3330 has_many :invoices
3331 end
3332
3333 class Invoice < ActiveRecord::Base
3334 belongs_to :client
3335 end
3336
3337 * Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [josh@hasmanythrough.com]
3338
3339 * Fixed has_many :through to include :conditions set on the :through association. closes #4020 [jonathan@bluewire.net.nz]
3340
3341 * Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick]
3342
3343 * SQL Server adapter gets some love #4298 [rtomayko@gmail.com]
3344
3345 * Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com]
3346
3347 * Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI):
3348
3349 Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body')
3350
3351 * Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick]
3352
3353 * Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Koz]
3354
3355 * Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Koz]
3356
3357 * Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom ward]
3358
3359 * Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com]
3360
3361 * Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck]
3362
3363 * Use association's :conditions when eager loading. [jeremyevans0@gmail.com] #4144
3364
3365 * Alias the has_and_belongs_to_many join table on eager includes. #4106 [jeremyevans0@gmail.com]
3366
3367 This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous.
3368
3369 Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL')
3370
3371 * Oracle adapter gets some love #4230 [schoenm@earthlink.net]
3372
3373 * Changes :text to CLOB rather than BLOB [Moses Hohman]
3374 * Fixes an issue with nil numeric length/scales (several)
3375 * Implements support for XMLTYPE columns [wilig / Kubo Takehiro]
3376 * Tweaks a unit test to get it all green again
3377 * Adds support for #current_database
3378
3379 * Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson]
3380
3381 class CachedModel < ActiveRecord::Base
3382 self.abstract_class = true
3383 end
3384
3385 class Post < CachedModel
3386 end
3387
3388 CachedModel.abstract_class?
3389 => true
3390
3391 Post.abstract_class?
3392 => false
3393
3394 Post.base_class
3395 => Post
3396
3397 Post.table_name
3398 => 'posts'
3399
3400 * Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson]
3401
3402 class Foo < ActiveRecord::Base
3403 has_many :attachments, :as => :attachable, :dependent => :delete_all
3404 end
3405
3406 * Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay@gmail.com]
3407
3408 * Upgrade to Transaction::Simple 1.3 [Jamis Buck]
3409
3410 * Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson]
3411
3412 * Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com]
3413
3414 * Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com]
3415
3416 * Dynamically set allow_concurrency. #4044 [Stefan Kaes]
3417
3418 * Added Base#to_xml that'll turn the current record into a XML representation [DHH]. Example:
3419
3420 topic.to_xml
3421
3422 ...returns:
3423
3424 <?xml version="1.0" encoding="UTF-8"?>
3425 <topic>
3426 <title>The First Topic</title>
3427 <author-name>David</author-name>
3428 <id type="integer">1</id>
3429 <approved type="boolean">false</approved>
3430 <replies-count type="integer">0</replies-count>
3431 <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time>
3432 <written-on type="datetime">2003-07-16 09:28:00</written-on>
3433 <content>Have a nice day</content>
3434 <author-email-address>david@loudthinking.com</author-email-address>
3435 <parent-id></parent-id>
3436 <last-read type="date">2004-04-15</last-read>
3437 </topic>
3438
3439 ...and you can configure with:
3440
3441 topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ])
3442
3443 ...that'll return:
3444
3445 <topic>
3446 <title>The First Topic</title>
3447 <author-name>David</author-name>
3448 <approved type="boolean">false</approved>
3449 <content>Have a nice day</content>
3450 <author-email-address>david@loudthinking.com</author-email-address>
3451 <parent-id></parent-id>
3452 <last-read type="date">2004-04-15</last-read>
3453 </topic>
3454
3455 You can even do load first-level associations as part of the document:
3456
3457 firm.to_xml :include => [ :account, :clients ]
3458
3459 ...that'll return something like:
3460
3461 <?xml version="1.0" encoding="UTF-8"?>
3462 <firm>
3463 <id type="integer">1</id>
3464 <rating type="integer">1</rating>
3465 <name>37signals</name>
3466 <clients>
3467 <client>
3468 <rating type="integer">1</rating>
3469 <name>Summit</name>
3470 </client>
3471 <client>
3472 <rating type="integer">1</rating>
3473 <name>Microsoft</name>
3474 </client>
3475 </clients>
3476 <account>
3477 <id type="integer">1</id>
3478 <credit-limit type="integer">50</credit-limit>
3479 </account>
3480 </firm>
3481
3482 * Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck]
3483
3484 * Documentation fixes for :dependent [robby@planetargon.com]
3485
3486 * Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney]
3487
3488 * Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org]
3489
3490 * Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson]
3491
3492 * Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>]
3493
3494 * Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson]
3495
3496 * The first time a table is referenced in a join, no alias is used.
3497 * After that, the parent class name and the reflection name are used.
3498
3499 Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ...
3500
3501 * Any additional join references get a numerical suffix like '_2', '_3', etc.
3502
3503 * Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to.
3504
3505 * Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples:
3506
3507 # cascaded in two levels
3508 >> Author.find(:all, :include=>{:posts=>:comments})
3509 => authors
3510 +- posts
3511 +- comments
3512
3513 # cascaded in two levels and normal association
3514 >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations])
3515 => authors
3516 +- posts
3517 +- comments
3518 +- categorizations
3519
3520 # cascaded in two levels with two has_many associations
3521 >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]})
3522 => authors
3523 +- posts
3524 +- comments
3525 +- categorizations
3526
3527 # cascaded in three levels
3528 >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}})
3529 => companies
3530 +- groups
3531 +- members
3532 +- favorites
3533
3534 * Make counter cache work when replacing an association #3245 [eugenol@gmail.com]
3535
3536 * Make migrations verbose [Jamis Buck]
3537
3538 * Make counter_cache work with polymorphic belongs_to [Jamis Buck]
3539
3540 * Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp]
3541
3542 * Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats:
3543
3544 * Does not support DATE SQL column types; use DATETIME instead.
3545 * Date columns on HABTM join tables are returned as String, not Time.
3546 * Insertions are potentially broken for :polymorphic join tables
3547 * BLOB column access not yet fully supported
3548
3549 * Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper]
3550
3551 * CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper]
3552
3553 * Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [schoenm@earthlink.net]
3554
3555 * Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [DHH]
3556
3557 * Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes]
3558
3559 * Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark]
3560
3561 * Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net]
3562
3563 * Define attribute query methods to avoid method_missing calls. #3677 [jonathan@bluewire.net.nz]
3564
3565 * ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward]
3566
3567 * Added support for nested scopes #3407 [anna@wota.jp]. Examples:
3568
3569 Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do
3570 Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10
3571
3572 # inner rule is used. (all previous parameters are ignored)
3573 Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do
3574 Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis')
3575 end
3576
3577 # parameters are merged
3578 Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do
3579 Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10
3580 end
3581 end
3582
3583 * Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com]
3584
3585 * Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh]
3586
3587 * Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [lars@pind.com]
3588
3589 * Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples:
3590
3591 Person.average :age
3592 Person.minimum :age
3593 Person.maximum :age
3594 Person.sum :salary, :group => :last_name
3595
3596 * Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [contact@lukeredpath.co.uk]
3597
3598 * Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper]
3599
3600 * Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net]
3601
3602 * Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de]
3603
3604 * Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [skaes]
3605
3606 * Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva]
3607
3608 * Allow :include to be used with has_many :through associations #3611 [Michael Schoen]
3609
3610 * PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac]
3611
3612 * SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward]
3613
3614 * Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson]
3615
3616 * PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org]
3617
3618 * Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark]
3619
3620 * ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Luetke]
3621
3622 * Using AssociationCollection#build with arrays of hashes should call build, not create [DHH]
3623
3624 * Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar]
3625
3626 * Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt]
3627
3628 * Support the :column option for remove_index with the PostgreSQL adapter. #3661 [shugo@ruby-lang.org]
3629
3630 * Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>]
3631
3632 * If the OCI library is not available, raise an exception indicating as much. #3593 [schoenm@earthlink.net]
3633
3634 * Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson]
3635
3636 * Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.]
3637
3638 * Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar]
3639
3640 * Make .count work for has_many associations with multi line finder sql [schoenm@earthlink.net]
3641
3642 * Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck]
3643
3644 * Allow configuration of the column used for optimistic locking [wilsonb@gmail.com]
3645
3646 * Don't hardcode 'id' in acts as list. [ror@philippeapril.com]
3647
3648 * Fix date errors for SQLServer in association tests. #3406 [kevin.clark@gmal.com]
3649
3650 * Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp]
3651
3652 * Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com]
3653
3654 * .with_scope imposed create parameters now bypass attr_protected [Tobias Luetke]
3655
3656 * Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.]
3657
3658 * Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de]
3659
3660 * Sanitize scoped conditions. [Marcel Molina Jr.]
3661
3662 * Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [DHH]
3663
3664 * Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [TobiasLuetke]
3665
3666 * SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [TobiasLuetke]
3667
3668 * Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber]
3669
3670 * Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron]
3671
3672 * removed :piggyback in favor of just allowing :select on :through associations. [Tobias Luetke]
3673
3674 * made method missing delegation to class methods on relation target work on :through associations. [Tobias Luetke]
3675
3676 * made .find() work on :through relations. [Tobias Luetke]
3677
3678 * Fix typo in association docs. #3296. [Blair Zajac]
3679
3680 * Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Luetke]
3681
3682 *1.13.2* (December 13th, 2005)
3683
3684 * Become part of Rails 1.0
3685
3686 * MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper]
3687
3688 * Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [DHH]. Example:
3689
3690 class Post
3691 has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author
3692 end
3693
3694 post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors
3695 post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors
3696 post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors
3697
3698 * Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [DHH]
3699
3700 * MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder]
3701
3702 * SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com]
3703
3704 * SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org]
3705
3706 * SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com]
3707
3708 * SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko]
3709
3710 * SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com]
3711
3712 * Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen]
3713
3714 * MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes]
3715
3716 * Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausolei]
3717
3718 * Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond]
3719
3720 * PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson]
3721
3722 * Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen]
3723
3724 * MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper]
3725
3726 * Added preliminary support for polymorphic associations [DHH]
3727
3728 * Added preliminary support for join models [DHH]
3729
3730 * Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.]
3731
3732 * Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>]
3733
3734 * Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>]
3735
3736 * MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper]
3737
3738 * Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen]
3739
3740 * SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com]
3741
3742 * Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper]
3743
3744 * Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen]
3745
3746 * MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda]
3747
3748 * has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper]
3749
3750 * MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda]
3751
3752 * Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.]
3753
3754 * Correct boolean handling in generated reader methods. #2945 [don.park@gmail.com, Stefan Kaes]
3755
3756 * Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes]
3757
3758 * Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>]
3759
3760 * Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans]
3761
3762 * Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
3763
3764 * Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>]
3765
3766 * SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
3767
3768 * Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com]
3769
3770 * SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
3771
3772 * Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>]
3773
3774 * Correct documentation for Base.delete_all. #1568 [Newhydra]
3775
3776 * Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>]
3777
3778 * Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>]
3779
3780 * When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper]
3781
3782 * Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>]
3783
3784 * Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper]
3785
3786 * PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper]
3787
3788 * PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper]
3789
3790 * SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko]
3791
3792 * Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>]
3793
3794 * Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de]
3795
3796 * Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>]
3797
3798 * acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com]
3799
3800 * Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar]
3801
3802 * Fixed acts_as_list for definitions without an explicit :order #2803 [jonathan@bluewire.net.nz]
3803
3804 * Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper]
3805
3806 * Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.]
3807
3808 * Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com]
3809
3810 * Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper]
3811
3812 * Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper]
3813
3814 * More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>]
3815
3816
3817 *1.13.0* (November 7th, 2005)
3818
3819 * Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko]
3820
3821 * Added :include as an option for association declarations [DHH]. Example:
3822
3823 has_many :posts, :include => [ :author, :comments ]
3824
3825 * Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example:
3826
3827 Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do
3828 # Find where name = ? and active=true
3829 Comment.find :all, :conditions => ['name = ?', name]
3830 # Create comment associated with :post_id
3831 Comment.create :body => "Hello world"
3832 end
3833
3834 * Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko]
3835
3836 * Added constrain scoping for creates using a hash of attributes bound to the :creation key [DHH]. Example:
3837
3838 Comment.constrain(:creation => { :post_id => 5 }) do
3839 # Associated with :post_id
3840 Comment.create :body => "Hello world"
3841 end
3842
3843 This is rarely used directly, but allows for find_or_create on associations. So you can do:
3844
3845 # If the tag doesn't exist, a new one is created that's associated with the person
3846 person.tags.find_or_create_by_name("Summer")
3847
3848 * Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [DHH]. Example:
3849
3850 # No 'Summer' tag exists
3851 Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
3852
3853 # Now the 'Summer' tag does exist
3854 Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
3855
3856 * Added extension capabilities to has_many and has_and_belongs_to_many proxies [DHH]. Example:
3857
3858 class Account < ActiveRecord::Base
3859 has_many :people do
3860 def find_or_create_by_name(name)
3861 first_name, *last_name = name.split
3862 last_name = last_name.join " "
3863
3864 find_or_create_by_first_name_and_last_name(first_name, last_name)
3865 end
3866 end
3867 end
3868
3869 person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson")
3870 person.first_name # => "David"
3871 person.last_name # => "Heinemeier Hansson"
3872
3873 Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation).
3874
3875 * Omit internal dtproperties table from SQLServer table list. #2729 [rtomayko@gmail.com]
3876
3877 * Quote column names in generated SQL. #2728 [rtomayko@gmail.com]
3878
3879 * Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper]
3880
3881 * Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper]
3882
3883 * Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>]
3884
3885 * Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson]
3886
3887 * Added migration support for Oracle #2647 [Michael Schoen]
3888
3889 * Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>]
3890
3891 * Fixed SQL Server adapter to pass even more tests and do even better #2634 [rtomayko@gmail.com]
3892
3893 * Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward]
3894
3895 * Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward]
3896
3897 * Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com]
3898
3899 * Constraints are cloned so they can't be inadvertently modified while they're
3900 in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>]
3901
3902 * Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com]
3903
3904 * Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [schoenm@earthlink.net]
3905
3906 * Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt]
3907
3908
3909 *1.12.2* (October 26th, 2005)
3910
3911 * Allow symbols to rename columns when using SQLite adapter. #2531 [kevin.clark@gmail.com]
3912
3913 * Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>]
3914
3915 * Clarify semantics of ActiveRecord::Base#respond_to? #2560 [skaes@web.de]
3916
3917 * Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>]
3918
3919 * HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>]
3920
3921 * Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>]
3922
3923
3924 *1.12.1* (October 19th, 2005)
3925
3926 * Always parenthesize :conditions options so they may be safely combined with STI and constraints.
3927
3928 * Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com]
3929
3930 * Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations
3931
3932
3933 *1.12.0* (October 16th, 2005)
3934
3935 * Update/clean up documentation (rdoc)
3936
3937 * PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>]
3938
3939 * Change default logging colors to work on both white and black backgrounds. [Sam Stephenson]
3940
3941 * YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net]
3942
3943 * :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>]
3944
3945 * Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around.
3946
3947 * Avoid memleak in dev mode when using fcgi
3948
3949 * Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>]
3950
3951 * Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>]
3952
3953 * Fix errors caused by assigning a has-one or belongs-to property to itself
3954
3955 * Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson]
3956
3957 * Update DB2 adapter. #2206. [contact@maik-schmidt.de]
3958
3959 * Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com]
3960
3961 * Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency.
3962
3963 * Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>]
3964
3965 * Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code]
3966
3967 * Add test coverage for content_columns. #2432. [coffee2code]
3968
3969 * Speed up for unthreaded environments. #2431. [skaes@web.de]
3970
3971 * Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [skaes@web.de]
3972
3973 * Speed up the setting of table_name. #2428. [skaes@web.de]
3974
3975 * Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [skaes@web.de]
3976
3977 * Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>]
3978
3979 * Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [skaes@web.de]
3980
3981 * Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>]
3982
3983 * Add geometric type for postgresql adapter. #2233 [akaspick@gmail.com]
3984
3985 * Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [skaes@web.de]
3986
3987 * Add convenience predicate methods on Column class. In partial fullfilment of #1236. [skaes@web.de]
3988
3989 * Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar]
3990
3991 * Added :force option to create_table that'll try to drop the table if it already exists before creating
3992
3993 * Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar]
3994
3995 * Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>]
3996
3997 * model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>]
3998
3999 * Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman]
4000
4001 * Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>]
4002
4003 * Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>]
4004
4005 * Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>]
4006
4007 * Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>]
4008
4009 * Make update_attribute use the same writer method that update_attributes uses.
4010 #2237 [trevor@protocool.com]
4011
4012 * Make migrations honor table name prefixes and suffixes. #2298 [Jakob S, Marcel Molina]
4013
4014 * Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org]
4015
4016 * Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com]
4017
4018 * Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
4019
4020 * Added new symbol-driven approach to activating observers with Base#observers= [DHH]. Example:
4021
4022 ActiveRecord::Base.observers = :cacher, :garbage_collector
4023
4024 * Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com]
4025
4026 * Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck]
4027
4028 * Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck]
4029
4030 * Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck]
4031
4032 * Fixed migrations for Windows when using more than 10 [David Naseby]
4033
4034 * Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
4035
4036 * Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
4037
4038 * Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]
4039
4040 * Fixed that Observers didn't observe sub-classes #627 [Florian Weber]
4041
4042 * Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina]
4043
4044 * Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae]
4045
4046 * Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber]
4047
4048 * Added better exception error when unknown column types are used with migrations #1814 [fbeausoleil@ftml.net]
4049
4050 * Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com]
4051
4052 * Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg]
4053
4054 * Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward]
4055
4056 * Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code]
4057
4058 * Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net]
4059
4060 * Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/
4061
4062 * Make sure the schema_info table is created before querying the current version #1903
4063
4064 * Fixtures ignore table name prefix and suffix #1987 [Jakob S]
4065
4066 * Add documentation for index_type argument to add_index method for migrations #2005 [blaine@odeo.com]
4067
4068 * Modify read_attribute to allow a symbol argument #2024 [Ken Kunz]
4069
4070 * Make destroy return self #1913 [sebastian.kanthak@muehlheim.de]
4071
4072 * Fix typo in validations documentation #1938 [court3nay]
4073
4074 * Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org]
4075
4076 * Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky]
4077
4078 * Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
4079
4080 * Fix create_table so that id column is implicitly added [Rick Olson]
4081
4082 * Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798
4083
4084 * OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798
4085
4086 * Fixed the handling of camelCase columns names in Oracle #1798
4087
4088 * Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798
4089
4090 * Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798
4091
4092 * Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Luetke]
4093
4094 class Comment < AR:B
4095 def self.search(q)
4096 find(:all, :conditions => ["body = ?", q])
4097 end
4098 end
4099
4100 class Post < AR:B
4101 has_many :comments
4102 end
4103
4104 Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi'
4105
4106 NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as
4107 by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on
4108 details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself
4109 noticed :)
4110
4111 * Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson]
4112
4113 * Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar]
4114
4115 * Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions
4116
4117 * Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt]
4118
4119 * Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes]
4120
4121
4122 *1.11.1* (11 July, 2005)
4123
4124 * Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olsen]
4125
4126 * Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com]
4127
4128 * Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson]
4129
4130 * Correct reflected table name for singular associations. #1688 [court3nay@gmail.com]
4131
4132 * Fixed optimistic locking with SQL Server #1660 [tom@popdog.net]
4133
4134 * Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current
4135
4136 * Added better error message for "packets out of order" #1630 [courtenay]
4137
4138 * Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640
4139
4140
4141 *1.11.0* (6 July, 2005)
4142
4143 * Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar]
4144
4145 * Changed logging of SQL statements to use the DEBUG level instead of INFO
4146
4147 * Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Luetke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator.
4148
4149 * Added callback hooks to association collections #1549 [Florian Weber]. Example:
4150
4151 class Project
4152 has_and_belongs_to_many :developers, :before_add => :evaluate_velocity
4153
4154 def evaluate_velocity(developer)
4155 ...
4156 end
4157 end
4158
4159 ..raising an exception will cause the object not to be added (or removed, with before_remove).
4160
4161
4162 * Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry]
4163
4164 * Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato]
4165
4166 * Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber]
4167
4168 * Speed up ActiveRecord#method_missing for the common case (read_attribute).
4169
4170 * Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [skaes@web.de]
4171
4172 * Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath]
4173
4174 * Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
4175
4176 * Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [michael@schuerig.de]
4177
4178 * Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
4179
4180 * Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry]
4181
4182 * Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net]
4183
4184 * Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
4185
4186 * Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be:
4187
4188 Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
4189
4190 ...should instead be:
4191
4192 Developer.find(
4193 :all,
4194 :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
4195 :conditions => 'project_id=1'
4196 )
4197
4198 * Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina]
4199
4200 * Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon]
4201
4202 * Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
4203
4204 * Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid]
4205
4206 * Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice
4207
4208 * Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper]
4209
4210 * Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak].
4211 Example:
4212
4213 david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")]
4214 david.save
4215
4216 If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new
4217 project is saved when david.save is called.
4218
4219 Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do:
4220
4221 david.project_ids = [1, 5, 7]
4222
4223 * Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com]
4224
4225 * Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Luetke]
4226
4227 * Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org]
4228
4229 * Corrected @@configurations typo #1410 [david@ruppconsulting.com]
4230
4231 * Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com]
4232
4233 * Allow before/after update hooks to work on models using optimistic locking
4234
4235 * Eager loading of dependent has_one associations won't delete the association #1212
4236
4237 * Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it.
4238
4239 * Using transactional fixtures now causes the data to be loaded only once.
4240
4241 * Added fixture accessor methods that can be used when instantiated fixtures are disabled.
4242
4243 fixtures :web_sites
4244
4245 def test_something
4246 assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
4247 end
4248
4249 * Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]
4250
4251 * Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
4252
4253 * CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309
4254
4255 * Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead
4256
4257 * Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples:
4258
4259 Conditional validations such as the following are made possible:
4260 validates_numericality_of :income, :if => :employed?
4261
4262 Conditional validations can also solve the salted login generator problem:
4263 validates_confirmation_of :password, :if => :new_password?
4264
4265 Using blocks:
4266 validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 }
4267
4268 * Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
4269
4270 * Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
4271
4272 * Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper]
4273
4274 * Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed.
4275
4276 * Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first.
4277
4278 * Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example:
4279
4280 # SELECT * FROM topics WHERE title IN ('First', 'Second')
4281 Topic.find_all_by_title(["First", "Second"])
4282
4283 * Added compatibility with camelCase column names for dynamic finders #533 [Dee.Zsombor]
4284
4285 * Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
4286
4287 * Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid]
4288
4289 * Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com]
4290
4291 * Added encoding and min_messages options for PostgreSQL #1205 [shugo]. Configuration example:
4292
4293 development:
4294 adapter: postgresql
4295 database: rails_development
4296 host: localhost
4297 username: postgres
4298 password:
4299 encoding: UTF8
4300 min_messages: ERROR
4301
4302 * Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck]
4303
4304 * Added validates_exclusion_of as a negative of validates_inclusion_of
4305
4306 * Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls
4307
4308
4309 *1.10.1* (20th April, 2005)
4310
4311 * Fixed frivilous database queries being triggered with eager loading on empty associations and other things
4312
4313 * Fixed order of loading in eager associations
4314
4315 * Fixed stray comma when using eager loading and ordering together from has_many associations #1143
4316
4317
4318 *1.10.0* (19th April, 2005)
4319
4320 * Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example:
4321
4322 for post in Post.find(:all, :limit => 100)
4323 puts "Post: " + post.title
4324 puts "Written by: " + post.author.name
4325 puts "Last comment on: " + post.comments.first.created_on
4326 end
4327
4328 This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as:
4329
4330 for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ])
4331
4332 ...and the number of database queries needed is now 1.
4333
4334 * Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples:
4335
4336 Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
4337 Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC")
4338 Person.find(:first, :order => "created_on DESC", :offset => 5)
4339 Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
4340 Person.find(:all, :offset => 10, :limit => 10)
4341
4342 * Added acts_as_nested_set #1000 [wschenk]. Introduction:
4343
4344 This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with
4345 the added feature that you can select the children and all of it's descendants with
4346 a single query. A good use case for this is a threaded post system, where you want
4347 to display every reply to a comment without multiple selects.
4348
4349 * Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [After much pestering from Dave Thomas]
4350
4351 * Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com]
4352
4353 * Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com]
4354
4355 * Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com]
4356
4357 * Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher]
4358
4359 * Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle]
4360
4361 * Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com]
4362
4363 * Added insert_at(position) to acts_as_list #1083 [DeLynnB]
4364
4365 * Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order)
4366
4367 * Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com]
4368
4369 * Fixed boolean saving on Oracle #1093 [mparrish@pearware.org]
4370
4371 * Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864
4372
4373 * Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]
4374
4375 * Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
4376
4377 * Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
4378
4379 * Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
4380
4381 * Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org]
4382
4383 * Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper]
4384
4385 * Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]
4386
4387 * Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]
4388
4389 * Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
4390
4391 * Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas]
4392
4393 * Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias)
4394
4395
4396 *1.9.1* (27th March, 2005)
4397
4398 * Fixed that Active Record objects with float attribute could not be cloned #808
4399
4400 * Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar]
4401
4402 * Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count
4403
4404 * Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron]
4405
4406 * Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb]
4407
4408
4409 *1.9.0* (22th March, 2005)
4410
4411 * Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example:
4412
4413 Developer.find_all nil, 'id ASC', 5 # return the first five developers
4414 Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward
4415
4416 This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged.
4417
4418 * Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson]
4419
4420 * Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins]
4421
4422 * Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org]
4423
4424 * Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel]
4425
4426 * Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid]
4427
4428 * Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com]
4429
4430 * Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net]
4431
4432 * Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak]
4433
4434 * Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak]
4435
4436 * Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm]
4437
4438 * Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
4439
4440 * Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body)
4441
4442
4443 *1.8.0* (7th March, 2005)
4444
4445 * Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default)
4446
4447 * Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron]
4448
4449 * Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation:
4450
4451 * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
4452 +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
4453 objects that should be inspected to determine which attributes triggered the errors.
4454 * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
4455 You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
4456
4457 * Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k]
4458
4459 * Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper]
4460
4461 * Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example:
4462
4463 class Account < ActiveRecord::Base
4464 has_one :credit_card, :dependent => true
4465 end
4466 class CreditCard < ActiveRecord::Base
4467 belongs_to :account
4468 end
4469
4470 account.credit_card # => returns existing credit card, lets say id = 12
4471 account.credit_card = CreditCard.create("number" => "123")
4472 account.save # => CC with id = 12 is destroyed
4473
4474
4475 * Added validates_numericality_of #716 [skanthak/c.r.mcgrath]. Docuemntation:
4476
4477 Validates whether the value of the specified attribute is numeric by trying to convert it to
4478 a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression
4479 <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true).
4480
4481 class Person < ActiveRecord::Base
4482 validates_numericality_of :value, :on => :create
4483 end
4484
4485 Configuration options:
4486 * <tt>message</tt> - A custom error message (default is: "is not a number")
4487 * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
4488 * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false)
4489
4490
4491 * Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron]
4492
4493 * Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed)
4494
4495 * Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com]
4496
4497
4498 *1.7.0* (24th February, 2005)
4499
4500 * Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck]
4501
4502 * Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes:
4503
4504 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple
4505 and safe way of passing table-specific sequence information to the adapter.)
4506 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to
4507 resort to some hacks to get data converted to Date or Time in Ruby.
4508 If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the
4509 hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time.
4510 This is nasty - but if you use Duck Typing you'll probably not care very much.
4511 In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is
4512 valid - too many databases use DATE for both.
4513 Timezones and sub-second precision on timestamps are not supported.
4514 3. Default values that are functions (such as "SYSDATE") are not supported. This is a
4515 restriction of the way active record supports default values.
4516 4. Referential integrity constraints are not fully supported. Under at least
4517 some circumstances, active record appears to delete parent and child records out of
4518 sequence and out of transaction scope. (Or this may just be a problem of test setup.)
4519
4520 The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/
4521
4522 * Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke]
4523
4524 * Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm]
4525
4526 * Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka]
4527
4528 * Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar]
4529
4530 * Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com]
4531
4532 * Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
4533
4534 * Fixed that find_by_* would fail when column names had numbers #670 [demetrius]
4535
4536 * Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn]
4537
4538 1. Created a new columns method that is much cleaner.
4539 2. Corrected a problem with the select and select_all methods
4540 that didn't account for the LIMIT clause being passed into raw SQL statements.
4541 3. Implemented the string_to_time method in order to create proper instances of the time class.
4542 4. Added logic to the simplified_type method that allows the database to specify the scale of float data.
4543 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string.
4544
4545 * Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow@yahoo.com]
4546
4547 * Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example:
4548
4549 class Person < ActiveRecord::Base
4550 validates_each :first_name, :last_name do |record, attr|
4551 record.errors.add attr, 'starts with z.' if attr[0] == ?z
4552 end
4553 end
4554
4555 * Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper]
4556
4557 * Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example:
4558
4559 class Person < ActiveRecord::Base
4560 validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID }
4561 end
4562
4563 * Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates]
4564
4565 * Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example:
4566
4567 class Project < ActiveRecord::Base
4568 primary_key "sysid"
4569 table_name "XYZ_PROJECT"
4570 inheritance_column { original_inheritance_column + "_id" }
4571 end
4572
4573 * Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu]
4574
4575
4576 *1.6.0* (January 25th, 2005)
4577
4578 * Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once.
4579
4580 * Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336
4581
4582 * Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once.
4583
4584 * Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example
4585
4586 people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
4587 Person.update(people.keys, people.values)
4588
4589 * Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron]
4590
4591 * Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat]
4592
4593 * Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius]
4594
4595 * Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper]
4596
4597 * Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson]
4598
4599 * Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson]
4600
4601 * Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not
4602
4603 * Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription
4604
4605 * Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius]
4606
4607 * Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron]
4608
4609
4610 *1.5.1* (January 18th, 2005)
4611
4612 * Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates]
4613
4614 * Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle]
4615
4616
4617 *1.5.0* (January 17th, 2005)
4618
4619 * Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel]
4620
4621 * Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example:
4622
4623 class Book < ActiveRecord::Base
4624 has_many :pages
4625 belongs_to :library
4626
4627 validates_associated :pages, :library
4628 end
4629
4630 * Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition:
4631
4632 == Unsaved objects and associations
4633
4634 You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be
4635 aware of, mostly involving the saving of associated objects.
4636
4637 === One-to-one associations
4638
4639 * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in
4640 order to update their primary keys - except if the parent object is unsaved (new_record? == true).
4641 * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment
4642 is cancelled.
4643 * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below).
4644 * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does
4645 not save the parent either.
4646
4647 === Collections
4648
4649 * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object
4650 (the owner of the collection) is not yet stored in the database.
4651 * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false.
4652 * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below).
4653 * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved.
4654
4655 * Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates]
4656
4657 * Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates]
4658
4659 * Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates]
4660
4661 * Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates]
4662
4663 * Fixed binary support for PostgreSQL #444 [alex@byzantine.no]
4664
4665 * Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the
4666 collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If
4667 it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards,
4668 it'll take one less SELECT query if you use length.
4669
4670 * Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de]
4671
4672 * Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson]
4673
4674 * Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey]
4675
4676 * Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz]
4677
4678 * Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper]
4679
4680 * Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower]
4681
4682 * Added that Observers can use the observes class method instead of overwriting self.observed_class().
4683
4684 Before:
4685 class ListSweeper < ActiveRecord::Base
4686 def self.observed_class() [ List, Item ]
4687 end
4688
4689 After:
4690 class ListSweeper < ActiveRecord::Base
4691 observes List, Item
4692 end
4693
4694 * Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is
4695
4696 * Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name
4697
4698 * Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag.
4699
4700 Before: topic.update_attribute(:approved, !approved?)
4701 After : topic.toggle!(:approved)
4702
4703 * Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example:
4704
4705 page.views # => 1
4706 page.increment!(:views) # executes an UPDATE statement
4707 page.views # => 2
4708
4709 page.increment(:views).increment!(:views)
4710 page.views # => 4
4711
4712 * Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns.
4713
4714
4715 *1.4.0* (January 4th, 2005)
4716
4717 * Added automated optimistic locking if the field <tt>lock_version</tt> is present. Each update to the
4718 record increments the lock_version column and the locking facilities ensure that records instantiated twice
4719 will let the last one saved raise a StaleObjectError if the first was also updated. Example:
4720
4721 p1 = Person.find(1)
4722 p2 = Person.find(1)
4723
4724 p1.first_name = "Michael"
4725 p1.save
4726
4727 p2.first_name = "should fail"
4728 p2.save # Raises a ActiveRecord::StaleObjectError
4729
4730 You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging,
4731 or otherwise apply the business logic needed to resolve the conflict.
4732
4733 #384 [Michael Koziarski]
4734
4735 * Added dynamic attribute-based finders as a cleaner way of getting objects by simple queries without turning to SQL.
4736 They work by appending the name of an attribute to <tt>find_by_</tt>, so you get finders like <tt>Person.find_by_user_name,
4737 Payment.find_by_transaction_id</tt>. So instead of writing <tt>Person.find_first(["user_name = ?", user_name])</tt>, you just do
4738 <tt>Person.find_by_user_name(user_name)</tt>.
4739
4740 It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
4741 <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
4742 <tt>Person.find_first(["user_name = ? AND password = ?", user_name, password])</tt>, you just do
4743 <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
4744
4745 While primarily a construct for easier find_firsts, it can also be used as a construct for find_all by using calls like
4746 <tt>Payment.find_all_by_amount(50)</tt> that is turned into <tt>Payment.find_all(["amount = ?", 50])</tt>. This is something not as equally useful,
4747 though, as it's not possible to specify the order in which the objects are returned.
4748
4749 * Added block-style for callbacks #332 [Jeremy Kemper].
4750
4751 Before:
4752 before_destroy(Proc.new{ |record| Person.destroy_all "firm_id = #{record.id}" })
4753
4754 After:
4755 before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" }
4756
4757 * Added :counter_cache option to acts_as_tree that works just like the one you can define on belongs_to #371 [Josh]
4758
4759 * Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates
4760 and times from the database. This is set to :local by default.
4761
4762 * Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite.
4763
4764 * Added the possibility of having objects with acts_as_list created before their scope is available or...
4765
4766 * Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt]
4767
4768 * Added the final touches to the Microsoft SQL Server adapter by Joey Gibson that makes it suitable for actual use #394 [DeLynn Barry]
4769
4770 * Added that Base#find takes an optional options hash, including :conditions. Base#find_on_conditions deprecated in favor of #find with :conditions #407 [Jeremy Kemper]
4771
4772 * Added HasManyAssociation#count that works like Base#count #413 [intinig]
4773
4774 * Fixed handling of binary content in blobs and similar fields for Ruby/MySQL and SQLite #409 [xal]
4775
4776 * Fixed a bug in the Ruby/MySQL that caused binary content to be escaped badly and come back mangled #405 [Tobias Luetke]
4777
4778 * Fixed that the const_missing autoload assumes the requested constant is set by require_association and calls const_get to retrieve it.
4779 If require_association did not set the constant then const_get will call const_missing, resulting in an infinite loop #380 [Jeremy Kemper]
4780
4781 * Fixed broken transactions that were actually only running object-level and not db level transactions [andreas]
4782
4783 * Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406
4784
4785 * Fixed that the overwritten respond_to? method didn't take two parameters like the original #391
4786
4787 * Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin]
4788
4789
4790 *1.3.0* (December 23, 2004)
4791
4792 * Added a require_association hook on const_missing that makes it possible to use any model class without requiring it first. This makes STI look like:
4793
4794 before:
4795 require_association 'person'
4796 class Employee < Person
4797 end
4798
4799 after:
4800 class Employee < Person
4801 end
4802
4803 This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes.
4804
4805 * Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341
4806
4807 * Added scope option to validation_uniqueness #349 [Kent Sibilev]
4808
4809 * Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type.
4810 This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100".
4811
4812 * Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day]
4813
4814 * Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case.
4815 This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron]
4816
4817 * Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Luetke]
4818
4819 * Added more informative exceptions in establish_connection #356 [Jeremy Kemper]
4820
4821 * Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise).
4822
4823 Before:
4824 person.attributes = @params["person"]
4825 person.save
4826
4827 Now:
4828 person.update_attributes(@params["person"])
4829
4830 * Added Base.destroy and Base.delete to remove records without holding a reference to them first.
4831
4832 * Added that query benchmarking will only happen if its going to be logged anyway #344
4833
4834 * Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Luetke]
4835
4836 * Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [Jeremy Kemper]
4837
4838 * Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used
4839 the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten]
4840
4841 * Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz]
4842
4843 * Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction.
4844 If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction
4845 bubble up even when you've dealt with local issues. Closes #231 and #340.
4846
4847 * Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com]
4848
4849 * Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations.
4850
4851 * Fixed the automated timestamping feature when running under Rails' development environment that resets the inheritable attributes on each request.
4852
4853
4854
4855 *1.2.0*
4856
4857 * Added Base.validates_inclusion_of that validates whether the value of the specified attribute is available in a particular enumerable
4858 object. [what-a-day]
4859
4860 class Person < ActiveRecord::Base
4861 validates_inclusion_of :gender, :in=>%w( m f ), :message=>"woah! what are you then!??!!"
4862 validates_inclusion_of :age, :in=>0..99
4863 end
4864
4865 * Added acts_as_list that can decorates an existing class with methods like move_higher/lower, move_to_top/bottom. [Tobias Luetke] Example:
4866
4867 class TodoItem < ActiveRecord::Base
4868 acts_as_list :scope => :todo_list_id
4869 belongs_to :todo_list
4870 end
4871
4872 * Added acts_as_tree that can decorates an existing class with a many to many relationship with itself. Perfect for categories in
4873 categories and the likes. [Tobias Luetke]
4874
4875 * Added that Active Records will automatically record creation and/or update timestamps of database objects if fields of the names
4876 created_at/created_on or updated_at/updated_on are present. [Tobias Luetke]
4877
4878 * Added Base.default_error_messages as a hash of all the error messages used in the validates_*_of so they can be changed in one place [Tobias Luetke]
4879
4880 * Added automatic transaction block around AssociationCollection.<<, AssociationCollection.delete, and AssociationCollection.destroy_all
4881
4882 * Fixed that Base#find will return an array if given an array -- regardless of the number of elements #270 [Marten]
4883
4884 * Fixed that has_and_belongs_to_many would generate bad sql when naming conventions differed from using vanilla "id" everywhere [RedTerror]
4885
4886 * Added a better exception for when a type column is used in a table without the intention of triggering single-table inheritance. Example:
4887
4888 ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'bad_class!'.
4889 This error is raised because the column 'type' is reserved for storing the class in case of inheritance.
4890 Please rename this column if you didn't intend it to be used for storing the inheritance class or
4891 overwrite Company.inheritance_column to use another column for that information.
4892
4893 * Added that single-table inheritance will only kick in if the inheritance_column (by default "type") is present. Otherwise, inheritance won't
4894 have any magic side effects.
4895
4896 * Added the possibility of marking fields as being in error without adding a message (using nil) to it that'll get displayed wth full_messages #208 [mjobin]
4897
4898 * Fixed Base.errors to be indifferent as to whether strings or symbols are used. Examples:
4899
4900 Before:
4901 errors.add(:name, "must be shorter") if name.size > 10
4902 errors.on(:name) # => "must be shorter"
4903 errors.on("name") # => nil
4904
4905 After:
4906 errors.add(:name, "must be shorter") if name.size > 10
4907 errors.on(:name) # => "must be shorter"
4908 errors.on("name") # => "must be shorter"
4909
4910 * Added Base.validates_format_of that Validates whether the value of the specified attribute is of the correct form by matching
4911 it against the regular expression provided. [Marcel]
4912
4913 class Person < ActiveRecord::Base
4914 validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :on => :create
4915 end
4916
4917 * Added Base.validates_length_of that delegates to add_on_boundary_breaking #312 [Tobias Luetke]. Example:
4918
4919 Validates that the specified attribute matches the length restrictions supplied in either:
4920
4921 - configuration[:minimum]
4922 - configuration[:maximum]
4923 - configuration[:is]
4924 - configuration[:within] (aka. configuration[:in])
4925
4926 Only one option can be used at a time.
4927
4928 class Person < ActiveRecord::Base
4929 validates_length_of :first_name, :maximum=>30
4930 validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind"
4931 validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
4932 validates_length_of :fav_bra_size, :minimum=>1, :too_short=>"please enter at least %d character"
4933 validates_length_of :smurf_leader, :is=>4, :message=>"papa is spelled with %d characters... don't play me."
4934 end
4935
4936 * Added Base.validate_presence as an alternative to implementing validate and doing errors.add_on_empty yourself.
4937
4938 * Added Base.validates_uniqueness_of that alidates whether the value of the specified attributes are unique across the system.
4939 Useful for making sure that only one user can be named "davidhh".
4940
4941 class Person < ActiveRecord::Base
4942 validates_uniqueness_of :user_name
4943 end
4944
4945 When the record is created, a check is performed to make sure that no record exist in the database with the given value for the specified
4946 attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself.
4947
4948
4949 * Added Base.validates_confirmation_of that encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example:
4950
4951 Model:
4952 class Person < ActiveRecord::Base
4953 validates_confirmation_of :password
4954 end
4955
4956 View:
4957 <%= password_field "person", "password" %>
4958 <%= password_field "person", "password_confirmation" %>
4959
4960 The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual.
4961 It exists only as an in-memory variable for validating the password. This check is performed both on create and update.
4962
4963
4964 * Added Base.validates_acceptance_of that encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example:
4965
4966 class Person < ActiveRecord::Base
4967 validates_acceptance_of :terms_of_service
4968 end
4969
4970 The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed both on create and update.
4971
4972 NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox.
4973
4974
4975 * Added validation macros to make the stackable just like the lifecycle callbacks. Examples:
4976
4977 class Person < ActiveRecord::Base
4978 validate { |record| record.errors.add("name", "too short") unless name.size > 10 }
4979 validate { |record| record.errors.add("name", "too long") unless name.size < 20 }
4980 validate_on_create :validate_password
4981
4982 private
4983 def validate_password
4984 errors.add("password", "too short") unless password.size > 6
4985 end
4986 end
4987
4988 * Added the option for sanitizing find_by_sql and the offset parts in regular finds [Sam Stephenson]. Examples:
4989
4990 Project.find_all ["category = ?", category_name], "created ASC", ["? OFFSET ?", 15, 20]
4991 Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
4992
4993 * Fixed value quoting in all generated SQL statements, so that integers are not surrounded in quotes and that all sanitation are happening
4994 through the database's own quoting routine. This should hopefully make it lots easier for new adapters that doesn't accept '1' for integer
4995 columns.
4996
4997 * Fixed has_and_belongs_to_many guessing of foreign key so that keys are generated correctly for models like SomeVerySpecialClient
4998 [Florian Weber]
4999
5000 * Added counter_sql option for has_many associations [Jeremy Kemper]. Documentation:
5001
5002 <tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is
5003 specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM.
5004
5005 * Fixed that methods wrapped in callbacks still return their original result #260 [Jeremy Kemper]
5006
5007 * Fixed the Inflector to handle the movie/movies pair correctly #261 [Scott Baron]
5008
5009 * Added named bind-style variable interpolation #281 [Michael Koziarski]. Example:
5010
5011 Person.find(["id = :id and first_name = :first_name", { :id => 5, :first_name = "bob' or 1=1" }])
5012
5013 * Added bind-style variable interpolation for the condition arrays that uses the adapter's quote method [Michael Koziarski]
5014
5015 Before:
5016 find_first([ "user_name = '%s' AND password = '%s'", user_name, password ])]
5017 find_first([ "firm_id = %s", firm_id ])] # unsafe!
5018
5019 After:
5020 find_first([ "user_name = ? AND password = ?", user_name, password ])]
5021 find_first([ "firm_id = ?", firm_id ])]
5022
5023 * Added CSV format for fixtures #272 [what-a-day]. (See the new and expanded documentation on fixtures for more information)
5024
5025 * Fixed fixtures using primary key fields called something else than "id" [dave]
5026
5027 * Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon]
5028
5029 * Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates]
5030
5031 * Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [Jeremy Kemper]
5032
5033 * Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable
5034
5035 * Fixed problems with primary keys and postgresql sequences (#230) [Tim Bates]
5036
5037 * Added reloading for associations under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development.
5038 This is turned on by default, but can be turned off with ActiveRecord::Base.reload_dependencies = false in production environments.
5039
5040 NOTE: This will only have an effect if you let the associations manage the requiring of model classes. All libraries loaded through
5041 require will be "forever" cached. You can, however, use ActiveRecord::Base.load_or_require("library") to get this behavior outside of the
5042 auto-loading associations.
5043
5044 * Added ERB capabilities to the fixture files for dynamic fixture generation. You don't need to do anything, just include ERB blocks like:
5045
5046 david:
5047 id: 1
5048 name: David
5049
5050 jamis:
5051 id: 2
5052 name: Jamis
5053
5054 <% for digit in 3..10 %>
5055 dev_<%= digit %>:
5056 id: <%= digit %>
5057 name: fixture_<%= digit %>
5058 <% end %>
5059
5060 * Changed the yaml fixture searcher to look in the root of the fixtures directory, so when you before could have something like:
5061
5062 fixtures/developers/fixtures.yaml
5063 fixtures/accounts/fixtures.yaml
5064
5065 ...you now need to do:
5066
5067 fixtures/developers.yaml
5068 fixtures/accounts.yaml
5069
5070 * Changed the fixture format from:
5071
5072 name: david
5073 data:
5074 id: 1
5075 name: David Heinemeier Hansson
5076 birthday: 1979-10-15
5077 profession: Systems development
5078 ---
5079 name: steve
5080 data:
5081 id: 2
5082 name: Steve Ross Kellock
5083 birthday: 1974-09-27
5084 profession: guy with keyboard
5085
5086 ...to:
5087
5088 david:
5089 id: 1
5090 name: David Heinemeier Hansson
5091 birthday: 1979-10-15
5092 profession: Systems development
5093
5094 steve:
5095 id: 2
5096 name: Steve Ross Kellock
5097 birthday: 1974-09-27
5098 profession: guy with keyboard
5099
5100 The change is NOT backwards compatible. Fixtures written in the old YAML style needs to be rewritten!
5101
5102 * All associations will now attempt to require the classes that they associate to. Relieving the need for most explicit 'require' statements.
5103
5104
5105 *1.1.0* (34)
5106
5107 * Added automatic fixture setup and instance variable availability. Fixtures can also be automatically
5108 instantiated in instance variables relating to their names using the following style:
5109
5110 class FixturesTest < Test::Unit::TestCase
5111 fixtures :developers # you can add more with comma separation
5112
5113 def test_developers
5114 assert_equal 3, @developers.size # the container for all the fixtures is automatically set
5115 assert_kind_of Developer, @david # works like @developers["david"].find
5116 assert_equal "David Heinemeier Hansson", @david.name
5117 end
5118 end
5119
5120 * Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional
5121 attributes. This is really useful when you have information that's only relevant to the join itself, such as a "added_on" column for an association
5122 between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back
5123 approach:
5124
5125 post.categories.push_with_attributes(category, :added_on => Date.today)
5126 post.categories.first.added_on # => Date.today
5127
5128 NOTE: The categories table doesn't have a added_on column, it's the categories_post join table that does!
5129
5130 * Fixed that :exclusively_dependent and :dependent can't be activated at the same time on has_many associations [Jeremy Kemper]
5131
5132 * Fixed that database passwords couldn't be all numeric [Jeremy Kemper]
5133
5134 * Fixed that calling id would create the instance variable for new_records preventing them from being saved correctly [Jeremy Kemper]
5135
5136 * Added sanitization feature to HasManyAssociation#find_all so it works just like Base.find_all [Sam Stephenson/bitsweat]
5137
5138 * Added that you can pass overlapping ids to find without getting duplicated records back [Jeremy Kemper]
5139
5140 * Added that Base.benchmark returns the result of the block [Jeremy Kemper]
5141
5142 * Fixed problem with unit tests on Windows with SQLite [paterno]
5143
5144 * Fixed that quotes would break regular non-yaml fixtures [Dmitry Sabanin/daft]
5145
5146 * Fixed fixtures on windows with line endings cause problems under unix / mac [Tobias Luetke]
5147
5148 * Added HasAndBelongsToManyAssociation#find(id) that'll search inside the collection and find the object or record with that id
5149
5150 * Added :conditions option to has_and_belongs_to_many that works just like the one on all the other associations
5151
5152 * Added AssociationCollection#clear to remove all associations from has_many and has_and_belongs_to_many associations without destroying the records [geech]
5153
5154 * Added type-checking and remove in 1-instead-of-N sql statements to AssociationCollection#delete [geech]
5155
5156 * Added a return of self to AssociationCollection#<< so appending can be chained, like project << Milestone.create << Milestone.create [geech]
5157
5158 * Added Base#hash and Base#eql? which means that all of the equality using features of array and other containers now works:
5159
5160 [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
5161
5162 * Added :uniq as an option to has_and_belongs_to_many which will automatically ensure that AssociateCollection#uniq is called
5163 before pulling records out of the association. This is especially useful for three-way (and above) has_and_belongs_to_many associations.
5164
5165 * Added AssociateCollection#uniq which is especially useful for has_and_belongs_to_many associations that can include duplicates,
5166 which is common on associations that also use metadata. Usage: post.categories.uniq
5167
5168 * Fixed respond_to? to use a subclass specific hash instead of an Active Record-wide one
5169
5170 * Fixed has_and_belongs_to_many to treat associations between classes in modules properly [Florian Weber]
5171
5172 * Added a NoMethod exception to be raised when query and writer methods are called for attributes that doesn't exist [geech]
5173
5174 * Added a more robust version of Fixtures that throws meaningful errors when on formatting issues [geech]
5175
5176 * Added Base#transaction as a compliment to Base.transaction for prettier use in instance methods [geech]
5177
5178 * Improved the speed of respond_to? by placing the dynamic methods lookup table in a hash [geech]
5179
5180 * Added that any additional fields added to the join table in a has_and_belongs_to_many association
5181 will be placed as attributes when pulling records out through has_and_belongs_to_many associations.
5182 This is helpful when have information about the association itself that you want available on retrival.
5183
5184 * Added better loading exception catching and RubyGems retries to the database adapters [alexeyv]
5185
5186 * Fixed bug with per-model transactions [daniel]
5187
5188 * Fixed Base#transaction so that it returns the result of the last expression in the transaction block [alexeyv]
5189
5190 * Added Fixture#find to find the record corresponding to the fixture id. The record
5191 class name is guessed by using Inflector#classify (also new) on the fixture directory name.
5192
5193 Before: Document.find(@documents["first"]["id"])
5194 After : @documents["first"].find
5195
5196 * Fixed that the table name part of column names ("TABLE.COLUMN") wasn't removed properly [Andreas Schwarz]
5197
5198 * Fixed a bug with Base#size when a finder_sql was used that didn't capitalize SELECT and FROM [geech]
5199
5200 * Fixed quoting problems on SQLite by adding quote_string to the AbstractAdapter that can be overwritten by the concrete
5201 adapters for a call to the dbm. [Andreas Schwarz]
5202
5203 * Removed RubyGems backup strategy for requiring SQLite-adapter -- if people want to use gems, they're already doing it with AR.
5204
5205
5206 *1.0.0 (35)*
5207
5208 * Added OO-style associations methods [Florian Weber]. Examples:
5209
5210 Project#milestones_count => Project#milestones.size
5211 Project#build_to_milestones => Project#milestones.build
5212 Project#create_for_milestones => Project#milestones.create
5213 Project#find_in_milestones => Project#milestones.find
5214 Project#find_all_in_milestones => Project#milestones.find_all
5215
5216 * Added serialize as a new class method to control when text attributes should be YAMLized or not. This means that automated
5217 serialization of hashes, arrays, and so on WILL NO LONGER HAPPEN (#10). You need to do something like this:
5218
5219 class User < ActiveRecord::Base
5220 serialize :settings
5221 end
5222
5223 This will assume that settings is a text column and will now YAMLize any object put in that attribute. You can also specify
5224 an optional :class_name option that'll raise an exception if a serialized object is retrieved as a descendent of a class not in
5225 the hierarchy. Example:
5226
5227 class User < ActiveRecord::Base
5228 serialize :settings, :class_name => "Hash"
5229 end
5230
5231 user = User.create("settings" => %w( one two three ))
5232 User.find(user.id).settings # => raises SerializationTypeMismatch
5233
5234 * Added the option to connect to a different database for one model at a time. Just call establish_connection on the class
5235 you want to have connected to another database than Base. This will automatically also connect decendents of that class
5236 to the different database [Renald Buter].
5237
5238 * Added transactional protection for Base#save. Validations can now check for values knowing that it happens in a transaction and callbacks
5239 can raise exceptions knowing that the save will be rolled back. [Suggested by Alexey Verkhovsky]
5240
5241 * Added column name quoting so reserved words, such as "references", can be used as column names [Ryan Platte]
5242
5243 * Added the possibility to chain the return of what happened inside a logged block [geech]:
5244
5245 This now works:
5246 log { ... }.map { ... }
5247
5248 Instead of doing:
5249 result = []
5250 log { result = ... }
5251 result.map { ... }
5252
5253 * Added "socket" option for the MySQL adapter, so you can change it to something else than "/tmp/mysql.sock" [Anna Lissa Cruz]
5254
5255 * Added respond_to? answers for all the attribute methods. So if Person has a name attribute retrieved from the table schema,
5256 person.respond_to? "name" will return true.
5257
5258 * Added Base.benchmark which can be used to aggregate logging and benchmark, so you can measure and represent multiple statements in a single block.
5259 Usage (hides all the SQL calls for the individual actions and calculates total runtime for them all):
5260
5261 Project.benchmark("Creating project") do
5262 project = Project.create("name" => "stuff")
5263 project.create_manager("name" => "David")
5264 project.milestones << Milestone.find_all
5265 end
5266
5267 * Added logging of invalid SQL statements [Suggested by Daniel Von Fange]
5268
5269 * Added alias Errors#[] for Errors#on, so you can now say person.errors["name"] to retrieve the errors for name [Andreas Schwarz]
5270
5271 * Added RubyGems require attempt if sqlite-ruby is not available through regular methods.
5272
5273 * Added compatibility with 2.x series of sqlite-ruby drivers. [Jamis Buck]
5274
5275 * Added type safety for association assignments, so a ActiveRecord::AssociationTypeMismatch will be raised if you attempt to
5276 assign an object that's not of the associated class. This cures the problem with nil giving id = 4 and fixnums giving id = 1 on
5277 mistaken association assignments. [Reported by Andreas Schwarz]
5278
5279 * Added the option to keep many fixtures in one single YAML document [what-a-day]
5280
5281 * Added the class method "inheritance_column" that can be overwritten to return the name of an alternative column than "type" for storing
5282 the type for inheritance hierarchies. [Dave Steinberg]
5283
5284 * Added [] and []= as an alternative way to access attributes when the regular methods have been overwritten [Dave Steinberg]
5285
5286 * Added the option to observer more than one class at the time by specifying observed_class as an array
5287
5288 * Added auto-id propagation support for tables with arbitrary primary keys that have autogenerated sequences associated with them
5289 on PostgreSQL. [Dave Steinberg]
5290
5291 * Changed that integer and floats set to "" through attributes= remain as NULL. This was especially a problem for scaffolding and postgresql. (#49)
5292
5293 * Changed the MySQL Adapter to rely on MySQL for its defaults for socket, host, and port [Andreas Schwarz]
5294
5295 * Changed ActionControllerError to decent from StandardError instead of Exception. It can now be caught by a generic rescue.
5296
5297 * Changed class inheritable attributes to not use eval [Caio Chassot]
5298
5299 * Changed Errors#add to now use "invalid" as the default message instead of true, which means full_messages work with those [Marcel Molina Jr]
5300
5301 * Fixed spelling on Base#add_on_boundry_breaking to Base#add_on_boundary_breaking (old naming still works) [Marcel Molina Jr.]
5302
5303 * Fixed that entries in the has_and_belongs_to_many join table didn't get removed when an associated object was destroyed.
5304
5305 * Fixed unnecessary calls to SET AUTOCOMMIT=0/1 for MySQL adapter [Andreas Schwarz]
5306
5307 * Fixed PostgreSQL defaults are now handled gracefully [Dave Steinberg]
5308
5309 * Fixed increment/decrement_counter are now atomic updates [Andreas Schwarz]
5310
5311 * Fixed the problems the Inflector had turning Attachment into attuchments and Cases into Casis [radsaq/Florian Gross]
5312
5313 * Fixed that cloned records would point attribute references on the parent object [Andreas Schwarz]
5314
5315 * Fixed SQL for type call on inheritance hierarchies [Caio Chassot]
5316
5317 * Fixed bug with typed inheritance [Florian Weber]
5318
5319 * Fixed a bug where has_many collection_count wouldn't use the conditions specified for that association
5320
5321
5322 *0.9.5*
5323
5324 * Expanded the table_name guessing rules immensely [Florian Green]. Documentation:
5325
5326 Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
5327 directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used
5328 to guess the table name from even when called on Reply. The guessing rules are as follows:
5329 * Class name ends in "x", "ch" or "ss": "es" is appended, so a Search class becomes a searches table.
5330 * Class name ends in "y" preceded by a consonant or "qu": The "y" is replaced with "ies",
5331 so a Category class becomes a categories table.
5332 * Class name ends in "fe": The "fe" is replaced with "ves", so a Wife class becomes a wives table.
5333 * Class name ends in "lf" or "rf": The "f" is replaced with "ves", so a Half class becomes a halves table.
5334 * Class name ends in "person": The "person" is replaced with "people", so a Salesperson class becomes a salespeople table.
5335 * Class name ends in "man": The "man" is replaced with "men", so a Spokesman class becomes a spokesmen table.
5336 * Class name ends in "sis": The "i" is replaced with an "e", so a Basis class becomes a bases table.
5337 * Class name ends in "tum" or "ium": The "um" is replaced with an "a", so a Datum class becomes a data table.
5338 * Class name ends in "child": The "child" is replaced with "children", so a NodeChild class becomes a node_children table.
5339 * Class name ends in an "s": No additional characters are added or removed.
5340 * Class name doesn't end in "s": An "s" is appended, so a Comment class becomes a comments table.
5341 * Class name with word compositions: Compositions are underscored, so CreditCard class becomes a credit_cards table.
5342 Additionally, the class-level table_name_prefix is prepended to the table_name and the table_name_suffix is appended.
5343 So if you have "myapp_" as a prefix, the table name guess for an Account class becomes "myapp_accounts".
5344
5345 You can also overwrite this class method to allow for unguessable links, such as a Mouse class with a link to a
5346 "mice" table. Example:
5347
5348 class Mouse < ActiveRecord::Base
5349 def self.table_name() "mice" end
5350 end
5351
5352 This conversion is now done through an external class called Inflector residing in lib/active_record/support/inflector.rb.
5353
5354 * Added find_all_in_collection to has_many defined collections. Works like this:
5355
5356 class Firm < ActiveRecord::Base
5357 has_many :clients
5358 end
5359
5360 firm.id # => 1
5361 firm.find_all_in_clients "revenue > 1000" # SELECT * FROM clients WHERE firm_id = 1 AND revenue > 1000
5362
5363 [Requested by Dave Thomas]
5364
5365 * Fixed finders for inheritance hierarchies deeper than one level [Florian Weber]
5366
5367 * Added add_on_boundry_breaking to errors to accompany add_on_empty as a default validation method. It's used like this:
5368
5369 class Person < ActiveRecord::Base
5370 protected
5371 def validation
5372 errors.add_on_boundry_breaking "password", 3..20
5373 end
5374 end
5375
5376 This will add an error to the tune of "is too short (minimum is 3 characters)" or "is too long (minimum is 20 characters)" if
5377 the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings.
5378
5379 * Implemented a clone method that works properly with AR. It returns a clone of the record that
5380 hasn't been assigned an id yet and is treated as a new record.
5381
5382 * Allow for domain sockets in PostgreSQL by not assuming localhost when no host is specified [Scott Barron]
5383
5384 * Fixed that bignums are saved properly instead of attempted to be YAMLized [Andreas Schwartz]
5385
5386 * Fixed a bug in the GEM where the rdoc options weren't being passed according to spec [Chad Fowler]
5387
5388 * Fixed a bug with the exclusively_dependent option for has_many
5389
5390
5391 *0.9.4*
5392
5393 * Correctly guesses the primary key when the class is inside a module [Dave Steinberg].
5394
5395 * Added [] and []= as alternatives to read_attribute and write_attribute [Dave Steinberg]
5396
5397 * has_and_belongs_to_many now accepts an :order key to determine in which order the collection is returned [radsaq].
5398
5399 * The ids passed to find and find_on_conditions are now automatically sanitized.
5400
5401 * Added escaping of plings in YAML content.
5402
5403 * Multi-parameter assigns where all the parameters are empty will now be set to nil instead of a new instance of their class.
5404
5405 * Proper type within an inheritance hierarchy is now ensured already at object initialization (instead of first at create)
5406
5407
5408 *0.9.3*
5409
5410 * Fixed bug with using a different primary key name together with has_and_belongs_to_many [Investigation by Scott]
5411
5412 * Added :exclusively_dependent option to the has_many association macro. The doc reads:
5413
5414 If set to true all the associated object are deleted in one SQL statement without having their
5415 before_destroy callback run. This should only be used on associations that depend solely on
5416 this class and don't need to do any clean-up in before_destroy. The upside is that it's much
5417 faster, especially if there's a counter_cache involved.
5418
5419 * Added :port key to connection options, so the PostgreSQL and MySQL adapters can connect to a database server
5420 running on another port than the default.
5421
5422 * Converted the new natural singleton methods that prevented AR objects from being saved by PStore
5423 (and hence be placed in a Rails session) to a module. [Florian Weber]
5424
5425 * Fixed the use of floats (was broken since 0.9.0+)
5426
5427 * Fixed PostgreSQL adapter so default values are displayed properly when used in conjunction with
5428 Action Pack scaffolding.
5429
5430 * Fixed booleans support for PostgreSQL (use real true/false on boolean fields instead of 0/1 on tinyints) [radsaq]
5431
5432
5433 *0.9.2*
5434
5435 * Added static method for instantly updating a record
5436
5437 * Treat decimal and numeric as Ruby floats [Andreas Schwartz]
5438
5439 * Treat chars as Ruby strings (fixes problem for Action Pack form helpers too)
5440
5441 * Removed debugging output accidently left in (which would screw web applications)
5442
5443
5444 *0.9.1*
5445
5446 * Added MIT license
5447
5448 * Added natural object-style assignment for has_and_belongs_to_many associations. Consider the following model:
5449
5450 class Event < ActiveRecord::Base
5451 has_one_and_belongs_to_many :sponsors
5452 end
5453
5454 class Sponsor < ActiveRecord::Base
5455 has_one_and_belongs_to_many :sponsors
5456 end
5457
5458 Earlier, you'd have to use synthetic methods for creating associations between two objects of the above class:
5459
5460 roskilde_festival.add_to_sponsors(carlsberg)
5461 roskilde_festival.remove_from_sponsors(carlsberg)
5462
5463 nike.add_to_events(world_cup)
5464 nike.remove_from_events(world_cup)
5465
5466 Now you can use regular array-styled methods:
5467
5468 roskilde_festival.sponsors << carlsberg
5469 roskilde_festival.sponsors.delete(carlsberg)
5470
5471 nike.events << world_cup
5472 nike.events.delete(world_cup)
5473
5474 * Added delete method for has_many associations. Using this will nullify an association between the has_many and the belonging
5475 object by setting the foreign key to null. Consider this model:
5476
5477 class Post < ActiveRecord::Base
5478 has_many :comments
5479 end
5480
5481 class Comment < ActiveRecord::Base
5482 belongs_to :post
5483 end
5484
5485 You could do something like:
5486
5487 funny_comment.has_post? # => true
5488 announcement.comments.delete(funny_comment)
5489 funny_comment.has_post? # => false
5490
5491
5492 *0.9.0*
5493
5494 * Active Record is now thread safe! (So you can use it with Cerise and WEBrick applications)
5495 [Implementation idea by Michael Neumann, debugging assistance by Jamis Buck]
5496
5497 * Improved performance by roughly 400% on a basic test case of pulling 100 records and querying one attribute.
5498 This brings the tax for using Active Record instead of "riding on the metal" (using MySQL-ruby C-driver directly) down to ~50%.
5499 Done by doing lazy type conversions and caching column information on the class-level.
5500
5501 * Added callback objects and procs as options for implementing the target for callback macros.
5502
5503 * Added "counter_cache" option to belongs_to that automates the usage of increment_counter and decrement_counter. Consider:
5504
5505 class Post < ActiveRecord::Base
5506 has_many :comments
5507 end
5508
5509 class Comment < ActiveRecord::Base
5510 belongs_to :post
5511 end
5512
5513 Iterating over 100 posts like this:
5514
5515 <% for post in @posts %>
5516 <%= post.title %> has <%= post.comments_count %> comments
5517 <% end %>
5518
5519 Will generate 100 SQL count queries -- one for each call to post.comments_count. If you instead add a "comments_count" int column
5520 to the posts table and rewrite the comments association macro with:
5521
5522 class Comment < ActiveRecord::Base
5523 belongs_to :post, :counter_cache => true
5524 end
5525
5526 Those 100 SQL count queries will be reduced to zero. Beware that counter caching is only appropriate for objects that begin life
5527 with the object it's specified to belong with and is destroyed like that as well. Typically objects where you would also specify
5528 :dependent => true. If your objects switch from one belonging to another (like a post that can be move from one category to another),
5529 you'll have to manage the counter yourself.
5530
5531 * Added natural object-style assignment for has_one and belongs_to associations. Consider the following model:
5532
5533 class Project < ActiveRecord::Base
5534 has_one :manager
5535 end
5536
5537 class Manager < ActiveRecord::Base
5538 belongs_to :project
5539 end
5540
5541 Earlier, assignments would work like following regardless of which way the assignment told the best story:
5542
5543 active_record.manager_id = david.id
5544
5545 Now you can do it either from the belonging side:
5546
5547 david.project = active_record
5548
5549 ...or from the having side:
5550
5551 active_record.manager = david
5552
5553 If the assignment happens from the having side, the assigned object is automatically saved. So in the example above, the
5554 project_id attribute on david would be set to the id of active_record, then david would be saved.
5555
5556 * Added natural object-style assignment for has_many associations [Florian Weber]. Consider the following model:
5557
5558 class Project < ActiveRecord::Base
5559 has_many :milestones
5560 end
5561
5562 class Milestone < ActiveRecord::Base
5563 belongs_to :project
5564 end
5565
5566 Earlier, assignments would work like following regardless of which way the assignment told the best story:
5567
5568 deadline.project_id = active_record.id
5569
5570 Now you can do it either from the belonging side:
5571
5572 deadline.project = active_record
5573
5574 ...or from the having side:
5575
5576 active_record.milestones << deadline
5577
5578 The milestone is automatically saved with the new foreign key.
5579
5580 * API CHANGE: Attributes for text (or blob or similar) columns will now have unknown classes stored using YAML instead of using
5581 to_s. (Known classes that won't be yamelized are: String, NilClass, TrueClass, FalseClass, Fixnum, Date, and Time).
5582 Likewise, data pulled out of text-based attributes will be attempted converged using Yaml if they have the "--- " header.
5583 This was primarily done to be enable the storage of hashes and arrays without wrapping them in aggregations, so now you can do:
5584
5585 user = User.find(1)
5586 user.preferences = { "background" => "black", "display" => large }
5587 user.save
5588
5589 User.find(1).preferences # => { "background" => "black", "display" => large }
5590
5591 Please note that this method should only be used when you don't care about representing the object in proper columns in
5592 the database. A money object consisting of an amount and a currency is still a much better fit for a value object done through
5593 aggregations than this new option.
5594
5595 * POSSIBLE CODE BREAKAGE: As a consequence of the lazy type conversions, it's a bad idea to reference the @attributes hash
5596 directly (it always was, but now it's paramount that you don't). If you do, you won't get the type conversion. So to implement
5597 new accessors for existing attributes, use read_attribute(attr_name) and write_attribute(attr_name, value) instead. Like this:
5598
5599 class Song < ActiveRecord::Base
5600 # Uses an integer of seconds to hold the length of the song
5601
5602 def length=(minutes)
5603 write_attribute("length", minutes * 60)
5604 end
5605
5606 def length
5607 read_attribute("length") / 60
5608 end
5609 end
5610
5611 The clever kid will notice that this opens a door to sidestep the automated type conversion by using @attributes directly.
5612 This is not recommended as read/write_attribute may be granted additional responsibilities in the future, but if you think
5613 you know what you're doing and aren't afraid of future consequences, this is an option.
5614
5615 * Applied a few minor bug fixes reported by Daniel Von Fange.
5616
5617
5618 *0.8.4*
5619
5620 _Reflection_
5621
5622 * Added ActiveRecord::Reflection with a bunch of methods and classes for reflecting in aggregations and associations.
5623
5624 * Added Base.columns and Base.content_columns which returns arrays of column description (type, default, etc) objects.
5625
5626 * Added Base#attribute_names which returns an array of names for the attributes available on the object.
5627
5628 * Added Base#column_for_attribute(name) which returns the column description object for the named attribute.
5629
5630
5631 _Misc_
5632
5633 * Added multi-parameter assignment:
5634
5635 # Instantiate objects for all attribute classes that needs more than one constructor parameter. This is done
5636 # by calling new on the column type or aggregation type (through composed_of) object with these parameters.
5637 # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
5638 # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
5639 # parenteses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
5640 # s for String, and a for Array.
5641
5642 This is incredibly useful for assigning dates from HTML drop-downs of month, year, and day.
5643
5644 * Fixed bug with custom primary key column name and Base.find on multiple parameters.
5645
5646 * Fixed bug with dependent option on has_one associations if there was no associated object.
5647
5648
5649 *0.8.3*
5650
5651 _Transactions_
5652
5653 * Added transactional protection for destroy (important for the new :dependent option) [Suggested by Carl Youngblood]
5654
5655 * Fixed so transactions are ignored on MyISAM tables for MySQL (use InnoDB to get transactions)
5656
5657 * Changed transactions so only exceptions will cause a rollback, not returned false.
5658
5659
5660 _Mapping_
5661
5662 * Added support for non-integer primary keys [Aredridel/earlier work by Michael Neumann]
5663
5664 User.find "jdoe"
5665 Product.find "PDKEY-INT-12"
5666
5667 * Added option to specify naming method for primary key column. ActiveRecord::Base.primary_key_prefix_type can either
5668 be set to nil, :table_name, or :table_name_with_underscore. :table_name will assume that Product class has a primary key
5669 of "productid" and :table_name_with_underscore will assume "product_id". The default nil will just give "id".
5670
5671 * Added an overwriteable primary_key method that'll instruct AR to the name of the
5672 id column [Aredridele/earlier work by Guan Yang]
5673
5674 class Project < ActiveRecord::Base
5675 def self.primary_key() "project_id" end
5676 end
5677
5678 * Fixed that Active Records can safely associate inside and out of modules.
5679
5680 class MyApplication::Account < ActiveRecord::Base
5681 has_many :clients # will look for MyApplication::Client
5682 has_many :interests, :class_name => "Business::Interest" # will look for Business::Interest
5683 end
5684
5685 * Fixed that Active Records can safely live inside modules [Aredridel]
5686
5687 class MyApplication::Account < ActiveRecord::Base
5688 end
5689
5690
5691 _Misc_
5692
5693 * Added freeze call to value object assignments to ensure they remain immutable [Spotted by Gavin Sinclair]
5694
5695 * Changed interface for specifying observed class in observers. Was OBSERVED_CLASS constant, now is
5696 observed_class() class method. This is more consistant with things like self.table_name(). Works like this:
5697
5698 class AuditObserver < ActiveRecord::Observer
5699 def self.observed_class() Account end
5700 def after_update(account)
5701 AuditTrail.new(account, "UPDATED")
5702 end
5703 end
5704
5705 [Suggested by Gavin Sinclair]
5706
5707 * Create new Active Record objects by setting the attributes through a block. Like this:
5708
5709 person = Person.new do |p|
5710 p.name = 'Freddy'
5711 p.age = 19
5712 end
5713
5714 [Suggested by Gavin Sinclair]
5715
5716
5717 *0.8.2*
5718
5719 * Added inheritable callback queues that can ensure that certain callback methods or inline fragments are
5720 run throughout the entire inheritance hierarchy. Regardless of whether a descendent overwrites the callback
5721 method:
5722
5723 class Topic < ActiveRecord::Base
5724 before_destroy :destroy_author, 'puts "I'm an inline fragment"'
5725 end
5726
5727 Learn more in link:classes/ActiveRecord/Callbacks.html
5728
5729 * Added :dependent option to has_many and has_one, which will automatically destroy associated objects when
5730 the holder is destroyed:
5731
5732 class Album < ActiveRecord::Base
5733 has_many :tracks, :dependent => true
5734 end
5735
5736 All the associated tracks are destroyed when the album is.
5737
5738 * Added Base.create as a factory that'll create, save, and return a new object in one step.
5739
5740 * Automatically convert strings in config hashes to symbols for the _connection methods. This allows you
5741 to pass the argument hashes directly from yaml. (Luke)
5742
5743 * Fixed the install.rb to include simple.rb [Spotted by Kevin Bullock]
5744
5745 * Modified block syntax to better follow our code standards outlined in
5746 http://www.rubyonrails.org/CodingStandards
5747
5748
5749 *0.8.1*
5750
5751 * Added object-level transactions [Thanks to Austin Ziegler for Transaction::Simple]
5752
5753 * Changed adapter-specific connection methods to use centralized ActiveRecord::Base.establish_connection,
5754 which is parametized through a config hash with symbol keys instead of a regular parameter list.
5755 This will allow for database connections to be opened in a more generic fashion. (Luke)
5756
5757 NOTE: This requires all *_connections to be updated! Read more in:
5758 http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000081
5759
5760 * Fixed SQLite adapter so objects fetched from has_and_belongs_to_many have proper attributes
5761 (t.name is now name). [Spotted by Garrett Rooney]
5762
5763 * Fixed SQLite adapter so dates are returned as Date objects, not Time objects [Spotted by Gavin Sinclair]
5764
5765 * Fixed requirement of date class, so date conversions are succesful regardless of whether you
5766 manually require date or not.
5767
5768
5769 *0.8.0*
5770
5771 * Added transactions
5772
5773 * Changed Base.find to also accept either a list (1, 5, 6) or an array of ids ([5, 7])
5774 as parameter and then return an array of objects instead of just an object
5775
5776 * Fixed method has_collection? for has_and_belongs_to_many macro to behave as a
5777 collection, not an association
5778
5779 * Fixed SQLite adapter so empty or nil values in columns of datetime, date, or time type
5780 aren't treated as current time [Spotted by Gavin Sinclair]
5781
5782
5783 *0.7.6*
5784
5785 * Fixed the install.rb to create the lib/active_record/support directory [Spotted by Gavin Sinclair]
5786 * Fixed that has_association? would always return true [Spotted by Daniel Von Fange]