Skip to content

Commit

Permalink
Merge pull request #1120 from couchbase/feature/issue_976_1.1.1
Browse files Browse the repository at this point in the history
Cherry pick fix for #976 to 1.1.1
  • Loading branch information
adamcfraser committed Sep 5, 2015
2 parents 7df2fa4 + 8cb0e8f commit 2fff9eb
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 2fff9eb

Please sign in to comment.