X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fexpressions.lisp;h=c7236a454f56cb4c4c08a102c4ee61381c162996;hb=4edcfb48e6b87dee64a8be20e2ac79b5266538ba;hp=2b9b913da4685ed9180d0abd5156015092037ff9;hpb=43ebc59a11ebc66f3405e85f6aba5351ab707fb3;p=clsql.git diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 2b9b913..c7236a4 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -586,12 +586,16 @@ uninclusive, and the args from that keyword to the end." (when *in-subselect* (write-string "(" *sql-stream*)) (write-string "SELECT " *sql-stream*) + (when (and limit (eql :mssql (database-underlying-type database))) + (write-string " TOP " *sql-stream*) + (output-sql limit database) + (write-string " " *sql-stream*)) (when all - (write-string "ALL " *sql-stream*)) + (write-string " ALL " *sql-stream*)) (when (and distinct (not all)) - (write-string "DISTINCT " *sql-stream*) + (write-string " DISTINCT " *sql-stream*) (unless (eql t distinct) - (write-string "ON " *sql-stream*) + (write-string " ON " *sql-stream*) (output-sql distinct database) (write-char #\Space *sql-stream*))) (let ((*in-subselect* t)) @@ -657,7 +661,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 (eql :mssql (database-underlying-type database)))) (write-string " LIMIT " *sql-stream*) (output-sql limit database)) (when offset @@ -797,9 +801,9 @@ uninclusive, and the args from that keyword to the end." (declaim (inline listify)) (defun listify (x) - (if (atom x) - (list x) - x)) + (if (listp x) + x + (list x))) (defmethod output-sql ((stmt sql-create-table) database) (flet ((output-column (column-spec)