SeaQL / SeaQL/sea-orm

Allow unique key to be used instead of primary key

Open
#1,670 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
9.9k
Forks
734
Avg merge
6h 36m
Merged PRs (30d)
8

Description

Motivation

Currently the primary must be specified for many operations like update to work, otherwise it panics.
In reality this is unnecessarily strict since since any unique column or combination of columns would work.

Proposed Solutions

I have not been in the codebase much yet, but I feel this will require a new implementation similar to PrimaryKey, maybe we could call it SecondaryKeys and a changes in all places that currently check for only the primary key.

Current Workarounds

Use more generic methods like update_many, but then you hit the problem #1669

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading SeaORM's PrimaryKey handling and the update operations that currently require a primary key; compare them with the update_many workaround and issue #1669. Define how a unique column or combination of columns would be represented and identify every operation affected. Done means supported unique keys no longer cause those operations to panic.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.