我试图理解为什么一些 Postgres 约束可以在不同的表中命名相同,而有些则不能
这是一个简单的例子:
drop table if exists public.table_1;
drop table if exists public.table_2;
CREATE TABLE public.table_1 (
id serial NOT NULL,
date_start date NOT NULL,
date_end date NULL
);
CREATE TABLE public.table_2 (
id serial NOT NULL,
date_start date NOT NULL,
date_end date NULL
);
alter table public.table_1 add constraint my_constraint_1 check (date_start > now());
alter table public.table_2 add constraint my_constraint_1 check (date_start > now());
alter table public.table_1 add constraint my_constraint_2 EXCLUDE USING gist (daterange(date_start, coalesce(date_end, 'infinity'), '[]') WITH …Run Code Online (Sandbox Code Playgroud) 我有一个带几个板条箱的工作区。我需要排除一个特定的测试。
我尝试添加环境变量检查,但这不起作用。我想过cargo test滤掉环境变量。
// package1/src/lib.rs
// ...
#[cfg(test)]
mod tests {
#[test]
fn test1() {
if std::env::var("CI").is_ok() {
return;
}
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试--exclude使用各种选项传递参数,但它们都不起作用:
cargo test --workspace --exclude test1cargo test --workspace --exclude tests:test1cargo test --workspace --exclude tests::test1cargo test --workspace --exclude '*test1'cargo test --workspace --exclude 'tests*test1'cargo test --workspace --exclude package1
这将跳过包中的所有测试。cargo test --workspace --exclude 'package1*test1'如何运行除一个之外的所有工作区测试?
给出以下架构
CREATE TABLE test (
value text,
flag bool
);
Run Code Online (Sandbox Code Playgroud)
这是否可能,创建这样的约束,该约束将允许具有相同value和的重复行flag = true,但最多允许具有给定value和 的行flag = false
例如
这些应该执行没有错误
INSERT INTO test (value, flag) VALUES ('1', true);
INSERT INTO test (value, flag) VALUES ('1', true);
INSERT INTO test (value, flag) VALUES ('1', true);
INSERT INTO test (value, flag) VALUES ('1', true);
Run Code Online (Sandbox Code Playgroud)
INSERT INTO test (value, flag) VALUES ('1', true);
INSERT INTO test (value, flag) VALUES ('1', true);
INSERT INTO test (value, flag) VALUES ('1', …Run Code Online (Sandbox Code Playgroud)