mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
schema endpoint doesn't return internal fields
This commit is contained in:
parent
45cd48c1b7
commit
ef7f04c09d
2 changed files with 21 additions and 1 deletions
19
api_test.go
19
api_test.go
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
|
|
@ -48,7 +49,7 @@ func TestAPI_Import(t *testing.T) {
|
|||
index := "rick"
|
||||
field := "f"
|
||||
|
||||
_, err := m0.API.CreateIndex(ctx, index, pilosa.IndexOptions{Keys: true})
|
||||
_, err := m0.API.CreateIndex(ctx, index, pilosa.IndexOptions{Keys: true, TrackExistence: true})
|
||||
if err != nil {
|
||||
t.Fatalf("creating index: %v", err)
|
||||
}
|
||||
|
|
@ -99,6 +100,22 @@ func TestAPI_Import(t *testing.T) {
|
|||
} else if keys := res.Results[0].(*pilosa.Row).Keys; !reflect.DeepEqual(keys, colKeys) {
|
||||
t.Fatalf("unexpected column keys: %+v", keys)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// Relies on the previous test creating an index with TrackExistence and
|
||||
// adding some data.
|
||||
t.Run("SchemaHasNoExists", func(t *testing.T) {
|
||||
schema := m1.API.Schema(context.Background())
|
||||
for _, f := range schema[0].Fields {
|
||||
if f.Name == "_exists" {
|
||||
t.Fatalf("found _exists field in schema")
|
||||
}
|
||||
if strings.HasPrefix(f.Name, "_") {
|
||||
t.Fatalf("found internal field '%s' in schema output", f.Name)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
t.Run("RowKeyColumnID", func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -289,6 +289,9 @@ func (h *Holder) limitedSchema() []*IndexInfo {
|
|||
for _, index := range h.Indexes() {
|
||||
di := &IndexInfo{Name: index.Name(), Options: index.Options()}
|
||||
for _, field := range index.Fields() {
|
||||
if strings.HasPrefix(field.name, "_") {
|
||||
continue
|
||||
}
|
||||
fi := &FieldInfo{Name: field.Name(), Options: field.Options()}
|
||||
di.Fields = append(di.Fields, fi)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue