Skip to content

Commit

Permalink
Merge pull request jashmenn#51 from donbobka/feature/fix_array_type_cast
Browse files Browse the repository at this point in the history
Fix PostgreSQL array type casting(ArgumentError: wrong number of arguments (3 for 1..2))
  • Loading branch information
pyromaniac committed Jan 11, 2015
2 parents 8ebad2f + c596d0a commit 5259314
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/activeuuid/patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def quote_with_visiting(value, column = nil)
quote_without_visiting(value, column)
end

def type_cast_with_visiting(value, column = nil)
def type_cast_with_visiting(value, column = nil, *args)
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)
type_cast_without_visiting(value, column, *args)
end

def native_database_types_with_pguuid
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@
its(:delete) { should be_truthy }
its(:destroy) { should be_truthy }
end

context '#save' do
subject { article }
let(:array) { [1, 2, 3] }

its(:save) { should be_truthy }

context 'when change array field' do
before { article.some_array = array }
its(:save) { should be_truthy }
end
end
end

describe UuidArticle do
Expand Down
5 changes: 5 additions & 0 deletions spec/support/migrate/20141017204945_add_array_to_articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddArrayToArticles < ActiveRecord::Migration
def change
add_column :articles, :some_array, :integer, array: true
end
end

0 comments on commit 5259314

Please sign in to comment.