r9608: * Version 2.11.9
[clsql.git] / sql / syntax.lisp
index c265f634917769e625648c89e7b2d864096269d5..514f410438ede39fb8f33c09c37c435b2a60832c 100644 (file)
@@ -89,7 +89,7 @@ reader syntax is disabled."
   (declare (ignore char))
   (let ((sqllist (read-delimited-list #\] stream t)))
     (cond ((string= (write-to-string (car sqllist)) "||")
-           (cons (sql-operator 'concat) (cdr sqllist)))
+           (cons (sql-operator 'concat-op) (cdr sqllist)))
           ((and (= (length sqllist) 1) (eql (car sqllist) '*))
            (apply #'generate-sql-reference sqllist))
           ((sql-operator (car sqllist))
@@ -114,26 +114,21 @@ reader syntax is disabled."
             (sql-expression :string (car arglist))
              (sql-expression :attribute (car arglist))))
        ((<= 2 (length arglist))
-        (let ((sqltype (if (keywordp (caddr arglist))
-                           (caddr arglist) nil))
-              (sqlparam (if (keywordp (caddr arglist))
-                            (caddr arglist))))
-          (cond
+        (let ((sqltype (when (keywordp (caddr arglist)) (caddr arglist) nil)))
+           (cond
              ((stringp (cadr arglist))
             (sql-expression :table (car arglist)
                             :alias (cadr arglist)
                             :type sqltype))
            ((keywordp (cadr arglist))
             (sql-expression :attribute (car arglist)
-                            :type (cadr arglist)
-                            :params sqlparam))
+                            :type (cadr arglist)))
            (t
             (sql-expression :attribute (cadr arglist)
                             :table (car arglist)
-                            :params sqlparam
                             :type sqltype)))))
        (t
-        (error 'clsql-sql-syntax-error :reason "bad expression syntax"))))
+        (error 'sql-user-error :message "bad expression syntax"))))
 
 
 ;; Exported functions for dealing with SQL syntax 
@@ -144,7 +139,7 @@ ARGS. The expressions are translated into SQL strings and then
 concatenated with a single space delimiting each expression."
   (format nil "~{~A~^ ~}" (mapcar #'sql-output args)))
 
-(defun sql-expression (&key string table alias attribute type params)
+(defun sql-expression (&key string table alias attribute type)
   "Returns an SQL expression constructed from the supplied arguments
 which may be combined as follows: ATTRIBUTE and TYPE; ATTRIBUTE;
 ALIAS or TABLE and ATTRIBUTE and TYPE; ALIAS or TABLE and
@@ -156,8 +151,7 @@ and ALIAS; TABLE; and STRING."
     (attribute
      (make-instance 'sql-ident-attribute  :name attribute
                     :qualifier (or table alias)
-                    :type type
-                    :params params))
+                    :type type))
     ((and table (not attribute))
      (make-instance 'sql-ident-table :name table
                     :table-alias alias))))
@@ -167,8 +161,8 @@ and ALIAS; TABLE; and STRING."
   represented by the symbol OPERATION."
   (typecase operation
     (string nil)
-    (symbol (gethash (symbol-name-default-case (symbol-name operation))
-                     *sql-op-table*))))
+    (symbol (values (gethash (symbol-name-default-case (symbol-name operation))
+                             *sql-op-table*)))))
 
 (defun sql-operation (operation &rest rest)
   "Returns an SQL expression constructed from the supplied SQL
@@ -178,6 +172,8 @@ REST is taken to be a valid SQL function and the remaining values
 in REST its arguments."
   (if (sql-operator operation)
       (apply (symbol-function (sql-operator operation)) rest)
-      (error "~A is not a recognized SQL operator." operation)))
+      (error 'sql-user-error 
+             :message 
+             (format nil "~A is not a recognized SQL operator." operation))))