[clouchdb-cvs] CVS clouchdb/src
peddy
peddy at common-lisp.net
Wed Jul 15 01:32:28 UTC 2009
Update of /project/clouchdb/cvsroot/clouchdb/src
In directory cl-net:/tmp/cvs-serv22082
Modified Files:
tests.lisp clouchdb.lisp changelog.txt
Log Message:
Added conflicts keyword parameter to get-document, tests
--- /project/clouchdb/cvsroot/clouchdb/src/tests.lisp 2009/07/12 18:46:53 1.22
+++ /project/clouchdb/cvsroot/clouchdb/src/tests.lisp 2009/07/15 01:32:28 1.23
@@ -685,6 +685,12 @@
(ensure-same 1 (length attachments))
(ensure (find :|tests2.lisp| attachments :key #'car))))
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Make shure conflicts don't appear when they shouldn't")
+ test-no-conflicts
+ (ensure (create-document '((:name . "hi")) :id "hi"))
+ (ensure-null (document-property :|_conflicts| (get-document "hi"))))
+
;;
;; Replication Tests.
;;
@@ -742,6 +748,22 @@
(let ((target *couchdb*))
(replicate target :source source)))))))
+(addtest (clouchdb-replication-tests)
+ (:documentation "test abilty to get document merge conflicts")
+ db-replicate-doc-conflict
+ (let ((db1 *couchdb*))
+ (with-temp-db
+ (create-document '((name . "foo")) :id "x")
+ (replicate db1)
+ (put-document (set-document-property
+ (get-document "x") :name "bar"))
+ (let ((*couchdb* db1))
+ (put-document (set-document-property
+ (get-document "x") :name "baz")))
+ (replicate db1)
+ (replicate *couchdb* :source db1)
+ (ensure (document-property :|_conflicts| (get-document "x" :conflicts t))))))
+
;;
;; View API Tests
;;
--- /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp 2009/07/12 18:46:53 1.39
+++ /project/clouchdb/cvsroot/clouchdb/src/clouchdb.lisp 2009/07/15 01:32:28 1.40
@@ -483,16 +483,16 @@
:document-update-fn document-update-fn
:document-fetch-fn document-fetch-fn)))
-(defmacro with-connection ((&key (db *couchdb*) name port protocol
+(defmacro with-connection ((&key db name port protocol
host document-update-fn
document-fetch-fn) &body body)
"Execute body in the context of the specified database connection
information.."
- `(let ((*couchdb* (make-db :db ,db
- :name ,name :port ,port
- :protocol ,protocol :host ,host
- :document-fetch-fn ,document-fetch-fn
- :document-update-fn ,document-update-fn)))
+ `(let ((*couchdb* (make-db :db ,(or db *couchdb*)
+ :name ,name :port ,port
+ :protocol ,protocol :host ,host
+ :document-fetch-fn ,document-fetch-fn
+ :document-update-fn ,document-update-fn)))
(progn , at body)))
(defun document-properties (document)
@@ -649,7 +649,7 @@
:parameters (transform-params options *view-options*)
:content (if keys (document-to-json `((:|keys| . ,keys)))))))
-(defun get-document (id &key revision revisions
+(defun get-document (id &key revision revisions conflicts
revision-info (if-missing nil if-missing-p))
"Get a document by ID. Returns nil if the document does not exist.
The revision property specifies an optional revision number, if
@@ -662,6 +662,7 @@
(unless id
(error 'id-missing))
(let ((parameters))
+ (when conflicts (push (cons "conflicts" "true") parameters))
(when revision
(push (cons "rev" (value-as-string revision)) parameters))
(when revisions
--- /project/clouchdb/cvsroot/clouchdb/src/changelog.txt 2009/07/06 22:24:45 1.10
+++ /project/clouchdb/cvsroot/clouchdb/src/changelog.txt 2009/07/15 01:32:28 1.11
@@ -1,4 +1,7 @@
+0.0.12:
+ - Added missing conflicts keyword parameter to get-document, tests
+
0.0.11:
- Switched to using a structure to hold the database connection
More information about the clouchdb-cvs
mailing list