cl-2sql

Lisp to SQL compiler for Common Lisp
git clone https://logand.com/git/cl-2sql.git/
Log | Files | Refs | README | LICENSE

commit 51c9d9408159416facf8762b5bcb06dede37b509
parent deb68a4c3541769f4fd118995d63f8c6a461ac15
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 13 Aug 2011 19:54:43 +0200

2sql-macros update

Diffstat:
Mmacros.lisp | 30++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/macros.lisp b/macros.lisp @@ -218,11 +218,16 @@ `(prefix ,value ,operation)) (defsyntax values (&body values) - `(prefix :values (par (clist ,@values)))) + (cl:when values `(prefix :values (par (clist ,@values))))) (defsyntax insert-into (tab cols &body body) ;; body (values...) | (select...) - `(prefix :insert :into ,tab (par (clist ,@cols)) ,@body)) + `(prefix :insert :into ,tab + ,@(cl:when cols `((par (clist ,@cols)))) + ,@(cl:loop + :for x :in body + :when (cl:macroexpand x) + :collect x))) (defsyntax returning (cols &optional vars) ;; oracle; better (k1 v1) (k2 v2)... `(backend-ecase @@ -319,9 +324,14 @@ (defsyntax unless (test &body body) `(if ,test (false-value) ,body)) +(defsyntax gt0 (exp) `(< 0 ,exp)) +(defsyntax ge0 (exp) `(<= 0 ,exp)) +(defsyntax lt0 (exp) `(< ,exp 0)) +(defsyntax le0 (exp) `(<= ,exp 0)) + (defsyntax zerop (exp) `(= 0 ,exp)) -(defsyntax plusp (exp) `(< 0 ,exp)) -(defsyntax minusp (exp) `(< ,exp 0)) +(defsyntax plusp (exp) `(gt0 ,exp)) +(defsyntax minusp (exp) `(lt ,exp)) ;;(plusp (+ 1 2 3)) @@ -562,19 +572,19 @@ (defsyntax blob-type () `(backend-ecase (:oracle :blob) - (:postgresql (prefix :binary :large :object)))) + (:postgresql :bytea))) (defsyntax date-type () - '(:date)) + :date) (defsyntax time-type () - '(:time)) + :time) (defsyntax timestamp-type () - '(:timestamp)) + :timestamp) (defsyntax timestamp-with-timezone-type () - '(:timestamp :with :time :zone)) + '(prefix :timestamp :with :time :zone)) (defsyntax interval-type () `(backend-ecase @@ -589,7 +599,7 @@ (defsyntax char-type (&optional size) `(backend-ecase (:oracle ,(cl:if (cl:eql 1 size) - (cl:error "CHAR(1) is reserved for booleans") + (cl:error "CHAR(1) is reserved for boolean type") `(char-sized-type :char ,size))) (:postgresql (char-sized-type :char ,size))))