fons / cl-mongo

lisp interface to mongo db
fons.github.com/cl-mongo
MIT License
142 stars 31 forks source link

`$map-reduce` ParenScript problem. #27

Closed EuAndreh closed 8 years ago

EuAndreh commented 9 years ago

I couldn't get $map-reduce to work properly. I'm not sure if I'm doing anything wrong or the ParenScript is blocking me:

(dotimes (i 3)
 (let ((doc (make-document)))
   (add-element "mykey" "xxx" doc)
   (db.insert "mycoll" doc)))
; => NIL

(defjs my-map ()
  (emit this.mykey))
; in: CL-MONGO:DEFJS MY-PACKAGE::MY-MAP
;     (PARENSCRIPT:PS
;       (LAMBDA () (MY-PACKAGE::EMIT MY-PACKAGE::THIS.MY-KEY)))
; 
; caught WARNING:
;   Symbol THIS.MY-KEY contains one of '.[]' - this compound naming convention is no longer supported by Parenscript!
; 
; compilation unit finished
;   caught 1 WARNING condition
STYLE-WARNING: redefining MY-PACKAGE::MY-MAP in DEFUN
; => MY-MAP

(defjs my-reduce (k vals)
  (return vals))
; in: DEFJS MY-REDUCE
;     (PARENSCRIPT:PS
;       (LAMBDA (MY-PACKAGE::K MY-PACKAGE::VALS) (RETURN MY-PACKAGE::VALS)))
; 
; caught WARNING:
;   Returning from unknown block nilBlock
; 
; compilation unit finished
;   caught 1 WARNING condition
STYLE-WARNING: redefining MY-PACKAGE::MY-REDUCE in DEFUN
; => MY-REDUCE

(mr.p ($map-reduce "mycoll" #'my-map #'my-reduce))
; => ((36 128 0 1 8 0 0 0 "mr.mycoll") NIL)

Is this a ParenScript problem or I'm doing something wrong?