diff options
| -rw-r--r-- | share/www/script/test/replication.js | 22 | ||||
| -rw-r--r-- | src/couchdb/couch_doc.erl | 9 | 
2 files changed, 28 insertions, 3 deletions
| diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js index 944c8e47..f069dc89 100644 --- a/share/www/script/test/replication.js +++ b/share/www/script/test/replication.js @@ -72,6 +72,7 @@ couchTests.replication = function(debug) {        },       deletes_test: new function () { +        // make sure deletes are replicated          this.init = function(dbA, dbB) {            T(dbA.save({_id:"foo1",value:"a"}).ok);          }; @@ -90,6 +91,27 @@ couchTests.replication = function(debug) {          };        }, +      deleted_test : new function() { +        // docs created and deleted on a single node are also replicated +        this.init = function(dbA, dbB) { +          T(dbA.save({_id:"del1",value:"a"}).ok); +          var docA = dbA.open("del1"); +          dbA.deleteDoc(docA); +        }; +         +        this.afterAB1 = function(dbA, dbB) { +          var rows = dbB.allDocsBySeq().rows; +          var rowCnt = 0; +          for (var i=0; i < rows.length; i++) { +            if (rows[i].id == "del1") { +              rowCnt += 1; +              T(rows[i].value.deleted == true); +            } +          }; +          T(rowCnt == 1); +        }; +      }, +              slashes_in_ids_test: new function () {          // make sure docs with slashes in id replicate properly          this.init = function(dbA, dbB) { diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl index fc817d56..3c4fd98c 100644 --- a/src/couchdb/couch_doc.erl +++ b/src/couchdb/couch_doc.erl @@ -129,9 +129,12 @@ from_json_obj(_Other) ->  parse_rev(Rev) when is_binary(Rev) ->      parse_rev(?b2l(Rev));  parse_rev(Rev) -> -    {Pos, [$- | RevId]} = lists:splitwith(fun($-) -> false; (_) -> true end, Rev), -    {list_to_integer(Pos), ?l2b(RevId)}. - +    SplitRev = lists:splitwith(fun($-) -> false; (_) -> true end, Rev), +    case SplitRev of  +        {Pos, [$- | RevId]} -> {list_to_integer(Pos), ?l2b(RevId)}; +        _Else -> throw({bad_request, <<"Invalid rev format">>}) +    end. +      parse_revs([]) ->      [];  parse_revs([Rev | Rest]) -> | 
