diff options
-rw-r--r-- | lib/active_relation/relations/update.rb | 2 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/deletion_spec.rb | 2 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/update_spec.rb | 12 |
3 files changed, 7 insertions, 9 deletions
diff --git a/lib/active_relation/relations/update.rb b/lib/active_relation/relations/update.rb index 46aafd38a5..5a7be31290 100644 --- a/lib/active_relation/relations/update.rb +++ b/lib/active_relation/relations/update.rb @@ -11,7 +11,7 @@ module ActiveRelation "UPDATE #{table_sql} SET", assignments.collect do |attribute, value| "#{value.format(attribute)} = #{attribute.format(value)}" - end.join("\n"), + end.join(",\n"), ("WHERE #{selects.collect(&:to_sql).join('\n\tAND ')}" unless selects.blank?) ].join("\n") end diff --git a/spec/active_relation/unit/relations/deletion_spec.rb b/spec/active_relation/unit/relations/deletion_spec.rb index 72f3f81b2a..46a962cb5c 100644 --- a/spec/active_relation/unit/relations/deletion_spec.rb +++ b/spec/active_relation/unit/relations/deletion_spec.rb @@ -24,7 +24,7 @@ module ActiveRelation it "manufactures sql deleting a ranged relation" do pending do - Deletion.new(@relation[0..0]).to_sql.should be_like(" + Deletion.new(@relation.take(1)).to_sql.should be_like(" DELETE FROM `users` LIMIT 1 diff --git a/spec/active_relation/unit/relations/update_spec.rb b/spec/active_relation/unit/relations/update_spec.rb index 6634dc67d1..969b17436f 100644 --- a/spec/active_relation/unit/relations/update_spec.rb +++ b/spec/active_relation/unit/relations/update_spec.rb @@ -8,17 +8,15 @@ module ActiveRelation describe '#to_sql' do it "manufactures sql updating attributes when given multiple attributes" do - pending do - Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql.should be_like(" - UPDATE `users` - SET `users`.`name` = 'nick', `users`.`id` = 1 - ") - end + Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql.should be_like(" + UPDATE `users` + SET `users`.`id` = 1, `users`.`name` = 'nick' + ") end it "manufactures sql updating attributes when given a ranged relation" do pending do - Update.new(@relation[0..0], @relation[:name] => "nick").to_sql.should be_like(" + Update.new(@relation.take(1), @relation[:name] => "nick").to_sql.should be_like(" UPDATE `users` SET `users`.`name` = 'nick' LIMIT 1 |