Skip to content

Commit

Permalink
Merge branch 'main' into clarify
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 28, 2022
2 parents 649fa79 + 05be2d5 commit f6153bd
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 @@ -11,7 +11,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

0 comments on commit f6153bd

Please sign in to comment.