SeaQL / SeaQL/sea-orm

Add contains method for ActiveValue

Open
#1,533 7 comments 0 reactions 1 assignee View on GitHub

@Diwakar-Gupta is already working on this.

Since Apr 25, 2023.

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

Description

Motivation

Sometimes it is necessary to compare a value in a model that is already the active model. Now this is done somewhat inconveniently, you need to use !is_not_set() and as_ref(). Which makes the code a bit more complicated.

Proposed Solutions

let id_set = ActiveValue::Set(1);
let id_unchanged = ActiveValue::Unchanged(1);
let id_not_set = ActiveValue::<i32>::NotSet;

id_set.contains(&1); // true
id_unchanged.contains(&1); // true
id_not_set.contains(&1); // false

Current Workarounds

let id_set = ActiveValue::Set(1);

!id_set.is_not_set() && id_set.as_ref() == &1

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.