Skip to content

Commit

Permalink
Deprecate dotted fields in data documents (#1313)
Browse files Browse the repository at this point in the history
Closes #659.
  • Loading branch information
Dmitry authored Oct 28, 2022
1 parent f996a91 commit 05be2d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion internal/types/document_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ func (d *Document) ValidateData() error {

// Tests for this case are in `dance`.
if strings.Contains(key, "$") {
return newValidationError(fmt.Errorf("invalid key: %q (key must not contain $)", key))
return newValidationError(fmt.Errorf("invalid key: %q (key must not contain '$' sign)", key))
}

// Tests for this case are in `dance`.
if strings.Contains(key, ".") {
return newValidationError(fmt.Errorf("invalid key: %q (key must not contain '.' sign)", key))
}

if _, ok := duplicateChecker[key]; ok {
Expand Down
8 changes: 6 additions & 2 deletions internal/types/document_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ func TestDocumentValidateData(t *testing.T) {
doc: must.NotFail(NewDocument("\xf4\x90\x80\x80", "bar")), // the key is out of range for UTF-8
reason: errors.New(`invalid key: "\xf4\x90\x80\x80" (not a valid UTF-8 string)`),
},
"KeyContains$": {
"KeyContainsDollarSign": {
doc: must.NotFail(NewDocument("$v", "bar")),
reason: errors.New(`invalid key: "$v" (key must not contain $)`),
reason: errors.New(`invalid key: "$v" (key must not contain '$' sign)`),
},
"KeyContainsDotSign": {
doc: must.NotFail(NewDocument("v.foo", "bar")),
reason: errors.New(`invalid key: "v.foo" (key must not contain '.' sign)`),
},
"Inf+": {
doc: must.NotFail(NewDocument("v", math.Inf(1))),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 6

1. FerretDB uses the same protocol error names and codes, but the exact error messages may be different in some cases.
2. FerretDB does not support NUL (`\0`) characters in strings.
3. Document keys must not contain `$` sign.
3. Document keys must not contain `$` or `.` signs.
4. Database and collection names restrictions:
* name cannot start with the reserved prefix `_ferretdb_`;
* database name must not include non-latin letters, spaces, dots, dollars or dashes;
Expand Down

1 comment on commit 05be2d5

@vercel
Copy link

@vercel vercel bot commented on 05be2d5 Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ferret-db – ./

ferret-db.vercel.app
ferret-db-ferretdb.vercel.app
ferret-db-git-main-ferretdb.vercel.app

Please sign in to comment.