mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 12:27:52 +00:00
Merge pull request #1672 from yuce/1637-trackexistence-by-default
Index trackExistence is true by default Fixes #1637
This commit is contained in:
commit
19177b94d1
3 changed files with 20 additions and 8 deletions
|
|
@ -542,7 +542,12 @@ func (p *postIndexRequest) UnmarshalJSON(b []byte) error {
|
|||
return err
|
||||
}
|
||||
// Unmarshal expected values.
|
||||
var _p _postIndexRequest
|
||||
_p := _postIndexRequest{
|
||||
Options: pilosa.IndexOptions{
|
||||
Keys: false,
|
||||
TrackExistence: true,
|
||||
},
|
||||
}
|
||||
if err := json.Unmarshal(b, &_p); err != nil {
|
||||
return errors.Wrap(err, "unmarshalling expected values")
|
||||
}
|
||||
|
|
@ -618,7 +623,12 @@ func (h *Handler) handlePostIndex(w http.ResponseWriter, r *http.Request) {
|
|||
resp := successResponse{}
|
||||
|
||||
// Decode request.
|
||||
var req postIndexRequest
|
||||
req := postIndexRequest{
|
||||
Options: pilosa.IndexOptions{
|
||||
Keys: false,
|
||||
TrackExistence: true,
|
||||
},
|
||||
}
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
if err != nil && err != io.EOF {
|
||||
resp.write(w, err)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ func TestPostIndexRequestUnmarshalJSON(t *testing.T) {
|
|||
expected postIndexRequest
|
||||
err string
|
||||
}{
|
||||
{json: `{"options": {}}`, expected: postIndexRequest{Options: pilosa.IndexOptions{}}},
|
||||
{json: `{"options": {"keys": true}}`, expected: postIndexRequest{Options: pilosa.IndexOptions{Keys: true}}},
|
||||
{json: `{"options": {}}`, expected: postIndexRequest{Options: pilosa.IndexOptions{TrackExistence: true}}},
|
||||
{json: `{"options": {"trackExistence": false}}`, expected: postIndexRequest{Options: pilosa.IndexOptions{TrackExistence: false}}},
|
||||
{json: `{"options": {"keys": true}}`, expected: postIndexRequest{Options: pilosa.IndexOptions{Keys: true, TrackExistence: true}}},
|
||||
{json: `{"options": 4}`, err: "options is not map[string]interface{}"},
|
||||
{json: `{"option": {}}`, err: "Unknown key: option:map[]"},
|
||||
{json: `{"options": {"badKey": "test"}}`, err: "Unknown key: badKey:test"},
|
||||
|
|
@ -53,7 +54,7 @@ func TestPostIndexRequestUnmarshalJSON(t *testing.T) {
|
|||
|
||||
if test.err == "" {
|
||||
if !reflect.DeepEqual(*actual, test.expected) {
|
||||
t.Errorf("expected: %v, but got: %v", test.expected, *actual)
|
||||
t.Errorf("expected: %v, but got: %v for JSON: %s", test.expected, *actual, test.json)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
7
index.go
7
index.go
|
|
@ -69,9 +69,10 @@ func NewIndex(path, name string) (*Index, error) {
|
|||
newAttrStore: newNopAttrStore,
|
||||
columnAttrs: nopStore,
|
||||
|
||||
broadcaster: NopBroadcaster,
|
||||
Stats: NopStatsClient,
|
||||
logger: NopLogger,
|
||||
broadcaster: NopBroadcaster,
|
||||
Stats: NopStatsClient,
|
||||
logger: NopLogger,
|
||||
trackExistence: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue