elefant_tools/models/
check_constraint.rs1use crate::object_id::ObjectId;
2use crate::whitespace_ignorant_string::WhitespaceIgnorantString;
3use serde::{Deserialize, Serialize};
4use std::cmp::Ordering;
5
6#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
7pub struct PostgresCheckConstraint {
8 pub name: String,
9 pub check_clause: WhitespaceIgnorantString,
10 pub comment: Option<String>,
11 pub is_enforced: bool,
12 pub object_id: ObjectId,
13}
14
15impl Default for PostgresCheckConstraint {
16 fn default() -> Self {
17 Self {
18 name: String::new(),
19 check_clause: WhitespaceIgnorantString::default(),
20 comment: None,
21 is_enforced: true,
22 object_id: ObjectId::default(),
23 }
24 }
25}
26
27impl PartialOrd for PostgresCheckConstraint {
28 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
29 Some(self.cmp(other))
30 }
31}
32
33impl Ord for PostgresCheckConstraint {
34 fn cmp(&self, other: &Self) -> Ordering {
35 self.name.cmp(&other.name)
36 }
37}