X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Foperations.lisp;h=faa22b5af7a8788aea28ef66d14b7b5619edf734;hp=a3f6bbd09fefd79a504f78f95f87e92a1fa4fb3f;hb=HEAD;hpb=e567409d9fff3f7231c2a0bb69b345e19de2b246 diff --git a/sql/operations.lisp b/sql/operations.lisp index a3f6bbd..faa22b5 100644 --- a/sql/operations.lisp +++ b/sql/operations.lisp @@ -1,8 +1,6 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id$ -;;;; ;;;; Definition of SQL operations used with the symbolic SQL syntax. ;;;; ;;;; This file is part of CLSQL. @@ -48,6 +46,9 @@ (make-instance 'sql-function-exp :name 'all :args rest)) +(defsql sql-e-string (:symbol "E") (&rest rest) + (make-instance 'sql-escape-string-exp :string (first rest))) + (defsql sql-not (:symbol "not") (&rest rest) (make-instance 'sql-value-exp :modifier 'not :components rest)) @@ -74,25 +75,30 @@ (defsql sql-group-by (:symbol "group-by") (&rest rest) (make-instance 'sql-query-modifier-exp - :modifier '|group by| :components rest)) + :modifier '|GROUP BY| :components rest)) (defsql sql-order-by (:symbol "order-by") (&rest rest) (make-instance 'sql-query-modifier-exp - :modifier '|order by| :components rest)) + :modifier '|ORDER BY| :components rest)) (defsql sql-having (:symbol "having") (&rest rest) (make-instance 'sql-query-modifier-exp :modifier 'having :components rest)) -(defsql sql-null (:symbol "null") (&rest rest) - (if rest +(defsql sql-null (:symbol "null") (&optional not-null-thing) + (if not-null-thing (make-instance 'sql-relational-exp :operator 'is - :sub-expressions (list (car rest) nil)) + :sub-expressions (list not-null-thing nil)) (make-instance 'sql-value-exp :components 'null))) -(defsql sql-not-null (:symbol "not-null") () - (make-instance 'sql-value-exp - :components '|NOT NULL|)) +(defsql sql-not-null (:symbol "not-null") (&optional not-null-thing) + (if not-null-thing + (make-instance + 'sql-relational-exp + :operator 'IS + :sub-expressions (list not-null-thing + (sql-expression :string "NOT NULL"))) + (sql-expression :string "NOT NULL"))) (defsql sql-exists (:symbol "exists") (&rest rest) (make-instance 'sql-function-exp