use-pg-constraint
PostgreSQL constraint primitives for RustUse.
This crate provides constraint names, kinds, deferrability labels, constrained columns, referenced table metadata, and expression labels. It does not generate or execute SQL.
Example
use use_pg_column::PgColumnName;
use use_pg_constraint::{PgConstraint, PgConstraintKind, PgConstraintName, PgDeferrability, PgInitially};
let constraint = PgConstraint::new(PgConstraintKind::PrimaryKey)
.with_name(PgConstraintName::new("users_pkey")?)
.with_columns(vec![PgColumnName::new("id")?])
.with_deferrability(PgDeferrability::deferrable(PgInitially::Immediate));
assert_eq!(constraint.to_string(), "CONSTRAINT users_pkey PRIMARY KEY");
assert_eq!(constraint.columns().len(), 1);
assert!(constraint.deferrability().is_deferrable());
# Ok::<(), Box<dyn std::error::Error>>(())