Skip to content
This repository
Browse code

Remove the deprecation of update_column.

update_column was suggested as replacement of update_attribute at the
last release of 3-2-stable, so deprecating it now will confuse the
users.
  • Loading branch information...
commit 4ac81de52fbcdabc68f6d1fa8a5ee9ff7fff7df1 1 parent 8601f73
Rafael Mendonça França authored July 30, 2012
6  activerecord/CHANGELOG.md
Source Rendered
@@ -19,15 +19,11 @@
19 19
 
20 20
     *Jon Leighton*
21 21
 
22  
-*   Deprecate `update_column` method in favor of `update_columns`.
23  
-
24  
-    *Rafael Mendonça França*
25  
-
26 22
 *   Added an `update_columns` method. This new method updates the given attributes on an object,
27 23
     without calling save, hence skipping validations and callbacks.
28 24
     Example:
29 25
 
30  
-        User.first.update_columns({:name => "sebastian", :age => 25})         # => true
  26
+        User.first.update_columns(name: "sebastian", age: 25) # => true
31 27
 
32 28
     *Sebastian Martinez + Rafael Mendonça França*
33 29
 
5  activerecord/lib/active_record/persistence.rb
@@ -204,11 +204,6 @@ def update_attributes!(attributes, options = {})
204 204
     # Raises an +ActiveRecordError+ when called on new objects, or when the +name+
205 205
     # attribute is marked as readonly.
206 206
     def update_column(name, value)
207  
-      msg = "update_column is deprecated and will be removed in 4.1. Please use update_columns. " \
208  
-        "E.g. update_columns(foo: 'bar')"
209  
-
210  
-      ActiveSupport::Deprecation.warn(msg)
211  
-
212 207
       update_columns(name => value)
213 208
     end
214 209
 
55  activerecord/test/cases/persistence_test.rb
@@ -377,21 +377,22 @@ def test_update_attribute_does_not_choke_on_nil
377 377
 
378 378
   def test_update_column
379 379
     topic = Topic.find(1)
380  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
381  
-      topic.update_column("approved", true)
382  
-    end
  380
+    topic.update_column("approved", true)
383 381
     assert topic.approved?
384 382
     topic.reload
385 383
     assert topic.approved?
  384
+
  385
+    topic.update_column(:approved, false)
  386
+    assert !topic.approved?
  387
+    topic.reload
  388
+    assert !topic.approved?
386 389
   end
387 390
 
388 391
   def test_update_column_should_not_use_setter_method
389 392
     dev = Developer.find(1)
390 393
     dev.instance_eval { def salary=(value); write_attribute(:salary, value * 2); end }
391 394
 
392  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
393  
-      dev.update_column(:salary, 80000)
394  
-    end
  395
+    dev.update_column(:salary, 80000)
395 396
     assert_equal 80000, dev.salary
396 397
 
397 398
     dev.reload
@@ -400,29 +401,19 @@ def test_update_column_should_not_use_setter_method
400 401
 
401 402
   def test_update_column_should_raise_exception_if_new_record
402 403
     topic = Topic.new
403  
-    assert_raises(ActiveRecord::ActiveRecordError) do
404  
-      assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
405  
-        topic.update_column("approved", false)
406  
-      end
407  
-    end
  404
+    assert_raises(ActiveRecord::ActiveRecordError) { topic.update_column("approved", false) }
408 405
   end
409 406
 
410 407
   def test_update_column_should_not_leave_the_object_dirty
411 408
     topic = Topic.find(1)
412  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
413  
-      topic.update_column("content", "Have a nice day")
414  
-    end
  409
+    topic.update_column("content", "Have a nice day")
415 410
 
416 411
     topic.reload
417  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
418  
-      topic.update_column(:content, "You too")
419  
-    end
  412
+    topic.update_column(:content, "You too")
420 413
     assert_equal [], topic.changed
421 414
 
422 415
     topic.reload
423  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
424  
-      topic.update_column("content", "Have a nice day")
425  
-    end
  416
+    topic.update_column("content", "Have a nice day")
426 417
     assert_equal [], topic.changed
427 418
   end
428 419
 
@@ -430,20 +421,14 @@ def test_update_column_with_model_having_primary_key_other_than_id
430 421
     minivan = Minivan.find('m1')
431 422
     new_name = 'sebavan'
432 423
 
433  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
434  
-      minivan.update_column(:name, new_name)
435  
-    end
  424
+    minivan.update_column(:name, new_name)
436 425
     assert_equal new_name, minivan.name
437 426
   end
438 427
 
439 428
   def test_update_column_for_readonly_attribute
440 429
     minivan = Minivan.find('m1')
441 430
     prev_color = minivan.color
442  
-    assert_raises(ActiveRecord::ActiveRecordError) do
443  
-      assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
444  
-        minivan.update_column(:color, 'black')
445  
-      end
446  
-    end
  431
+    assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_column(:color, 'black') }
447 432
     assert_equal prev_color, minivan.color
448 433
   end
449 434
 
@@ -451,14 +436,10 @@ def test_update_column_should_not_modify_updated_at
451 436
     developer = Developer.find(1)
452 437
     prev_month = Time.now.prev_month
453 438
 
454  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
455  
-      developer.update_column(:updated_at, prev_month)
456  
-    end
  439
+    developer.update_column(:updated_at, prev_month)
457 440
     assert_equal prev_month, developer.updated_at
458 441
 
459  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
460  
-      developer.update_column(:salary, 80001)
461  
-    end
  442
+    developer.update_column(:salary, 80001)
462 443
     assert_equal prev_month, developer.updated_at
463 444
 
464 445
     developer.reload
@@ -467,11 +448,9 @@ def test_update_column_should_not_modify_updated_at
467 448
 
468 449
   def test_update_column_with_one_changed_and_one_updated
469 450
     t = Topic.order('id').limit(1).first
470  
-    author_name = t.author_name
  451
+    title, author_name = t.title, t.author_name
471 452
     t.author_name = 'John'
472  
-    assert_deprecated "update_column is deprecated and will be removed in 4.1. Please use update_columns. E.g. update_columns(foo: 'bar')" do
473  
-      t.update_column(:title, 'super_title')
474  
-    end
  453
+    t.update_column(:title, 'super_title')
475 454
     assert_equal 'John', t.author_name
476 455
     assert_equal 'super_title', t.title
477 456
     assert t.changed?, "topic should have changed"

0 notes on commit 4ac81de

Please sign in to comment.
Something went wrong with that request. Please try again.