如果我想在PostgreSQL中定义一个类型应该是这样的类型:
[A-Z]{4}[0-9]{4}
正在进行模式匹配。 我该怎么办?
答案 0 :(得分:1)
let ingredient1Text = ingredient1.text ?? ""
let ingredient2Text = ingredient2.text ?? ""
cocktails = cocktails?
.filter("ingredientName1 CONTAINS %@ || ingredientName2 CONTAINS %@ || ingredientName3 CONTAINS %@ || ingredientName4 CONTAINS %@ || ingredientName5 CONTAINS %@ || ingredientName6 CONTAINS %@ || ingredientName1 CONTAINS %@ || ingredientName2 CONTAINS %@ || ingredientName3 CONTAINS %@ || ingredientName4 CONTAINS %@ || ingredientName5 CONTAINS %@ || ingredientName6 CONTAINS %@",
ingredient1Text, ingredient1Text, ingredient1Text, ingredient1Text, ingredient1Text, ingredient1Text, ingredient1Text,
ingredient2Text, ingredient2Text, ingredient2Text, ingredient2Text, ingredient2Text, ingredient2Text, ingredient2Text)
可能适合您。
CREATE DOMAIN
我猜到了create domain NEWTYPE as char(8)
constraint newtype_regex not null check (value ~ '[A-Z]{4}[0-9]{4}');
。像内在数据类型一样使用它。
not null
烟雾测试。 。
create table test (
nt NEWTYPE
);