graphprotocol / graphprotocol/graph-node
Introduce uniquness constraints for entity fields
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
It would be useful to be able to provide uniqueness constraints for entity fields, importantly
- each constraint should be able to cover more than one field
- it should be possible to define more than one such constraint per entity
This constraint should be enforced at the database level, helping the mapping author from making mistakes, and also would clarify the semantics of the data model to third parties looking at the entity definition.
It is not possible to capture both of these properties by simply picking a suitable id field, take the following example.
I have a Profile entity that holds both a handle: String! and an account: Bytes!.
I may want to model the fact that both must be unique independently. In this case, using the entity ID = account||handle does not work, it is too loose, it allows two profiles which have the same handle value, but distinct account.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name implementation files or tests. Start by tracing how entity fields and identifiers are defined and persisted, then design support for multiple database-level uniqueness constraints, including constraints spanning several fields; done means both independent and compound constraints are represented and enforced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100