Permalink
Browse files

Fixed psql batch updates quoting

  • Loading branch information...
1 parent 94e86a8 commit 3ff6d03af293ec17490439850a783fbad33a30a4 @pyromaniac pyromaniac committed Jan 29, 2013
Showing with 9 additions and 8 deletions.
  1. +4 −8 lib/activeuuid/patches.rb
  2. +5 −0 spec/lib/activerecord_spec.rb
View
@@ -81,18 +81,14 @@ module PostgreSQLQuoting
included do
def quote_with_visiting(value, column = nil)
- if column && column.type == :uuid
- value = UUIDTools::UUID.serialize(value)
- value = value.to_s if value.is_a? UUIDTools::UUID
- end
+ value = UUIDTools::UUID.serialize(value) if column && column.type == :uuid
+ value = value.to_s if value.is_a? UUIDTools::UUID
quote_without_visiting(value, column)
end
def type_cast_with_visiting(value, column = nil)
- if column && column.type == :uuid
- value = UUIDTools::UUID.serialize(value)
- value = value.to_s if value.is_a? UUIDTools::UUID
- end
+ value = UUIDTools::UUID.serialize(value) if column && column.type == :uuid
+ value = value.to_s if value.is_a? UUIDTools::UUID
type_cast_without_visiting(value, column)
end
@@ -111,6 +111,11 @@
specify { model.where("id = :id", id: article.id) }
end
+ context 'batch interpolation' do
+ before { model.update_all(["title = CASE WHEN id = :id THEN 'Passed' ELSE 'Nothing' END", id: article.id]) }
+ specify { article.reload.title.should == 'Passed' }
+ end
+
context '.find' do
specify { model.find(article).should == article }
specify { model.find(id).should == article }

0 comments on commit 3ff6d03

Please sign in to comment.