Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Cloud 1475 (#2371)
Browse files Browse the repository at this point in the history
* working on incorporating regex logic

* Implemented a validation check for database name with given rules in doc within controller

* fixing tests to pass

* reflecting changes to match docs

* fixed tests further, hopefully

* for sure fixed integration tests, and moved validation check

* integration tests passed, go test now will pass

* fixed name size to 230 due to previous commit acknowledgement

* fixed field test negative validations

* added missing comma
  • Loading branch information
DKagan07 committed Apr 7, 2023
1 parent 7f75193 commit 24a45bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dax/controller/schemar/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewErrDatabaseIDInvalid(databaseID dax.DatabaseID) error {
func NewErrDatabaseNameInvalid(databaseName dax.DatabaseName) error {
return errors.New(
ErrCodeDatabaseNameInvalid,
fmt.Sprintf("database name '%s' is invalid", databaseName),
fmt.Sprintf("invalid database name %s", databaseName),
)
}

Expand Down
5 changes: 3 additions & 2 deletions dax/controller/sqldb/schemar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/pkg/errors"

featurebase "github.com/featurebasedb/featurebase/v3"
"github.com/featurebasedb/featurebase/v3/dax"
"github.com/featurebasedb/featurebase/v3/dax/controller/schemar"
"github.com/featurebasedb/featurebase/v3/dax/models"
Expand Down Expand Up @@ -34,8 +35,8 @@ func (s *Schemar) CreateDatabase(tx dax.Transaction, qdb *dax.QualifiedDatabase)
return schemar.NewErrDatabaseIDInvalid(qdb.ID)
}

// Ensure the database name is not blank.
if qdb.Name == "" {
// Sanitizing database name
if err := featurebase.ValidateName(string(qdb.Name)); err != nil {
return schemar.NewErrDatabaseNameInvalid(qdb.Name)
}

Expand Down
4 changes: 4 additions & 0 deletions pilosa.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func newPreconditionFailedError(err error) PreconditionFailedError {
}

// Regular expression to validate index and field names.
// The lowest limitation I've seen on any filesystem we care about is 255
// characters. 230 leaves enough space that an index or field could be
// backed up and have a timestamp and file extension appended while
// still allowing for much longer index and field names. --Jaffee
var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9Θ_-]{0,229}$`)

// TimeFormat is the go-style time format used to parse string dates.
Expand Down

0 comments on commit 24a45bc

Please sign in to comment.