mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
Cloud 1475 (#2371)
* 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
This commit is contained in:
parent
7f75193cf2
commit
24a45bc30d
3 changed files with 8 additions and 3 deletions
|
|
@ -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),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue