uqa_sql/catalog/index/
enforced_key.rs1use crate::ast::{Expr, IndexKey, TableKeyConstraint};
9
10#[derive(Debug, Clone)]
12pub struct EnforcedKey {
13 pub constraint: TableKeyConstraint,
14 pub keys: Vec<IndexKey>,
15 pub index: Option<uqa_core::RelationIdentity>,
16 pub predicate: Option<Box<Expr>>,
17 pub constraint_owned: bool,
18}
19
20impl std::ops::Deref for EnforcedKey {
21 type Target = TableKeyConstraint;
22
23 fn deref(&self) -> &Self::Target {
24 &self.constraint
25 }
26}
27
28impl From<TableKeyConstraint> for EnforcedKey {
29 fn from(constraint: TableKeyConstraint) -> Self {
30 Self {
31 keys: constraint
32 .columns
33 .iter()
34 .cloned()
35 .map(IndexKey::Column)
36 .collect(),
37 index: None,
38 constraint,
39 predicate: None,
40 constraint_owned: true,
41 }
42 }
43}