| 572 | | # The ADO library doesn't support the number of affected rows |
|---|
| 573 | | unless current_adapter?(:SQLServerAdapter) |
|---|
| 574 | | def test_update_all |
|---|
| 575 | | assert_equal 2, Topic.update_all("content = 'bulk updated!'") |
|---|
| 576 | | assert_equal "bulk updated!", Topic.find(1).content |
|---|
| 577 | | assert_equal "bulk updated!", Topic.find(2).content |
|---|
| 578 | | |
|---|
| 579 | | assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!']) |
|---|
| 580 | | assert_equal "bulk updated again!", Topic.find(1).content |
|---|
| 581 | | assert_equal "bulk updated again!", Topic.find(2).content |
|---|
| 582 | | |
|---|
| 583 | | assert_equal 2, Topic.update_all(['content = ?', nil]) |
|---|
| 584 | | assert_nil Topic.find(1).content |
|---|
| 585 | | end |
|---|
| 586 | | |
|---|
| 587 | | def test_update_all_with_hash |
|---|
| 588 | | assert_not_nil Topic.find(1).last_read |
|---|
| 589 | | assert_equal 2, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) |
|---|
| 590 | | assert_equal "bulk updated with hash!", Topic.find(1).content |
|---|
| 591 | | assert_equal "bulk updated with hash!", Topic.find(2).content |
|---|
| 592 | | assert_nil Topic.find(1).last_read |
|---|
| 593 | | assert_nil Topic.find(2).last_read |
|---|
| 594 | | end |
|---|
| | 572 | def test_update_all |
|---|
| | 573 | assert_equal 2, Topic.update_all("content = 'bulk updated!'") |
|---|
| | 574 | assert_equal "bulk updated!", Topic.find(1).content |
|---|
| | 575 | assert_equal "bulk updated!", Topic.find(2).content |
|---|
| | 576 | |
|---|
| | 577 | assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!']) |
|---|
| | 578 | assert_equal "bulk updated again!", Topic.find(1).content |
|---|
| | 579 | assert_equal "bulk updated again!", Topic.find(2).content |
|---|
| | 580 | |
|---|
| | 581 | assert_equal 2, Topic.update_all(['content = ?', nil]) |
|---|
| | 582 | assert_nil Topic.find(1).content |
|---|
| | 583 | end |
|---|
| | 584 | |
|---|
| | 585 | def test_update_all_with_hash |
|---|
| | 586 | assert_not_nil Topic.find(1).last_read |
|---|
| | 587 | assert_equal 2, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) |
|---|
| | 588 | assert_equal "bulk updated with hash!", Topic.find(1).content |
|---|
| | 589 | assert_equal "bulk updated with hash!", Topic.find(2).content |
|---|
| | 590 | assert_nil Topic.find(1).last_read |
|---|
| | 591 | assert_nil Topic.find(2).last_read |
|---|