mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 23:31:03 +00:00
fix review
This commit is contained in:
parent
69cfdb0df9
commit
c6a502efed
4 changed files with 10 additions and 27 deletions
10
client.go
10
client.go
|
|
@ -194,11 +194,6 @@ func (c *Client) ExecuteQuery(ctx context.Context, db, query string, allowRedire
|
|||
return nil, ErrQueryRequired
|
||||
}
|
||||
|
||||
er := ValidateName(db)
|
||||
if er != nil {
|
||||
return nil, ErrName
|
||||
}
|
||||
|
||||
// Encode query request.
|
||||
buf, err := proto.Marshal(&internal.QueryRequest{
|
||||
DB: db,
|
||||
|
|
@ -255,11 +250,6 @@ func (c *Client) ExecutePQL(ctx context.Context, db, query string) (interface{},
|
|||
}.Encode(),
|
||||
}
|
||||
|
||||
er := ValidateName(db)
|
||||
if er != nil {
|
||||
return nil, ErrName
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", u.String(), bytes.NewReader([]byte(query)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
6
db.go
6
db.go
|
|
@ -49,9 +49,9 @@ type DB struct {
|
|||
|
||||
// NewDB returns a new instance of DB.
|
||||
func NewDB(path, name string) (*DB, error) {
|
||||
err := ValidateName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
validName := Exp.FindStringSubmatchIndex(name)
|
||||
if len(validName) == 0 {
|
||||
return nil, ErrName
|
||||
}
|
||||
|
||||
return &DB{
|
||||
|
|
|
|||
6
frame.go
6
frame.go
|
|
@ -47,9 +47,9 @@ type Frame struct {
|
|||
|
||||
// NewFrame returns a new instance of frame.
|
||||
func NewFrame(path, db, name string) (*Frame, error) {
|
||||
err := ValidateName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
validName := Exp.FindStringSubmatchIndex(name)
|
||||
if len(validName) == 0 {
|
||||
return nil, ErrName
|
||||
}
|
||||
|
||||
return &Frame{
|
||||
|
|
|
|||
15
pilosa.go
15
pilosa.go
|
|
@ -20,13 +20,16 @@ var (
|
|||
ErrFrameNotFound = errors.New("frame not found")
|
||||
|
||||
// ErrFrameRequired is returned when no frame is specified.
|
||||
ErrName = errors.New("name restricted to [a-z0-9_-.]")
|
||||
ErrName = errors.New("name restricted to [a-z0-9_-]")
|
||||
|
||||
// ErrFragmentNotFound is returned when a fragment does not exist.
|
||||
ErrFragmentNotFound = errors.New("fragment not found")
|
||||
ErrQueryRequired = errors.New("query required")
|
||||
)
|
||||
|
||||
// Regular expression to valuate db and frame's name
|
||||
var Exp = regexp.MustCompile(`^([a-z0-9._-]{1,64}$)`)
|
||||
|
||||
// Profile represents vertical column in a database.
|
||||
// A profile can have a set of attributes attached to it.
|
||||
type Profile struct {
|
||||
|
|
@ -79,13 +82,3 @@ func decodeProfile(pb *internal.Profile) *Profile {
|
|||
|
||||
// TimeFormat is the go-style time format used to parse string dates.
|
||||
const TimeFormat = "2006-01-02T15:04"
|
||||
|
||||
// Restrict name using regex
|
||||
func ValidateName(name string) error {
|
||||
expr := regexp.MustCompile(`^([a-z0-9._-]{1,64}$)`)
|
||||
validName := expr.FindStringSubmatchIndex(name)
|
||||
if len(validName) == 0 {
|
||||
return ErrName
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue