hashicorp / hashicorp/go-memdb

Unique constraint on an index should throw an error if an item already exists

Open
#7 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.5k
Forks
230
PR merge metrics
No merged PRs in 30d

Description

This came up in https://github.com/hashicorp/consul/pull/1463 where I found I could create multiple entries by name, even though there's a unique constraint on that index.

MemDB should throw an error if an item is being inserted into an index marked unique, and there's an existing item there, and that item's primary key doesn't match the incoming one.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the MemDB insertion and unique-index handling described in the issue, then trace how an existing item's primary key is compared with the incoming item. Done means inserting a duplicate unique-index value with a different primary key returns an error, while the same primary key remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.