Merge pull request #1420 from alanbernstein/fix-schema-null-fields

Represent zero fields in /schema response as [] instead of null
This commit is contained in:
Alan Bernstein 2021-02-13 06:40:36 -06:00 • committed by GitHub
commit 06503813c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -857,7 +857,9 @@ func (h *Holder) Schema(includeHiddenAndViews bool) []*IndexInfo {
CreatedAt: index.CreatedAt(),
Options: index.Options(),
ShardWidth: ShardWidth,
Fields: []*FieldInfo{},
}
for _, field := range index.Fields() {
if !includeHiddenAndViews && strings.HasPrefix(field.name, "_") {
continue
@ -868,6 +870,7 @@ func (h *Holder) Schema(includeHiddenAndViews bool) []*IndexInfo {
Options: field.Options(),
}
if includeHiddenAndViews {
fi.Views = []*ViewInfo{}
for _, view := range field.views() {
fi.Views = append(fi.Views, &ViewInfo{Name: view.name})
}