From fb93f90f3162ac71e10d83f66aba15e1fb40b9f9 Mon Sep 17 00:00:00 2001 From: Shaquille Wyan Que Date: Mon, 13 May 2019 11:20:50 -0500 Subject: [PATCH] fixed error message returned by regex on field and index names --- docs/getting-started.md | 1 + docs/query-language.md | 2 +- go.sum | 1 + pilosa.go | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 45473d7ec..c7dd54a8c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -63,6 +63,7 @@ curl localhost:10101/index/repository -X POST ``` response {"success":true} ``` +The index name must be 64 characters or less, start with a letter, and consist only of lowercase alphanumeric characters or `_-`. Let's create the `stargazer` field which has user IDs of stargazers as its rows: ``` request diff --git a/docs/query-language.md b/docs/query-language.md index 408a967bc..0064401cc 100644 --- a/docs/query-language.md +++ b/docs/query-language.md @@ -43,7 +43,7 @@ curl localhost:10101/index/repository/query \ #### Arguments and Types -* `field` The field specifies on which Pilosa [field](../glossary/#field) the query will operate. Valid field names are lower case strings; they start with an alphanumeric character, and contain only alphanumeric characters and `_-`. They must be 64 characters or less in length. +* `field` The field specifies on which Pilosa [field](../glossary/#field) the query will operate. Valid field names are lower case strings; they start with a lowercase letter, and contain only alphanumeric characters and `_-`. They must be 64 characters or less in length. * `TIMESTAMP` This is a timestamp in the following format `YYYY-MM-DDTHH:MM` (e.g. 2006-01-02T15:04) * `UINT` An unsigned integer (e.g. 42839) * `BOOL` A boolean value, `true` or `false` diff --git a/go.sum b/go.sum index f12f88d07..674e2adea 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190429231329-9d4d845e86f1 h1:MSSXVSCgrxTAYytvleklMKlLdxjexiJWNffJciO1nCI= golang.org/x/tools v0.0.0-20190429231329-9d4d845e86f1/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pilosa.go b/pilosa.go index 88510cef9..42ab3d3c1 100644 --- a/pilosa.go +++ b/pilosa.go @@ -48,7 +48,7 @@ var ( ErrInvalidView = errors.New("invalid view") ErrInvalidCacheType = errors.New("invalid cache type") - ErrName = errors.New("invalid index or field name, must match [a-z0-9_-]") + ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 64 characters") ErrLabel = errors.New("invalid row or column label, must match [A-Za-z0-9_-]") // ErrFragmentNotFound is returned when a fragment does not exist. @@ -152,7 +152,7 @@ func (cas ColumnAttrSet) MarshalJSON() ([]byte, error) { // TimeFormat is the go-style time format used to parse string dates. const TimeFormat = "2006-01-02T15:04" -// validateName ensures that the name is a valid format. +// validateName ensures that the index or field name is a valid format. func validateName(name string) error { if !nameRegexp.Match([]byte(name)) { return errors.Wrapf(ErrName, "'%s'", name)