From 2c83985f5aaf48aee17a50ca5bfc00197078de1f Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 15 Nov 2018 17:10:05 +1100 Subject: [PATCH] fix: handle race conditions when creating a pacticipant on postgres --- lib/pact_broker/pacticipants/repository.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pact_broker/pacticipants/repository.rb b/lib/pact_broker/pacticipants/repository.rb index bbb42d1af..1798efe2e 100644 --- a/lib/pact_broker/pacticipants/repository.rb +++ b/lib/pact_broker/pacticipants/repository.rb @@ -42,13 +42,13 @@ def find_by_name_or_create name end def create args - id = PactBroker::Domain::Pacticipant.dataset.insert_ignore.insert( + PactBroker::Domain::Pacticipant.dataset.insert_ignore.insert( name: args[:name], repository_url: args[:repository_url], created_at: Sequel.datetime_class.now, updated_at: Sequel.datetime_class.now ) - PactBroker::Domain::Pacticipant.find(id: id) + PactBroker::Domain::Pacticipant.find(name: args[:name]) end def pacticipant_names