Improve check

This commit is contained in:
eraden 2023-06-16 21:44:53 +02:00
parent b3b1acdb05
commit 8383104d53
6 changed files with 18 additions and 8 deletions

View File

@ -1,3 +1,5 @@
#![feature(box_patterns)]
pub use sea_orm_migration::prelude::*;
pub mod carts;
@ -18,6 +20,8 @@ mod sea_ext;
pub use sea_ext::*;
pub mod stocks;
pub use stocks::*;
pub mod notifications;
pub use notifications::*;
pub mod types;
pub use types::*;

View File

View File

@ -228,7 +228,14 @@ pub mod constraint {
Check::Greater(l, r) => {
f.write_fmt(format_args!("{} > {}", l.to_string(), r.to_string()))
}
Check::Or(l, r) => f.write_fmt(format_args!("({l}) OR ({r})")),
Check::Or(l, r) => match (l, r) {
(box Check::Or(_, _), box Check::Or(_, _)) => {
f.write_fmt(format_args!("{l} OR {r}"))
}
(_, box Check::Or(_, _)) => f.write_fmt(format_args!("({l}) OR {r}")),
(box Check::Or(_, _), _) => f.write_fmt(format_args!("{l} OR ({r})")),
_ => f.write_fmt(format_args!("({l}) OR ({r})")),
},
Check::NotNull(l) => f.write_fmt(format_args!("{} IS NOT NULL", l.to_string())),
}
}

View File

@ -2,4 +2,4 @@
source: migration/src/sea_ext/mod.rs
expression: s.to_string()
---
"((((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL)) OR (cart_id IS NOT NULL)) OR (swap_id IS NOT NULL)) OR (return_id IS NOT NULL)"
"(claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR (cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR (return_id IS NOT NULL)"

View File

@ -2,4 +2,4 @@
source: migration/src/sea_ext/mod.rs
expression: c.to_string()
---
"CHECK ((((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL)) OR (cart_id IS NOT NULL)) OR (swap_id IS NOT NULL)) OR (return_id IS NOT NULL)"
"CHECK ((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR (cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR (return_id IS NOT NULL))"

View File

@ -1,3 +1,7 @@
--- DONE
--- DONE
--- DONE
CREATE TABLE tracking_links
(
id uuid NOT NULL,
@ -23,11 +27,6 @@ CREATE TABLE custom_shipping_options
metadata jsonb
);
---------
---------
---------
---------
CREATE TABLE shipping_methods
(
id uuid NOT NULL,