Skip to content

Commit

Permalink
Fix specs related to insert all
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Silva committed Feb 12, 2021
1 parent 6b1df43 commit e3d0cc8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions spec/tests/insert_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@
ON CONFLICT DO NOTHING RETURNING "id"
SQL

result = subject.insert_all(entries, returning: :name)
result = subject.insert_all(entries, returning: %i[name])
expect(result.squish).to be_eql(<<~SQL.squish)
INSERT INTO "tags" ("name") VALUES ('A'), ('B')
ON CONFLICT DO NOTHING RETURNING name
ON CONFLICT DO NOTHING RETURNING "name"
SQL

result = subject.insert_all(entries, returning: %i[id name])
expect(result.squish).to be_eql(<<~SQL.squish)
INSERT INTO "tags" ("name") VALUES ('A'), ('B')
ON CONFLICT DO NOTHING RETURNING "id","name"
SQL

result = subject.insert_all(entries, unique_by: :id)
expect(result.squish).to be_eql(<<~SQL.squish)
INSERT INTO "tags" ("name") VALUES ('A'), ('B')
ON CONFLICT ("id") DO NOTHING RETURNING "id"
SQL
end

it 'does not mess with insert_all!' do
Expand All @@ -43,9 +37,9 @@
INSERT INTO "tags" ("name") VALUES ('A'), ('B') RETURNING "id"
SQL

result = subject.insert_all!(entries, returning: :name)
result = subject.insert_all!(entries, returning: %i[name])
expect(result.squish).to be_eql(<<~SQL.squish)
INSERT INTO "tags" ("name") VALUES ('A'), ('B') RETURNING name
INSERT INTO "tags" ("name") VALUES ('A'), ('B') RETURNING "name"
SQL
end

Expand All @@ -57,11 +51,11 @@
RETURNING "id"
SQL

result = subject.upsert_all(entries, returning: :name)
result = subject.upsert_all(entries, returning: %i[name])
expect(result.squish).to be_eql(<<~SQL.squish)
INSERT INTO "tags" ("name") VALUES ('A'), ('B')
ON CONFLICT ("id") DO UPDATE SET "name"=excluded."name"
RETURNING name
RETURNING "name"
SQL
end

Expand Down

0 comments on commit e3d0cc8

Please sign in to comment.