//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//
//! `INSERT ... OVERRIDING` selection of identity column values.
use serde::{Deserialize, Serialize};
/// Which value an `INSERT` writes to an identity column it supplies a value for. Without the clause a supplied value is written to a `GENERATED BY DEFAULT` identity column and rejected for a `GENERATED ALWAYS` one.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OverridingKind {
/// `OVERRIDING SYSTEM VALUE`: write the supplied value, also to a `GENERATED ALWAYS` column.
SystemValue,
/// `OVERRIDING USER VALUE`: discard the supplied value and draw the column's next sequence value.
UserValue,
}
impl OverridingKind {
/// The SQL clause, as `PostgreSQL` prints it.
#[must_use]
pub const fn sql(self) -> &'static str {
match self {
Self::SystemValue => "OVERRIDING SYSTEM VALUE",
Self::UserValue => "OVERRIDING USER VALUE",
}
}
}