X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=inline;f=sql%2Fexpressions.lisp;h=16e967bee67d2a4f07e66f0a22a22955a6b275e0;hb=11161049fd7a9a3a8a71b7999cca5d8e8fee8cca;hp=63885153259d9fad208f1a9bc3636372936e340e;hpb=5bd17e4032ba3987db4af25b89fc939056896512;p=clsql.git diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 6388515..16e967b 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -257,6 +257,28 @@ (write-char #\) *sql-stream*))) t) +(defclass sql-array-exp (sql-relational-exp) + () + (:documentation "An SQL relational expression.")) + +(defmethod output-sql ((expr sql-array-exp) database) + (with-slots (operator sub-expressions) + expr + (let ((subs (if (consp (car sub-expressions)) + (car sub-expressions) + sub-expressions))) + (write-char #\( *sql-stream*) + (output-sql operator database) + (write-char #\[ *sql-stream*) + (do ((sub subs (cdr sub))) + ((null (cdr sub)) (output-sql (car sub) database)) + (output-sql (car sub) database) + (write-char #\, *sql-stream*) + (write-char #\Space *sql-stream*)) + (write-char #\] *sql-stream*) + (write-char #\) *sql-stream*))) + t) + (defclass sql-upcase-like (sql-relational-exp) () (:documentation "An SQL 'like' that upcases its arguments.")) @@ -565,6 +587,9 @@ uninclusive, and the args from that keyword to the end." (write-string "SELECT " *sql-stream*) (when all (write-string "ALL " *sql-stream*)) + (when (and limit (eq :odbc (database-type database))) + (write-string " TOP " *sql-stream*) + (output-sql limit database)) (when (and distinct (not all)) (write-string "DISTINCT " *sql-stream*) (unless (eql t distinct) @@ -634,7 +659,7 @@ uninclusive, and the args from that keyword to the end." (when (cdr order) (write-char #\, *sql-stream*)))) (output-sql order-by database))) - (when limit + (when (and limit (not (eq :odbc (database-type database)))) (write-string " LIMIT " *sql-stream*) (output-sql limit database)) (when offset