Skip to main content

uqa_execution/mutation/identity/
source.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Where an inserted row's physical document identity comes from.
8
9/// Where an inserted row's physical document identity comes from, as its table's columns decide it.
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum IdentitySource {
12    /// The table generates the identity: a declared table without a single primary-key column, or whose key is not an integer.
13    Generated,
14    /// The table's single integer primary-key column names the identity. Where the table maps its keys, a key in `0..KEY_IDENTITY_LIMIT` is the identity; any other row takes an identity the table generates at or above that limit, which no key names.
15    IntegerKey,
16    /// The `id` field of a table without declared columns names the identity, as the document API does.
17    Document,
18}
19
20impl IdentitySource {
21    /// Whether a value the row supplies can name its identity.
22    #[must_use]
23    pub const fn accepts_supplied(self) -> bool {
24        !matches!(self, Self::Generated)
25    }
26}