From 22383f40d8f5713af36a9baba89236bbf7e9d6c8 Mon Sep 17 00:00:00 2001 From: Ury Marshak Date: Mon, 13 Jan 2014 12:04:24 +0200 Subject: [PATCH 1/3] add missing :mongo parameter --- src/db.lisp | 3 ++- src/shell.lisp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/db.lisp b/src/db.lisp index f76fabd..eb854e1 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -278,7 +278,8 @@ Create an index specified by the keys in a collection (kv (kv "ns" (full-collection-name mongo collection)) (kv "key" (force-float index)) (spec-gen unique drop-duplicates) - (kv "name" (keys->name (ht->list index)))))))) + (kv "name" (keys->name (ht->list index)))) + :mongo mongo)))) (defmethod db.ensure-index ((collection string) (index kv-container) &key (mongo (mongo)) (unique nil) (drop-duplicates nil)) diff --git a/src/shell.lisp b/src/shell.lisp index 051cbcd..d0ccb36 100644 --- a/src/shell.lisp +++ b/src/shell.lisp @@ -4,10 +4,10 @@ shell commands |# -(defun docs (result) +(defun docs (result &key (mongo (mongo))) "Stop the iterator (if any) and return the list of documents returned by the query. -Typical ue would be in conjunction with db.find like so (docs (iter (db.find 'foo' 'll)))" - (cadr (db.stop result))) +Typical use would be in conjunction with db.find like so (docs (iter (db.find 'foo' 'll)))" + (cadr (db.stop result :mongo mongo))) (defun iter (result &key (mongo (mongo)) (max-per-call 0)) "Exhaustively iterate through a query. The maximum number of responses From e4f2f39133717ec7cf87bc6915349670e478296d Mon Sep 17 00:00:00 2001 From: Chris Laux Date: Sun, 2 Mar 2014 12:40:27 +0100 Subject: [PATCH 2/3] Bug fix: bson-encode for bson-binary called itself instead of call-next-method, infinite loop resulted --- src/bson.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bson.lisp b/src/bson.lisp index 1bb64f6..719c45a 100644 --- a/src/bson.lisp +++ b/src/bson.lisp @@ -83,7 +83,7 @@ (add-octets (byte-to-octet (type-id value)) array) (add-octets (int32-to-octet (length (data value))) array) (add-octets (data value) array))) - (bson-encode key value :array array :type type :encoder #'encode-value)))) + (call-next-method key value :array array :type type :encoder #'encode-value)))) ; ; The array type is the parent class of other types like string. So see if a type and encoder is From 98ecfe7460287420fae6aeff97c15ded30730e43 Mon Sep 17 00:00:00 2001 From: Chris Laux Date: Sun, 2 Mar 2014 13:52:39 +0100 Subject: [PATCH 3/3] Bug fix: offset needs be relative from pos if it is to be used as an index into array --- src/bson-decode.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bson-decode.lisp b/src/bson-decode.lisp index 55825b1..0e75c49 100644 --- a/src/bson-decode.lisp +++ b/src/bson-decode.lisp @@ -60,7 +60,7 @@ (size (if (eql type #x02) (octet-to-int32.1 array (+ pos 5)) (octet-to-int32.1 array pos))) - (offset (if (eql type #x02) 9 5)) + (offset (+ pos (if (eql type #x02) 9 5))) (binary (bson-binary type (subseq array offset (+ offset size))))) (setf (gethash key ht) binary) (incf pos totalsize)))