X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/b7657b86f85f575d5776dc6b626b1dc258d1fa47..f4efa7fff2efa6a3144fc664683137df92c42f91:/src/rofl.lisp diff --git a/src/rofl.lisp b/src/rofl.lisp index 3d73725..9b2e6dc 100644 --- a/src/rofl.lisp +++ b/src/rofl.lisp @@ -197,14 +197,30 @@ inheritance and does not create any tables for it.")) (%select-objects type #'select query)) (defun select-only-n-objects (n type &rest query) - (let ((results (%query `(:limit ,(cons :select - (intern (format nil "*")) - (if (string-equal (first query) :from) - query - (append `(:from ,type) query))) ,n)))) + (let ((fields (if (eq :fields (car query)) + (loop + :for cons :on (cdr query) + :if (not (keywordp (car cons))) + :collect (car cons) into fields + :else :do + (setf query cons) + (return (nreverse (print fields))) + :finally + (setf query cons) + (return (nreverse (print fields)))) + + (list (intern "*"))))) + (let ((results + (%query + (print `(:limit (:select + ,@fields + ,@(if (string-equal (first query) :from) + (print query) + (append `(:from ,type) query))) + ,n))))) (if (eql 1 n) (make-object-from-plist type (first results)) - (mapcar (curry 'make-object-from-plist type) results)))) + (mapcar (curry 'make-object-from-plist type) results))))) (defun make-object-from-plist (type plist) (let* ((class (find-class type))