Skip to content

Commit

Permalink
fix: handle race conditions when creating a pacticipant on postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 15, 2018
1 parent 996953f commit 2c83985
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/pacticipants/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2c83985

Please sign in to comment.