Skip to content

Commit

Permalink
Add spec for insert_ignore/insert_conflict usage with multi_insert
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Sep 27, 2016
1 parent c39594d commit 6e9a63f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/adapters/postgres_spec.rb
Expand Up @@ -204,6 +204,17 @@ def logger.method_missing(m, msg)
@ds.all.must_equal [{:a=>1, :b=>2, :c=>3}]
end

it "Dataset#insert_ignore and insert_conflict should work with multi_insert/import" do
@ds.insert(1, 2, 3)
@ds.insert_ignore.multi_insert([{:a=>1, :b=>3, :c=>4}])
@ds.insert_ignore.import([:a, :b, :c], [[1, 3, 4]])
@ds.all.must_equal [{:a=>1, :b=>2, :c=>3}]
@ds.insert_conflict(:target=>:a, :update=>{:b=>3}).import([:a, :b, :c], [[1, 3, 4]])
@ds.all.must_equal [{:a=>1, :b=>3, :c=>3}]
@ds.insert_conflict(:target=>:a, :update=>{:b=>4}).multi_insert([{:a=>1, :b=>5, :c=>6}])
@ds.all.must_equal [{:a=>1, :b=>4, :c=>3}]
end

it "Dataset#insert_conflict should handle upserts" do
@ds.insert(1, 2, 3)
@ds.insert_conflict(:target=>:a, :update=>{:b=>3}).insert(1, 3, 4).must_equal nil
Expand Down

0 comments on commit 6e9a63f

Please sign in to comment.