commit b249207fe33654e4b28a04c0b59783c3f203a214
parent d15ecde1a4b1fcb213d30ebbadda38e324f74c35
Author: Tomas Hlavaty <tom@logand.com>
Date: Sun, 31 Jul 2011 19:01:06 +0200
2sql-query introduced
Diffstat:
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/core.lisp b/core.lisp
@@ -49,14 +49,22 @@
lvars
lforms)))
-(defmacro 2sql-lambda (form) ;; TODO lforms
- `(lambda ()
- , (flet ((paste (x)
- (when x
- `(list ,@x))))
- (multiple-value-bind (str lvars lforms) (2sql-string form)
- `(values
+(defun 2sql-lambda (form) ;; TODO lforms
+ (multiple-value-bind (str lvars lforms) (2sql-string form)
+ (flet ((paste (x)
+ (when x
+ `(list ,@x))))
+ (let ((vars (mapcar #'car lvars)))
+ (values
+ `(lambda (,@vars)
+ (values
,str
- ,(paste (mapcar (lambda (x) (car x)) lvars))
+ ,(paste vars)
,(paste (mapcar #'cdr lvars))
- ,(paste (mapcar (lambda (x) `(funcall (lambda () ,@x))) lforms)))))))
+ #+nil
+ ,(paste (mapcar (lambda (x) `(funcall (lambda () ,@x))) lforms))))
+ vars)))))
+
+(defmacro 2sql-query (form)
+ (multiple-value-bind (fn vars) (2sql-lambda form)
+ `(funcall ,fn ,@vars)))