3
0

Add support for RDBMS index creation

This commit is contained in:
Denis Arh
2022-09-06 19:51:29 +02:00
parent 5992471337
commit 4e96804d46
27 changed files with 732 additions and 107 deletions

View File

@@ -9,6 +9,10 @@ import (
attributes: {
[name=_]: {"name": name} & #ModelAttribute
}
indexes?: {
[name=_]: {"name": name} & #ModelIndex
}
}
#ModelAttributeDalType:
@@ -206,3 +210,49 @@ SortableTimestampNilField: {
jsonTag: "json:\"\(json.field)\(_omitEmpty)\(_string)\""
}
}
#ModelIndex: {
name: #ident
_attributes: { [_]: #ModelAttribute }
_words: strings.Replace(strings.Replace(name, "_", " ", -1), ".", " ", -1)
_ident: strings.ToCamel(strings.Replace(strings.ToTitle(_words), " ", "", -1))
// lowercase (unexported, golang) identifier
ident: #ident | *_ident
primary: bool | *(strings.ToLower(name) == "primary")
unique: bool | *(strings.Contains(name, "unique") || primary)
type: "BTREE" | *"BTREE"
attribute?: string
attributes?: [string, ...]
if attribute != _|_ {
attributes: [attribute]
}
fields: [#ModelIndexField, ...] | *([
if attributes != _|_ {
for a in attributes {
"attribute": a
#ModelIndexField
}
}
])
predicate?: string
}
#IndexFieldModifier: "LOWERCASE"
#ModelIndexField: {
attribute: string
modifiers?: [#IndexFieldModifier, ...]
length?: number
sort?: "DESC" | "ASC"
nulls?: "FIRST" | "LAST"
}