diff --git a/dbschema/language.esdl b/dbschema/language.esdl index c57e408c32..8adb1852e0 100644 --- a/dbschema/language.esdl +++ b/dbschema/language.esdl @@ -1,8 +1,5 @@ module default { - type Language extending Resource, Project::ContextAware, Mixin::Pinnable, Mixin::Taggable { - required name: str; - index on (str_sortable(.name)); - + type Language extending Resource, Project::ContextAware, Mixin::Named, Mixin::Pinnable, Mixin::Taggable { required displayName: str { default := .name; } diff --git a/dbschema/project.esdl b/dbschema/project.esdl index 3fa427ebd0..8a9d639a11 100644 --- a/dbschema/project.esdl +++ b/dbschema/project.esdl @@ -1,6 +1,6 @@ module default { - abstract type Project extending Resource, Project::ContextAware, Mixin::Pinnable, Mixin::Taggable { - required name: str { + abstract type Project extending Resource, Project::ContextAware, Mixin::Named, Mixin::Pinnable, Mixin::Taggable { + overloaded name { constraint exclusive; }; diff --git a/dbschema/z.named.esdl b/dbschema/z.named.esdl new file mode 100644 index 0000000000..ccecdf094d --- /dev/null +++ b/dbschema/z.named.esdl @@ -0,0 +1,24 @@ +module Mixin { + abstract type Named { + required name: str { + rewrite insert, update using (default::str_clean(.name)); + }; + + index on (default::str_sortable(.name)); + + index fts::index on ( + fts::with_options( + .name, + language := fts::Language.eng, + ) + ); + } +} + +module default { + function str_clean(string: str) -> optional str + using( + with t := str_trim(string, " \t\r\n") + select t if len(t) > 0 else {} + ); +}