Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
seeforschauer committed Jul 6, 2022
1 parent 426b00d commit 0a29aed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ and [contributing guidelines](CONTRIBUTING.md).

* collection name cannot start with the reserved prefix `_ferretdb_`.
* collection name must not include non-latin letters, spaces, dots, dollars or dashes.
* collection name length must be less than 119 symbols.
* collection name length must be less or equal than 119 symbols.
* collection name must not start with a number.

If you encounter some other difference in behavior, please [join our community](#community) to report a problem.

Expand Down
10 changes: 5 additions & 5 deletions internal/handlers/pg/pgdb/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (pgPool *Pool) Tables(ctx context.Context, schema string) ([]string, error)

filtered := make([]string, 0, len(tables))
for _, table := range tables {
if strings.HasPrefix(table, collectionPrefix) {
if strings.HasPrefix(table, reservedCollectionPrefix) {
continue
}

Expand Down Expand Up @@ -353,15 +353,15 @@ func (pgPool *Pool) DropDatabase(ctx context.Context, db string) error {
// CreateCollection creates a new FerretDB collection in existing schema.
//
// It returns:
// - ErrInvalidTableName - if the table name doesn't conform to restrictions.
// - ErrAlreadyExist - if table already exist.
// - ErrTableNotExist - is schema does not exist.
// * ErrInvalidTableName - if the table name doesn't conform to restrictions.
// * ErrAlreadyExist - if table already exist.
// * ErrTableNotExist - is schema does not exist.
func (pgPool *Pool) CreateCollection(ctx context.Context, db, collection string) error {
if !validateCollectionNameRe.MatchString(collection) {
return ErrInvalidTableName
}

if strings.HasPrefix(collection, collectionPrefix) {
if strings.HasPrefix(collection, reservedCollectionPrefix) {
return ErrInvalidTableName
}

Expand Down
4 changes: 2 additions & 2 deletions internal/handlers/pg/pgdb/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import (

const (
// Internal collections prefix.
collectionPrefix = "_ferretdb_"
reservedCollectionPrefix = "_ferretdb_"

// Settings table name.
settingsTableName = collectionPrefix + "settings"
settingsTableName = reservedCollectionPrefix + "settings"

// PostgreSQL max table name length.
maxTableNameLength = 63
Expand Down

0 comments on commit 0a29aed

Please sign in to comment.