Skip to content

Commit

Permalink
Move Language/Project name to Named mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Nov 10, 2023
1 parent ac6332b commit 14c6392
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
5 changes: 1 addition & 4 deletions dbschema/language.esdl
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions dbschema/project.esdl
Original file line number Diff line number Diff line change
@@ -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;
};

Expand Down
24 changes: 24 additions & 0 deletions dbschema/z.named.esdl
Original file line number Diff line number Diff line change
@@ -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 <str>{}
);
}

0 comments on commit 14c6392

Please sign in to comment.