Skip to content

Commit

Permalink
Added check to skip properties with empty key value when checking for…
Browse files Browse the repository at this point in the history
… user special (_........) properties
  • Loading branch information
Andrew Reslan authored and adamcfraser committed Sep 5, 2015
1 parent 7df2fa4 commit 8cb0e8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/github.com/couchbase/sync_gateway/db/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,20 @@ func TestPutWithUserSpecialProperty(t *testing.T) {
assert.True(t, err.Error() == "400 user defined top level properties beginning with '_' are not allowed in document body")
}

// Unit test for issue #976
func TestWithNullPropertyKey(t *testing.T) {
db := setupTestDB(t)
defer tearDownTestDB(t, db)

// Test creating a document with null property key
customDocId := "customIdValue"
log.Printf("Create document with empty property key")
body := Body{"_id": customDocId, "": "value1"}
docid, rev1id, _ := db.Post(body)
assert.True(t, rev1id != "")
assert.True(t, docid != "")
}

// Unit test for issue #507
func TestPostWithUserSpecialProperty(t *testing.T) {
db := setupTestDB(t)
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/couchbase/sync_gateway/db/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func stripSpecialProperties(body Body) Body {

func containsUserSpecialProperties(body Body) bool {
for key, _ := range body {
if key[0] == '_' && key != "_id" && key != "_rev" && key != "_deleted" && key != "_attachments" && key != "_revisions" {
if key != "" && key[0] == '_' && key != "_id" && key != "_rev" && key != "_deleted" && key != "_attachments" && key != "_revisions" {
return true
}
}
Expand Down

0 comments on commit 8cb0e8f

Please sign in to comment.