Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 1007 lines (650 sloc) 33.16 kB
776af48 @tenderlove PostgreSQL hstore types are automatically deserialized from the datab…
tenderlove authored
1 ## Rails 4.0.0 (unreleased) ##
9b40f5c @rafaelfranca Copy edit [ci skip]
rafaelfranca authored
2
7042fe2 @rafaelfranca Deprecate passing a string as third argument of `add_index`
rafaelfranca authored
3 * Deprecate the possibility to pass a string as third argument of `add_index`.
4 Pass `unique: true` instead.
5
6 add_index(:users, :organization_id, unique: true)
7
8 *Rafael Mendonça França*
9
8fc5270 @rafaelfranca Raise an ArgumentError when passing an invalid option to add_index
rafaelfranca authored
10 * Raise an `ArgumentError` when passing an invalid option to `add_index`.
11
12 *Rafael Mendonça França*
13
a58cafe Fix find_in_batches against string IDs when start option is not speci…
Alexis Bernard authored
14 * Fix `find_in_batches` crashing when IDs are strings and start option is not specified.
15
16 *Alexis Bernard*
17
e7e59a7 @nikitug Fix `attributes_before_type_cast` for serialised attributes.
nikitug authored
18 * `AR::Base#attributes_before_type_cast` now returns unserialized values for serialized attributes.
19
20 *Nikita Afanasenko*
21
a7c3c90 @kennyj Fix #6951. Use query cache/uncache, when using not only database.yml …
kennyj authored
22 * Use query cache/uncache when using DATABASE_URL.
23 Fix #6951.
24
25 *kennyj*
26
300d080 @xuanxu ActiveRecord::Relation#none! method.
xuanxu authored
27 * Added `#none!` method for mutating `ActiveRecord::Relation` objects to a NullRelation.
28 It acts like `#none` but modifies relation in place.
29
30 *Juanjo Bazán*
31
1849665 @henrik Enable update_column(s) for the primary key attribute.
henrik authored
32 * Fix bug where `update_columns` and `update_column` would not let you update the primary key column.
33
34 *Henrik Nyh*
35
e4790a2 @senny raise `ArgumentError` when redefining the primary key column. Closes …
senny authored
36 * The `create_table` method raises an `ArgumentError` when the primary key column is redefined.
37 Fix #6378
38
39 *Yves Senn*
40
10f6f90 AR::AttributeMethods#[] raises AM::AttributeMissingError for missing …
Francesco Rodriguez authored
41 * `ActiveRecord::AttributeMethods#[]` raises `ActiveModel::MissingAttributeError`
42 error if the given attribute is missing. Fixes #5433.
43
44 class Person < ActiveRecord::Base
45 belongs_to :company
46 end
47
48 # Before:
49 person = Person.select('id').first
50 person[:name] # => nil
51 person.name # => ActiveModel::MissingAttributeError: missing_attribute: name
52 person[:company_id] # => nil
53 person.company # => nil
54
55 # After:
56 person = Person.select('id').first
57 person[:name] # => ActiveModel::MissingAttributeError: missing_attribute: name
58 person.name # => ActiveModel::MissingAttributeError: missing_attribute: name
59 person[:company_id] # => ActiveModel::MissingAttributeError: missing_attribute: company_id
60 person.company # => ActiveModel::MissingAttributeError: missing_attribute: company_id
61
62 *Francesco Rodriguez*
63
5d30e44 @pwnall Use the MySQL varbinary type when appropriate in migrations.
pwnall authored
64 * Small binary fields use the `VARBINARY` MySQL type, instead of `TINYBLOB`.
65
66 *Victor Costan*
67
f96b410 @veader Decode attributes pulled from URI.parse
veader authored
68 * Decode URI encoded attributes on database connection URLs.
69
70 *Shawn Veader*
71
eb72e62 @jonleighton Add Relation#find_or_create_by and friends
jonleighton authored
72 * Add `find_or_create_by`, `find_or_create_by!` and
73 `find_or_initialize_by` methods to `Relation`.
74
75 These are similar to the `first_or_create` family of methods, but
76 the behaviour when a record is created is slightly different:
77
78 User.where(first_name: 'Penélope').first_or_create
79
80 will execute:
81
82 User.where(first_name: 'Penélope').create
83
84 Causing all the `create` callbacks to execute within the context of
85 the scope. This could affect queries that occur within callbacks.
86
87 User.find_or_create_by(first_name: 'Penélope')
88
89 will execute:
90
91 User.create(first_name: 'Penélope')
92
93 Which obviously does not affect the scoping of queries within
94 callbacks.
95
0096f53 @jonleighton nodoc the first_or_create methods and document alternatives
jonleighton authored
96 The `find_or_create_by` version also reads better, frankly.
97
98 If you need to add extra attributes during create, you can do one of:
99
100 User.create_with(active: true).find_or_create_by(first_name: 'Jon')
101 User.find_or_create_by(first_name: 'Jon') { |u| u.active = true }
102
103 The `first_or_create` family of methods have been nodoc'ed in favour
104 of this API. They may be deprecated in the future but their
105 implementation is very small and it's probably not worth putting users
106 through lots of annoying deprecation warnings.
eb72e62 @jonleighton Add Relation#find_or_create_by and friends
jonleighton authored
107
108 *Jon Leighton*
109
f96b410 @veader Decode attributes pulled from URI.parse
veader authored
110 * Fix bug with presence validation of associations. Would incorrectly add duplicated errors
25262bc @scottwillson Fix bug with presence validation of associations.
scottwillson authored
111 when the association was blank. Bug introduced in 1fab518c6a75dac5773654646eb724a59741bc13.
112
113 *Scott Willson*
114
10f6f90 AR::AttributeMethods#[] raises AM::AttributeMissingError for missing …
Francesco Rodriguez authored
115 * Fix bug where sum(expression) returns string '0' for no matching records.
d207a33 @carlosantoniodasilva Move changelog entry from #7439 to the top [ci skip]
carlosantoniodasilva authored
116 Fixes #7439
117
118 *Tim Macfarlane*
119
54b3f41 @arturopie #7914 Add change of previous commit to CHANGELOG.md
arturopie authored
120 * PostgreSQL adapter correctly fetches default values when using multiple schemas and domains in a db. Fixes #7914
121
122 *Arturo Pie*
123
633ea6a @timsly learn ActiveRecord::QueryMethods#order work with hash arguments
timsly authored
124 * Learn ActiveRecord::QueryMethods#order work with hash arguments
125
126 When symbol or hash passed we convert it to Arel::Nodes::Ordering.
127 If we pass invalid direction(like name: :DeSc) ActiveRecord::QueryMethods#order will raise an exception
d207a33 @carlosantoniodasilva Move changelog entry from #7439 to the top [ci skip]
carlosantoniodasilva authored
128
633ea6a @timsly learn ActiveRecord::QueryMethods#order work with hash arguments
timsly authored
129 User.order(:name, email: :desc)
130 # SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC
131
132 *Tima Maslyuchenko*
133
bf4d6a2 @alexeymuranov Add CHANGELOG entry for "Fixtures" -> "FixtureSet"
alexeymuranov authored
134 * Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`.
135 Instances of this class normally hold a collection of fixtures (records)
136 loaded either from a single YAML file, or from a file and a folder
137 with the same name. This change make the class name singular and makes
138 the class easier to distinguish from the modules like
139 `ActiveRecord::TestFixtures`, which operates on multiple fixture sets,
140 or `DelegatingFixtures`, `::Fixtures`, etc.,
141 and from the class `ActiveRecord::Fixture`, which corresponds to a single
142 fixture.
143
144 *Alexey Muranov*
145
16e4a53 @senny PostgreSQL, quote table names when fetching the primary key. Closes #…
senny authored
146 * The postgres adapter now supports tables with capital letters.
147 Fix #5920
148
149 *Yves Senn*
150
d7d2284 @rafaelfranca Fix CHANGELOG entry [ci skip]
rafaelfranca authored
151 * `CollectionAssociation#count` returns `0` without querying if the
152 parent record is not persisted.
aa202ad Count returns 0 without querying if parent is not saved
Francesco Rodriguez authored
153
154 Before:
155
d7d2284 @rafaelfranca Fix CHANGELOG entry [ci skip]
rafaelfranca authored
156 person.pets.count
aa202ad Count returns 0 without querying if parent is not saved
Francesco Rodriguez authored
157 # SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" IS NULL
158 # => 0
159
160 After:
161
d7d2284 @rafaelfranca Fix CHANGELOG entry [ci skip]
rafaelfranca authored
162 person.pets.count
aa202ad Count returns 0 without querying if parent is not saved
Francesco Rodriguez authored
163 # fires without sql query
164 # => 0
165
166 *Francesco Rodriguez*
167
6e56a03 @lulalala Fix reset_counters() crashing on has_many :through associations.
lulalala authored
168 * Fix `reset_counters` crashing on `has_many :through` associations.
169 Fix #7822.
170
171 *lulalala*
172
144e869 @jonleighton Support for partial inserts.
jonleighton authored
173 * Support for partial inserts.
174
175 When inserting new records, only the fields which have been changed
176 from the defaults will actually be included in the INSERT statement.
177 The other fields will be populated by the database.
178
179 This is more efficient, and also means that it will be safe to
180 remove database columns without getting subsequent errors in running
181 app processes (so long as the code in those processes doesn't
182 contain any references to the removed column).
183
7efb1fe @jonleighton Rename the partial_updates config to partial_writes
jonleighton authored
184 The `partial_updates` configuration option is now renamed to
185 `partial_writes` to reflect the fact that it now impacts both inserts
186 and updates.
187
144e869 @jonleighton Support for partial inserts.
jonleighton authored
188 *Jon Leighton*
189
f31ea4d Add CHANGELOG entry and update the guide
John Foley authored
190 * Allow before and after validations to take an array of lifecycle events
191
192 *John Foley*
193
392eeec @jonleighton Support for specifying transaction isolation level
jonleighton authored
194 * Support for specifying transaction isolation level
195
196 If your database supports setting the isolation level for a transaction, you can set
197 it like so:
198
199 Post.transaction(isolation: :serializable) do
200 # ...
201 end
202
203 Valid isolation levels are:
204
205 * `:read_uncommitted`
206 * `:read_committed`
207 * `:repeatable_read`
208 * `:serializable`
209
210 You should consult the documentation for your database to understand the
211 semantics of these different levels:
212
213 * http://www.postgresql.org/docs/9.1/static/transaction-iso.html
214 * https://dev.mysql.com/doc/refman/5.0/en/set-transaction.html
215
216 An `ActiveRecord::TransactionIsolationError` will be raised if:
217
218 * The adapter does not support setting the isolation level
219 * You are joining an existing open transaction
220 * You are creating a nested (savepoint) transaction
221
222 The mysql, mysql2 and postgresql adapters support setting the transaction
223 isolation level. However, support is disabled for mysql versions below 5,
224 because they are affected by a bug (http://bugs.mysql.com/bug.php?id=39170)
225 which means the isolation level gets persisted outside the transaction.
226
227 *Jon Leighton*
228
1f4c89f @guilleiguaran Update changelogs to add entries about strong_parameters integration
guilleiguaran authored
229 * `ActiveModel::ForbiddenAttributesProtection` is included by default
230 in Active Record models. Check the docs of `ActiveModel::ForbiddenAttributesProtection`
231 for more details.
232
233 *Guillermo Iguaran*
234
235 * Remove integration between Active Record and
236 `ActiveModel::MassAssignmentSecurity`, `protected_attributes` gem
237 should be added to use `attr_accessible`/`attr_protected`. Mass
238 assignment options has been removed from all the AR methods that
f4a9d7d remove unnecessary entry and make minor edits to AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
239 used it (ex. `AR::Base.new`, `AR::Base.create`, `AR::Base#update_attributes`, etc).
1f4c89f @guilleiguaran Update changelogs to add entries about strong_parameters integration
guilleiguaran authored
240
241 *Guillermo Iguaran*
242
69e0e3f @rafaelfranca Improve the CHANGELOG entry for #6971
rafaelfranca authored
243 * Fix the return of querying with an empty hash.
244 Fix #6971.
245
246 User.where(token: {})
247
248 Before:
249
250 #=> SELECT * FROM users;
251
252 After:
253
254 #=> SELECT * FROM users WHERE 1 = 2;
255
256 *Damien Mathieu*
30a576f @dmathieu fix querying with an empty hash
dmathieu authored
257
c35a7d7 @rafaelfranca Use the CHANGELOG convention [ci skip]
rafaelfranca authored
258 * Fix creation of through association models when using `collection=[]`
259 on a `has_many :through` association from an unsaved model.
260 Fix #7661.
610b632 @ernie Fix collection= on hm:t join models when unsaved
ernie authored
261
262 *Ernie Miller*
263
5bb056d @kennyj Don't explain except normal CRUD sql.
kennyj authored
264 * Explain only normal CRUD sql (select / update / insert / delete).
c35a7d7 @rafaelfranca Use the CHANGELOG convention [ci skip]
rafaelfranca authored
265 Fix problem that explains unexplainable sql.
266 Closes #7544 #6458.
5bb056d @kennyj Don't explain except normal CRUD sql.
kennyj authored
267
268 *kennyj*
269
46873ae @al2o3cr refactor store_accessor
al2o3cr authored
270 * You can now override the generated accessor methods for stored attributes
271 and reuse the original behavior with `read_store_attribute` and `write_store_attribute`,
272 which are counterparts to `read_attribute` and `write_attribute`.
273
274 *Matt Jones*
275
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
276 * Accept belongs_to (including polymorphic) association keys in queries.
3da275c @beerlington Accept belongs_to assoc. keys in ActiveRecord queries
beerlington authored
277
278 The following queries are now equivalent:
279
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
280 Post.where(author: author)
281 Post.where(author_id: author)
3da275c @beerlington Accept belongs_to assoc. keys in ActiveRecord queries
beerlington authored
282
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
283 PriceEstimate.where(estimate_of: treasure)
284 PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: treasure)
3da275c @beerlington Accept belongs_to assoc. keys in ActiveRecord queries
beerlington authored
285
286 *Peter Brown*
287
ccc6910 @kennyj Use native mysqldump command for 'rake db:structure:dump'.
kennyj authored
288 * Use native `mysqldump` command instead of `structure_dump` method
289 when dumping the database structure to a sql file. Fixes #5547.
290
291 *kennyj*
292
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
293 * PostgreSQL inet and cidr types are converted to `IPAddr` objects.
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
294
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
295 *Dan McClain*
296
297 * PostgreSQL array type support. Any datatype can be used to create an
298 array column, with full migration and schema dumper support.
299
300 To declare an array column, use the following syntax:
301
302 create_table :table_with_arrays do |t|
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
303 t.integer :int_array, array: true
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
304 # integer[]
f4a9d7d remove unnecessary entry and make minor edits to AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
305 t.integer :int_array, array: true, length: 2
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
306 # smallint[]
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
307 t.string :string_array, array: true, length: 30
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
308 # char varying(30)[]
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
309 end
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
310
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
311 This respects any other migration detail (limits, defaults, etc).
254a324 @fxn ActiveRecord -> Active Record
fxn authored
312 Active Record will serialize and deserialize the array columns on
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
313 their way to and from the database.
314
315 One thing to note: PostgreSQL does not enforce any limits on the
316 number of elements, and any array can be multi-dimensional. Any
317 array that is multi-dimensional must be rectangular (each sub array
318 must have the same number of elements as its siblings).
319
320 If the `pg_array_parser` gem is available, it will be used when
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
321 parsing PostgreSQL's array representation.
4544d2b @danmcclain Moves column dump specific code to a module included in AbstractAdapter
danmcclain authored
322
323 *Dan McClain*
324
4f107da @ernie Raise MissingAttributeError on query methods
ernie authored
325 * Attribute predicate methods, such as `article.title?`, will now raise
326 `ActiveModel::MissingAttributeError` if the attribute being queried for
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
327 truthiness was not read from the database, instead of just returning `false`.
4f107da @ernie Raise MissingAttributeError on query methods
ernie authored
328
329 *Ernie Miller*
330
aaa33e6 @carlosantoniodasilva Improve latest AR and AP changelog entries
carlosantoniodasilva authored
331 * `ActiveRecord::SchemaDumper` uses Ruby 1.9 style hash, which means that the
332 schema.rb file will be generated using this new syntax from now on.
333
334 *Konstantin Shabanov*
b485b8a @etehtsea Dump schema using new style hash
etehtsea authored
335
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
336 * Map interval with precision to string datatype in PostgreSQL. Fixes #7518.
337
338 *Yves Senn*
f415475 @carlosantoniodasilva Add changelog entry for #7545: map interval with precision to string
carlosantoniodasilva authored
339
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
340 * Fix eagerly loading associations without primary keys. Fixes #4976.
341
342 *Kelley Reynolds*
d8fbfee @carlosantoniodasilva Add Changelog entry for #4976: fix eager load associations without pk…
carlosantoniodasilva authored
343
db8460c @sikachu Update Active Record CHANGELOG for #7419
sikachu authored
344 * Rails now raise an exception when you're trying to run a migration that has an invalid
345 file name. Only lower case letters, numbers, and '_' are allowed in migration's file name.
346 Please see #7419 for more details.
347
348 *Jan Bernacki*
349
46873ae @al2o3cr refactor store_accessor
al2o3cr authored
350 * Fix bug when calling `store_accessor` multiple times.
ddaeaef @rafaelfranca Add CHANGELOG entry for #7532 [ci skip]
rafaelfranca authored
351 Fixes #7532.
352
353 *Matt Jones*
354
355 * Fix store attributes that show the changes incorrectly.
356 Fixes #7532.
357
358 *Matt Jones*
359
c7d752f @elliterate Fix pluck when columns/tables are reserved words.
elliterate authored
360 * Fix `ActiveRecord::Relation#pluck` when columns or tables are reserved words.
361
362 *Ian Lesperance*
363
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
364 * Allow JSON columns to be created in PostgreSQL and properly encoded/decoded.
3b516b5 @guedes ActiveRecord support to PostgreSQL 9.2 JSON type
guedes authored
365 to/from database.
366
367 *Dickson S. Guedes*
368
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
369 * Fix time column type casting for invalid time string values to correctly return `nil`.
acf583a @adzap Update changelog with time column type casting fix
adzap authored
370
371 *Adam Meehan*
372
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
373 * Allow to pass Symbol or Proc into `:limit` option of #accepts_nested_attributes_for.
ff8f759 @Mik-die changelog #7449
Mik-die authored
374
375 *Mikhail Dieterle*
376
0ffe190 @sikachu Extract ActiveRecord::SessionStore from Rails
sikachu authored
377 * ActiveRecord::SessionStore has been extracted from Active Record as `activerecord-session_store`
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
378 gem. Please read the `README.md` file on the gem for the usage.
379
380 *Prem Sichanugrist*
0ffe190 @sikachu Extract ActiveRecord::SessionStore from Rails
sikachu authored
381
ff0d9b9 @Pliny reset_counters() was crashing when there were multiple belongs_to ass…
Pliny authored
382 * Fix `reset_counters` when there are multiple `belongs_to` association with the
383 same foreign key and one of them have a counter cache.
384 Fixes #5200.
385
386 *Dave Desrochers*
387
57bef99 @kennyj Use instance_accessor: false instead of instance_writer.
kennyj authored
388 * `serialized_attributes` and `_attr_readonly` become class method only. Instance reader methods are deprecated.
389
390 *kennyj*
391
55d943c @rafaelfranca Add CHANGELOG entry for #6986
rafaelfranca authored
392 * Round usec when comparing timestamp attributes in the dirty tracking.
393 Fixes #6975.
394
395 *kennyj*
396
c9c5566 @brainopia Use inversed parent for first and last child of has_many association
brainopia authored
397 * Use inversed parent for first and last child of has_many association.
398
399 *Ravil Bayramgalin*
400
53ca22f @aripollak Fix occasional microsecond conversion inaccuracy
aripollak authored
401 * Fix Column.microseconds and Column.fast_string_to_date to avoid converting
402 timestamp seconds to a float, since it occasionally results in inaccuracies
403 with microsecond-precision times. Fixes #7352.
404
405 *Ari Pollak*
406
fb66521 @csmuc Call super to nullify the reference to the original errors object in …
csmuc authored
407 * Fix AR#dup to nullify the validation errors in the dup'ed object. Previously the original
408 and the dup'ed object shared the same errors.
409
1a6b082 @ugisozols Fix incorrect markdown by removing extra space.
ugisozols authored
410 *Christian Seiler*
fb66521 @csmuc Call super to nullify the reference to the original errors object in …
csmuc authored
411
dd64f0a @carlosantoniodasilva Move changelog entry to the top [ci skip]
carlosantoniodasilva authored
412 * Raise `ArgumentError` if list of attributes to change is empty in `update_all`.
413
414 *Roman Shatsov*
415
a4801a7 @daveyeu Restore state on create when ActiveRecord::RecordInvalid is raised
daveyeu authored
416 * Fix AR#create to return an unsaved record when AR::RecordInvalid is
417 raised. Fixes #3217.
418
419 *Dave Yeu*
420
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
421 * Fixed table name prefix that is generated in engines for namespaced models.
422
21b5b6a @morgoth Added changelog entry for table name prefix fix [ci skip]
morgoth authored
423 *Wojciech Wnętrzak*
424
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
425 * Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load`.
e7e8656 @rafaelfranca Update changelog
rafaelfranca authored
426 Fixes #4772.
427
428 *Seamus Abshere*
429
bf2df6e @jonleighton Allow Relation#merge to take a proc.
jonleighton authored
430 * Allow Relation#merge to take a proc.
431
432 This was requested by DHH to allow creating of one's own custom
433 association macros.
434
435 For example:
436
437 module Commentable
438 def has_many_comments(extra)
439 has_many :comments, -> { where(:foo).merge(extra) }
440 end
441 end
442
443 class Post < ActiveRecord::Base
444 extend Commentable
445 has_many_comments -> { where(:bar) }
446 end
447
448 *Jon Leighton*
449
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
450 * Add CollectionProxy#scope.
0e1cafc @jonleighton Add CollectionProxy#scope
jonleighton authored
451
452 This can be used to get a Relation from an association.
453
454 Previously we had a #scoped method, but we're deprecating that for
455 AR::Base, so it doesn't make sense to have it here.
456
457 This was requested by DHH, to facilitate code like this:
458
459 Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do
460 @topics = @project.topics.scope
461 @todolists = @project.todolists.scope
462 @attachments = @project.attachments.scope
463 @documents = @project.documents.scope
464 end
465
466 *Jon Leighton*
467
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
468 * Add `Relation#load`.
437851e @jonleighton Add `Relation#load`
jonleighton authored
469
470 This method explicitly loads the records and then returns `self`.
471
472 Rather than deciding between "do I want an array or a relation?",
473 most people are actually asking themselves "do I want to eager load
474 or lazy load?" Therefore, this method provides a way to explicitly
475 eager-load without having to switch from a `Relation` to an array.
476
477 Example:
478
479 @posts = Post.where(published: true).load
480
481 *Jon Leighton*
482
77fbe1c @rafaelfranca Add missing CHANGELOG entry removed by mistake at 7f3b475 [ci skip]
rafaelfranca authored
483 * `Relation#order`: make new order prepend old one.
484
485 User.order("name asc").order("created_at desc")
486 # SELECT * FROM users ORDER BY created_at desc, name asc
487
488 This also affects order defined in `default_scope` or any kind of associations.
489
490 *Bogdan Gusiev*
491
0a6833b @jonleighton reinstate changelog that seems to have been accidentally deleted o_O
jonleighton authored
492 * `Model.all` now returns an `ActiveRecord::Relation`, rather than an
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
493 array of records. Use `Relation#to_a` if you really want an array.
0a6833b @jonleighton reinstate changelog that seems to have been accidentally deleted o_O
jonleighton authored
494
495 In some specific cases, this may cause breakage when upgrading.
496 However in most cases the `ActiveRecord::Relation` will just act as a
497 lazy-loaded array and there will be no problems.
498
499 Note that calling `Model.all` with options (e.g.
500 `Model.all(conditions: '...')` was already deprecated, but it will
501 still return an array in order to make the transition easier.
502
503 `Model.scoped` is deprecated in favour of `Model.all`.
504
505 `Relation#all` still returns an array, but is deprecated (since it
506 would serve no purpose if we made it return a `Relation`).
507
508 *Jon Leighton*
509
4efebde @jonleighton Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.
jonleighton authored
510 * `:finder_sql` and `:counter_sql` options on collection associations
511 are deprecated. Please transition to using scopes.
512
513 *Jon Leighton*
514
515 * `:insert_sql` and `:delete_sql` options on `has_and_belongs_to_many`
516 associations are deprecated. Please transition to using `has_many
65ce6fb improve AR CHANGELOG [ci skip]
Francesco Rodriguez authored
517 :through`.
4efebde @jonleighton Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.
jonleighton authored
518
519 *Jon Leighton*
520
77fbe1c @rafaelfranca Add missing CHANGELOG entry removed by mistake at 7f3b475 [ci skip]
rafaelfranca authored
521 * Added `#update_columns` method which updates the attributes from
522 the passed-in hash without calling save, hence skipping validations and
523 callbacks. `ActiveRecordError` will be raised when called on new objects
524 or when at least one of the attributes is marked as read only.
525
526 post.attributes # => {"id"=>2, "title"=>"My title", "body"=>"My content", "author"=>"Peter"}
527 post.update_columns(title: 'New title', author: 'Sebastian') # => true
528 post.attributes # => {"id"=>2, "title"=>"New title", "body"=>"My content", "author"=>"Sebastian"}
529
530 *Sebastian Martinez + Rafael Mendonça França*
531
e243a8a @josevalim Update changelog for migration generator change
josevalim authored
532 * The migration generator now creates a join table with (commented) indexes every time
533 the migration name contains the word `join_table`:
534
2470501 @josevalim Use attributes instead of table names in migration example
josevalim authored
535 rails g migration create_join_table_for_artists_and_musics artist_id:index music_id
e243a8a @josevalim Update changelog for migration generator change
josevalim authored
536
537 *Aleksey Magusev*
538
17d2115 @lexmag Add changelog entry for references statements
lexmag authored
539 * Add `add_reference` and `remove_reference` schema statements. Aliases, `add_belongs_to`
540 and `remove_belongs_to` are acceptable. References are reversible.
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
541
48fe382 @carlosantoniodasilva Update release notes with AR::Relation#inspect change [ci skip]
carlosantoniodasilva authored
542 Examples:
17d2115 @lexmag Add changelog entry for references statements
lexmag authored
543
544 # Create a user_id column
545 add_reference(:products, :user)
48fe382 @carlosantoniodasilva Update release notes with AR::Relation#inspect change [ci skip]
carlosantoniodasilva authored
546 # Create a supplier_id, supplier_type columns and appropriate index
17d2115 @lexmag Add changelog entry for references statements
lexmag authored
547 add_reference(:products, :supplier, polymorphic: true, index: true)
548 # Remove polymorphic reference
549 remove_reference(:products, :supplier, polymorphic: true)
550
551 *Aleksey Magusev*
552
ab72040 @carlosantoniodasilva Update AR and AP changelogs [ci skip]
carlosantoniodasilva authored
553 * Add `:default` and `:null` options to `column_exists?`.
554
555 column_exists?(:testings, :taggable_id, :integer, null: false)
556 column_exists?(:testings, :taggable_type, :string, default: 'Photo')
557
558 *Aleksey Magusev*
559
07314e6 @jonleighton Show the records in Relation#inspect
jonleighton authored
560 * `ActiveRecord::Relation#inspect` now makes it clear that you are
561 dealing with a `Relation` object rather than an array:.
ab72040 @carlosantoniodasilva Update AR and AP changelogs [ci skip]
carlosantoniodasilva authored
562
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
563 User.where(age: 30).inspect
c046a29 @ayrton Update activerecord/CHANGELOG.md
ayrton authored
564 # => <ActiveRecord::Relation [#<User ...>, #<User ...>, ...]>
05c7e0a @bcardarella Remove ActiveRelation#inspect
bcardarella authored
565
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
566 User.where(age: 30).to_a.inspect
c046a29 @ayrton Update activerecord/CHANGELOG.md
ayrton authored
567 # => [#<User ...>, #<User ...>]
07314e6 @jonleighton Show the records in Relation#inspect
jonleighton authored
568
7d0053e @dmathieu Limit the number of records in Relation#inspect
dmathieu authored
569 The number of records displayed will be limited to 10.
570
571 *Brian Cardarella, Jon Leighton & Damien Mathieu*
05c7e0a @bcardarella Remove ActiveRelation#inspect
bcardarella authored
572
aafa00f @rafaelfranca Unify the collation API for the database adpters
rafaelfranca authored
573 * Add `collation` and `ctype` support to PostgreSQL. These are available for PostgreSQL 8.4 or later.
8fe458a @kennyj Added an entry about fda24312d3 in the CHANGELOG.
kennyj authored
574 Example:
575
c046a29 @ayrton Update activerecord/CHANGELOG.md
ayrton authored
576 development:
577 adapter: postgresql
578 host: localhost
579 database: rails_development
580 username: foo
581 password: bar
582 encoding: UTF8
583 collation: ja_JP.UTF8
584 ctype: ja_JP.UTF8
8fe458a @kennyj Added an entry about fda24312d3 in the CHANGELOG.
kennyj authored
585
586 *kennyj*
587
9feda92 AR has a subclass of AM:PresenceValidator.
Brent Wheeldon & Nick Monje authored
588 * Changed validates_presence_of on an association so that children objects
589 do not validate as being present if they are marked for destruction. This
590 prevents you from saving the parent successfully and thus putting the parent
591 in an invalid state.
592
593 *Nick Monje & Brent Wheeldon*
594
359592b @flexoid exists?(false) returns false
flexoid authored
595 * `FinderMethods#exists?` now returns `false` with the `false` argument.
596
597 *Egor Lynko*
598
6657ec9 @tonywok Allow precision option for postgresql datetimes
tonywok authored
599 * Added support for specifying the precision of a timestamp in the postgresql
600 adapter. So, instead of having to incorrectly specify the precision using the
601 `:limit` option, you may use `:precision`, as intended. For example, in a migration:
602
603 def change
604 create_table :foobars do |t|
605 t.timestamps :precision => 0
606 end
607 end
608
609 *Tony Schneider*
610
215d41d @carlosantoniodasilva Update 4.0 Release Notes with changelogs [ci skip]
carlosantoniodasilva authored
611 * Allow `ActiveRecord::Relation#pluck` to accept multiple columns. Returns an
9298d60 @carlosantoniodasilva Fix changelog typo [ci skip]
carlosantoniodasilva authored
612 array of arrays containing the typecasted values:
e5cd300 @carlosantoniodasilva Add changelog entry and guide updates for pluck with multiple columns
carlosantoniodasilva authored
613
614 Person.pluck(:id, :name)
615 # SELECT people.id, people.name FROM people
616 # [[1, 'David'], [2, 'Jeremy'], [3, 'Jose']]
617
618 *Jeroen van Ingen & Carlos Antonio da Silva*
619
4649294 @pixeltrix Improve the derivation of HABTM assocation join table names
pixeltrix authored
620 * Improve the derivation of HABTM join table name to take account of nesting.
621 It now takes the table names of the two models, sorts them lexically and
622 then joins them, stripping any common prefix from the second table name.
623
624 Some examples:
625
626 Top level models (Category <=> Product)
627 Old: categories_products
628 New: categories_products
629
630 Top level models with a global table_name_prefix (Category <=> Product)
631 Old: site_categories_products
632 New: site_categories_products
633
634 Nested models in a module without a table_name_prefix method (Admin::Category <=> Admin::Product)
635 Old: categories_products
636 New: categories_products
637
638 Nested models in a module with a table_name_prefix method (Admin::Category <=> Admin::Product)
639 Old: categories_products
640 New: admin_categories_products
641
642 Nested models in a parent model (Catalog::Category <=> Catalog::Product)
643 Old: categories_products
644 New: catalog_categories_products
645
646 Nested models in different parent models (Catalog::Category <=> Content::Page)
647 Old: categories_pages
648 New: catalog_categories_content_pages
649
650 *Andrew White*
651
215d41d @carlosantoniodasilva Update 4.0 Release Notes with changelogs [ci skip]
carlosantoniodasilva authored
652 * Move HABTM validity checks to `ActiveRecord::Reflection`. One side effect of
4649294 @pixeltrix Improve the derivation of HABTM assocation join table names
pixeltrix authored
653 this is to move when the exceptions are raised from the point of declaration
654 to when the association is built. This is consistant with other association
655 validity checks.
656
657 *Andrew White*
658
8593964 @carlosantoniodasilva Refactor and use class_attribute
carlosantoniodasilva authored
659 * Added `stored_attributes` hash which contains the attributes stored using
215d41d @carlosantoniodasilva Update 4.0 Release Notes with changelogs [ci skip]
carlosantoniodasilva authored
660 `ActiveRecord::Store`. This allows you to retrieve the list of attributes
8593964 @carlosantoniodasilva Refactor and use class_attribute
carlosantoniodasilva authored
661 you've defined.
757f723 @tilsammans Remember the stored attributes in a config attribute.
tilsammans authored
662
8593964 @carlosantoniodasilva Refactor and use class_attribute
carlosantoniodasilva authored
663 class User < ActiveRecord::Base
664 store :settings, accessors: [:color, :homepage]
665 end
666
667 User.stored_attributes[:settings] # [:color, :homepage]
668
669 *Joost Baaij & Carlos Antonio da Silva*
757f723 @tilsammans Remember the stored attributes in a config attribute.
tilsammans authored
670
052e415 @kennyj Change minimum (default) log level in PostgreSQL to warning.
kennyj authored
671 * PostgreSQL default log level is now 'warning', to bypass the noisy notice
672 messages. You can change the log level using the `min_messages` option
673 available in your config/database.yml.
674
675 *kennyj*
676
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
677 * Add uuid datatype support to PostgreSQL adapter.
678
679 *Konstantin Shabanov*
508834c @rafaelfranca Add CHANGELOG entry to the uuid datatype support to PostgreSQL adpter
rafaelfranca authored
680
03f2249 @josevalim Use . instead of :: for class methods, add CHANGELOG entries
josevalim authored
681 * Added `ActiveRecord::Migration.check_pending!` that raises an error if
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
682 migrations are pending.
683
684 *Richard Schneeman*
03f2249 @josevalim Use . instead of :: for class methods, add CHANGELOG entries
josevalim authored
685
4faaa81 @marcandre + ActiveRecord::Base#destroy!
marcandre authored
686 * Added `#destroy!` which acts like `#destroy` but will raise an
687 `ActiveRecord::RecordNotDestroyed` exception instead of returning `false`.
688
689 *Marc-André Lafortune*
690
f9cb645 @carlosantoniodasilva Yield only one argument instead of splatting.
carlosantoniodasilva authored
691 * Allow blocks for `count` with `ActiveRecord::Relation`, to work similar as
692 `Array#count`:
693
c51fb02 @carlosantoniodasilva Fix changelog example for count method with block [ci skip]
carlosantoniodasilva authored
694 Person.where("age > 26").count { |person| person.gender == 'female' }
f9cb645 @carlosantoniodasilva Yield only one argument instead of splatting.
carlosantoniodasilva authored
695
696 *Chris Finne & Carlos Antonio da Silva*
697
39f0698 Add support for CollectionAssociation#delete by Fixnum or String
Francesco Rodriguez authored
698 * Added support to `CollectionAssociation#delete` for passing `fixnum`
699 or `string` values as record ids. This finds the records responding
700 to the `id` and executes delete on them.
701
702 class Person < ActiveRecord::Base
703 has_many :pets
704 end
705
706 person.pets.delete("1") # => [#<Pet id: 1>]
707 person.pets.delete(2, 3) # => [#<Pet id: 2>, #<Pet id: 3>]
708
709 *Francesco Rodriguez*
710
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
711 * Deprecated most of the 'dynamic finder' methods. All dynamic methods
712 except for `find_by_...` and `find_by_...!` are deprecated. Here's
713 how you can rewrite the code:
714
715 * `find_all_by_...` can be rewritten using `where(...)`
716 * `find_last_by_...` can be rewritten using `where(...).last`
717 * `scoped_by_...` can be rewritten using `where(...)`
718 * `find_or_initialize_by_...` can be rewritten using
719 `where(...).first_or_initialize`
720 * `find_or_create_by_...` can be rewritten using
eb72e62 @jonleighton Add Relation#find_or_create_by and friends
jonleighton authored
721 `find_or_create_by(...)` or where(...).first_or_create`
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
722 * `find_or_create_by_...!` can be rewritten using
eb72e62 @jonleighton Add Relation#find_or_create_by and friends
jonleighton authored
723 `find_or_create_by!(...) or `where(...).first_or_create!`
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
724
725 The implementation of the deprecated dynamic finders has been moved
17bb324 @jonleighton Renaming active_record_deprecated_finders to activerecord-deprecated_…
jonleighton authored
726 to the `activerecord-deprecated_finders` gem. See below for details.
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
727
728 *Jon Leighton*
729
730 * Deprecated the old-style hash based finder API. This means that
731 methods which previously accepted "finder options" no longer do. For
732 example this:
733
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
734 Post.find(:all, conditions: { comments_count: 10 }, limit: 5)
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
735
736 Should be rewritten in the new style which has existed since Rails 3:
737
738 Post.where(comments_count: 10).limit(5)
739
740 Note that as an interim step, it is possible to rewrite the above as:
741
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
742 Post.all.merge(where: { comments_count: 10 }, limit: 5)
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
743
744 This could save you a lot of work if there is a lot of old-style
745 finder usage in your application.
746
3205c76 @jonleighton Changelog and doc updates for the previous changes.
jonleighton authored
747 `Relation#merge` now accepts a hash of
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
748 options, but they must be identical to the names of the equivalent
749 finder method. These are mostly identical to the old-style finder
750 option names, except in the following cases:
751
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
752 * `:conditions` becomes `:where`.
753 * `:include` becomes `:includes`.
754 * `:extend` becomes `:extending`.
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
755
756 The code to implement the deprecated features has been moved out to
17bb324 @jonleighton Renaming active_record_deprecated_finders to activerecord-deprecated_…
jonleighton authored
757 the `activerecord-deprecated_finders` gem. This gem is a dependency
103ce30 @jonleighton add changelogs about deprecated stuff [ci skip]
jonleighton authored
758 of Active Record in Rails 4.0. It will no longer be a dependency
759 from Rails 4.1, but if your app relies on the deprecated features
760 then you can add it to your own Gemfile. It will be maintained by
761 the Rails core team until Rails 5.0 is released.
762
763 *Jon Leighton*
764
a8b370f @iGEL Don't destroy readonly models
iGEL authored
765 * It's not possible anymore to destroy a model marked as read only.
766
767 *Johannes Barre*
768
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
769 * Added ability to ActiveRecord::Relation#from to accept other ActiveRecord::Relation objects.
64872d1 @RStankov Relation#from to accept other Relation objects
RStankov authored
770
771 Record.from(subquery)
772 Record.from(subquery, :a)
773
774 *Radoslav Stankov*
775
3c0bf04 @Antiarchitect Custom coders support for ActiveRecord::Store. JSON, YAML, Marshal ca…
Antiarchitect authored
776 * Added custom coders support for ActiveRecord::Store. Now you can set
777 your custom coder like this:
778
779 store :settings, accessors: [ :color, :homepage ], coder: JSON
780
781 *Andrey Voronkov*
776af48 @tenderlove PostgreSQL hstore types are automatically deserialized from the datab…
tenderlove authored
782
2054a17 @mipearson Changelog entry regarding mysql(2) STRICT_ALL_TABLES
mipearson authored
783 * `mysql` and `mysql2` connections will set `SQL_MODE=STRICT_ALL_TABLES` by
784 default to avoid silent data loss. This can be disabled by specifying
785 `strict: false` in your `database.yml`.
786
787 *Michael Pearson*
788
66b9e4c @mhfs Adding note about `first` and `take` to the changelog
mhfs authored
789 * Added default order to `first` to assure consistent results among
bf4d6a2 @alexeymuranov Add CHANGELOG entry for "Fixtures" -> "FixtureSet"
alexeymuranov authored
790 different database engines. Introduced `take` as a replacement to
66b9e4c @mhfs Adding note about `first` and `take` to the changelog
mhfs authored
791 the old behavior of `first`.
792
793 *Marcelo Silveira*
794
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
795 * Added an `:index` option to automatically create indexes for references
ca0af82 @joshuap Automatically create indexes for references/belongs_to statements in …
joshuap authored
796 and belongs_to statements in migrations.
797
798 The `references` and `belongs_to` methods now support an `index`
799 option that receives either a boolean value or an options hash
800 that is identical to options available to the add_index method:
801
802 create_table :messages do |t|
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
803 t.references :person, index: true
ca0af82 @joshuap Automatically create indexes for references/belongs_to statements in …
joshuap authored
804 end
805
806 Is the same as:
807
808 create_table :messages do |t|
809 t.references :person
810 end
811 add_index :messages, :person_id
812
813 Generators have also been updated to use the new syntax.
814
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
815 *Joshua Wood*
ca0af82 @joshuap Automatically create indexes for references/belongs_to statements in …
joshuap authored
816
8c2c605 @jonleighton Add bang versions of relation query methods.
jonleighton authored
817 * Added bang methods for mutating `ActiveRecord::Relation` objects.
818 For example, while `foo.where(:bar)` will return a new object
819 leaving `foo` unchanged, `foo.where!(:bar)` will mutate the foo
820 object
821
822 *Jon Leighton*
823
13b3c77 @jonleighton Add Relation#find_by and Relation#find_by!
jonleighton authored
824 * Added `#find_by` and `#find_by!` to mirror the functionality
825 provided by dynamic finders in a way that allows dynamic input more
826 easily:
827
828 Post.find_by name: 'Spartacus', rating: 4
829 Post.find_by "published_at < ?", 2.weeks.ago
830 Post.find_by! name: 'Spartacus'
831
832 *Jon Leighton*
833
bb2e2d8 @guilleiguaran CHANGELOG entry for AR#slice
guilleiguaran authored
834 * Added ActiveRecord::Base#slice to return a hash of the given methods with
835 their names as keys and returned values as values.
836
837 *Guillermo Iguaran*
838
0a12a5f @jonleighton Deprecate eager-evaluated scopes.
jonleighton authored
839 * Deprecate eager-evaluated scopes.
840
841 Don't use this:
842
843 scope :red, where(color: 'red')
844 default_scope where(color: 'red')
845
846 Use this:
847
848 scope :red, -> { where(color: 'red') }
849 default_scope { where(color: 'red') }
850
851 The former has numerous issues. It is a common newbie gotcha to do
852 the following:
853
854 scope :recent, where(published_at: Time.now - 2.weeks)
855
856 Or a more subtle variant:
857
858 scope :recent, -> { where(published_at: Time.now - 2.weeks) }
859 scope :recent_red, recent.where(color: 'red')
860
861 Eager scopes are also very complex to implement within Active
862 Record, and there are still bugs. For example, the following does
863 not do what you expect:
864
865 scope :remove_conditions, except(:where)
866 where(...).remove_conditions # => still has conditions
867
868 *Jon Leighton*
869
dde3058 @carlosantoniodasilva Expand changelog and upgrading rails guide with IdentityMap info
carlosantoniodasilva authored
870 * Remove IdentityMap
871
872 IdentityMap has never graduated to be an "enabled-by-default" feature, due
873 to some inconsistencies with associations, as described in this commit:
874
875 https://github.com/rails/rails/commit/302c912bf6bcd0fa200d964ec2dc4a44abe328a6
876
877 Hence the removal from the codebase, until such issues are fixed.
878
879 *Carlos Antonio da Silva*
a8dd21d @carlosantoniodasilva Remove IdentityMap
carlosantoniodasilva authored
880
46c1217 @kennyj Add entry for schema cache dump to CHANGELOG.md.
kennyj authored
881 * Added the schema cache dump feature.
882
883 `Schema cache dump` feature was implemetend. This feature can dump/load internal state of `SchemaCache` instance
884 because we want to boot rails more quickly when we have many models.
885
886 Usage notes:
887
888 1) execute rake task.
889 RAILS_ENV=production bundle exec rake db:schema:cache:dump
890 => generate db/schema_cache.dump
891
79dc922 @kennyj Change AR's CHANGELOG, because it is related to e35c67ae0f920011a2440…
kennyj authored
892 2) add config.active_record.use_schema_cache_dump = true in config/production.rb. BTW, true is default.
46c1217 @kennyj Add entry for schema cache dump to CHANGELOG.md.
kennyj authored
893
894 3) boot rails.
895 RAILS_ENV=production bundle exec rails server
aa9b647 @kennyj Update CHANGELOG to fix wrong extension.
kennyj authored
896 => use db/schema_cache.dump
46c1217 @kennyj Add entry for schema cache dump to CHANGELOG.md.
kennyj authored
897
898 4) If you remove clear dumped cache, execute rake task.
899 RAILS_ENV=production bundle exec rake db:schema:cache:clear
900 => remove db/schema_cache.dump
901
902 *kennyj*
903
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
904 * Added support for partial indices to PostgreSQL adapter.
d70e023 @mhfs Added where option to add_index to support postgresql partial indices
mhfs authored
905
906 The `add_index` method now supports a `where` option that receives a
907 string with the partial index criteria.
908
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
909 add_index(:accounts, :code, where: 'active')
d70e023 @mhfs Added where option to add_index to support postgresql partial indices
mhfs authored
910
8781b26 @rafaelfranca Sync CHANGELOGs [ci skip]
rafaelfranca authored
911 Generates
d70e023 @mhfs Added where option to add_index to support postgresql partial indices
mhfs authored
912
8781b26 @rafaelfranca Sync CHANGELOGs [ci skip]
rafaelfranca authored
913 CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active
d70e023 @mhfs Added where option to add_index to support postgresql partial indices
mhfs authored
914
915 *Marcelo Silveira*
916
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
917 * Implemented ActiveRecord::Relation#none method.
8270e4a @xuanxu Added `none` query method to return zero records.
xuanxu authored
918
919 The `none` method returns a chainable relation with zero records
920 (an instance of the NullRelation class).
921
922 Any subsequent condition chained to the returned relation will continue
923 generating an empty relation and will not fire any query to the database.
924
925 *Juanjo Bazán*
926
927 * Added the `ActiveRecord::NullRelation` class implementing the null
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
928 object pattern for the Relation class.
8270e4a @xuanxu Added `none` query method to return zero records.
xuanxu authored
929
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
930 *Juanjo Bazán*
931
932 * Added new `dependent: :restrict_with_error` option. This will add
5ad7998 @jonleighton Remove the dependent_restrict_raises option.
jonleighton authored
933 an error to the model, rather than raising an exception.
336ff8a @hindenbug has_many/has_one, :dependent => :restrict, deprecation added.
hindenbug authored
934
5ad7998 @jonleighton Remove the dependent_restrict_raises option.
jonleighton authored
935 The `:restrict` option is renamed to `:restrict_with_exception` to
936 make this distinction explicit.
336ff8a @hindenbug has_many/has_one, :dependent => :restrict, deprecation added.
hindenbug authored
937
5ad7998 @jonleighton Remove the dependent_restrict_raises option.
jonleighton authored
938 *Manoj Kumar & Jon Leighton*
336ff8a @hindenbug has_many/has_one, :dependent => :restrict, deprecation added.
hindenbug authored
939
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
940 * Added `create_join_table` migration helper to create HABTM join tables.
080bd83 @rafaelfranca Add `create_join_table` migration helper to create HABTM join tables
rafaelfranca authored
941
942 create_join_table :products, :categories
943 # =>
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
944 # create_table :categories_products, id: false do |td|
945 # td.integer :product_id, null: false
946 # td.integer :category_id, null: false
080bd83 @rafaelfranca Add `create_join_table` migration helper to create HABTM join tables
rafaelfranca authored
947 # end
948
949 *Rafael Mendonça França*
950
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
951 * The primary key is always initialized in the @attributes hash to `nil` (unless
080bd83 @rafaelfranca Add `create_join_table` migration helper to create HABTM join tables
rafaelfranca authored
952 another value has been specified).
522c0fd @tenderlove The primary key is always initialized in the @attributes hash to nil …
tenderlove authored
953
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
954 *Aaron Paterson*
955
a2dab46 @jonleighton Deprecate inferred JOINs with includes + SQL snippets.
jonleighton authored
956 * In previous releases, the following would generate a single query with
957 an `OUTER JOIN comments`, rather than two separate queries:
958
959 Post.includes(:comments)
960 .where("comments.name = 'foo'")
961
962 This behaviour relies on matching SQL string, which is an inherently
963 flawed idea unless we write an SQL parser, which we do not wish to
964 do.
965
8c0c083 @jonleighton Make it more explicit that the feature is deprecated, not removed.
jonleighton authored
966 Therefore, it is now deprecated.
967
968 To avoid deprecation warnings and for future compatibility, you must
969 explicitly state which tables you reference, when using SQL snippets:
a2dab46 @jonleighton Deprecate inferred JOINs with includes + SQL snippets.
jonleighton authored
970
971 Post.includes(:comments)
972 .where("comments.name = 'foo'")
973 .references(:comments)
974
975 Note that you do not need to explicitly specify references in the
976 following cases, as they can be automatically inferred:
977
978 Post.where(comments: { name: 'foo' })
979 Post.where('comments.name' => 'foo')
980 Post.order('comments.name')
981
982 You also do not need to worry about this unless you are doing eager
983 loading. Basically, don't worry unless you see a deprecation warning
984 or (in future releases) an SQL error due to a missing JOIN.
985
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
986 *Jon Leighton*
a2dab46 @jonleighton Deprecate inferred JOINs with includes + SQL snippets.
jonleighton authored
987
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
988 * Support for the `schema_info` table has been dropped. Please
f82e244 @tenderlove dropping support for `schema_info`.
tenderlove authored
989 switch to `schema_migrations`.
990
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
991 *Aaron Patterson*
992
993 * Connections *must* be closed at the end of a thread. If not, your
6769293 @tenderlove connections must be checked in at the end of a thread
tenderlove authored
994 connection pool can fill and an exception will be raised.
995
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
996 *Aaron Patterson*
997
96838b5 @tenderlove can create hstore records via AR API
tenderlove authored
998 * PostgreSQL hstore records can be created.
999
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
1000 *Aaron Patterson*
1001
776af48 @tenderlove PostgreSQL hstore types are automatically deserialized from the datab…
tenderlove authored
1002 * PostgreSQL hstore types are automatically deserialized from the database.
1003
0aaf87c improve AR/CHANGELOG [ci skip]
Francesco Rodriguez authored
1004 *Aaron Patterson*
1005
810a50d @fxn CHANGELOGs are now per branch
fxn authored
1006 Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activerecord/CHANGELOG.md) for previous changes.
Something went wrong with that request. Please try again.