From e34a3ace07250c5c55b3f6598459ef7b6d292bdb Mon Sep 17 00:00:00 2001 From: Marcus Pearce Date: Sun, 16 May 2004 11:47:13 +0000 Subject: [PATCH] r9374: Remove redundant and commonsql incompatible order-by-descending keyword arg to select. --- ChangeLog | 6 ++++++ sql/classes.lisp | 22 +++------------------- sql/objects.lisp | 10 ++-------- tests/test-oodml.lisp | 10 ++++++++++ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9eba9b9..f1764ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,12 @@ behaviour and the ANY and ALL operators in subqueries. * tests/test-init.lisp: add set-operation and subquery tests to appropriate skip lists. + * sql/objects.lisp: remove redundant and non CommonSQL compatible + ORDER-BY-DESCENDING keyword argument for SELECT. + * sql/classes.lisp: remove redundant and non CommonSQL compatible + ORDER-BY-DESCENDING keyword argument for SELECT. + * tests/test-oodml.lisp: add test for ORDER-BY keyword to SELECT + with object queries. 15 May 2004 Kevin Rosenberg (kevin@rosenberg.net) * Version 2.10.18 diff --git a/sql/classes.lisp b/sql/classes.lisp index af3ca8d..6203359 100644 --- a/sql/classes.lisp +++ b/sql/classes.lisp @@ -487,9 +487,6 @@ (order-by :initarg :order-by :initform nil) - (order-by-descending - :initarg :order-by-descending - :initform nil) (inner-join :initarg :inner-join :initform nil) @@ -520,8 +517,7 @@ (defvar *select-arguments* '(:all :database :distinct :flatp :from :group-by :having :order-by - :order-by-descending :set-operation :where :offset :limit - :inner-join :on + :set-operation :where :offset :limit :inner-join :on ;; below keywords are not a SQL argument, but these keywords may terminate select :caching :refresh)) @@ -552,7 +548,7 @@ uninclusive, and the args from that keyword to the end." :flatp flatp :refresh refresh :exp arglist)) (destructuring-bind (&key all flatp set-operation distinct from where - group-by having order-by order-by-descending + group-by having order-by offset limit inner-join on &allow-other-keys) arglist (if (null selections) @@ -564,15 +560,13 @@ uninclusive, and the args from that keyword to the end." :distinct distinct :from from :where where :limit limit :offset offset :group-by group-by :having having :order-by order-by - :order-by-descending order-by-descending :inner-join inner-join :on on)))))) (defvar *in-subselect* nil) (defmethod output-sql ((query sql-query) database) (with-slots (distinct selections from where group-by having order-by - order-by-descending limit offset inner-join on - all set-operation) + limit offset inner-join on all set-operation) query (when *in-subselect* (write-string "(" *sql-stream*)) @@ -625,16 +619,6 @@ uninclusive, and the args from that keyword to the end." (when (cdr order) (write-char #\, *sql-stream*)))) (output-sql order-by database))) - (when order-by-descending - (write-string " ORDER BY " *sql-stream*) - (if (listp order-by-descending) - (do ((order order-by-descending (cdr order))) - ((null order)) - (output-sql (car order) database) - (when (cdr order) - (write-char #\, *sql-stream*))) - (output-sql order-by-descending database)) - (write-string " DESC " *sql-stream*)) (when limit (write-string " LIMIT " *sql-stream*) (output-sql limit database)) diff --git a/sql/objects.lisp b/sql/objects.lisp index 869e643..8fa9890 100644 --- a/sql/objects.lisp +++ b/sql/objects.lisp @@ -968,8 +968,8 @@ superclass of the newly-defined View Class." (defun find-all (view-classes &rest args &key all set-operation distinct from where group-by having - order-by order-by-descending offset limit refresh - flatp result-types inner-join on + order-by offset limit refresh flatp result-types + inner-join on (database *default-database*) instances) "Called by SELECT to generate object query results when the @@ -1020,12 +1020,6 @@ superclass of the newly-defined View Class." (setq fullsels (append fullsels (mapcar #'(lambda (att) (cons nil att)) (listify ob)))))) - (dolist (ob (listify order-by-descending)) - (when (and ob (not (member ob (mapcar #'cdr fullsels) - :test #'ref-equal))) - (setq fullsels - (append fullsels (mapcar #'(lambda (att) (cons nil att)) - (listify ob)))))) (dolist (ob (listify distinct)) (when (and (typep ob 'sql-ident) (not (member ob (mapcar #'cdr fullsels) diff --git a/tests/test-oodml.lisp b/tests/test-oodml.lisp index 2ae3005..f934e5e 100644 --- a/tests/test-oodml.lisp +++ b/tests/test-oodml.lisp @@ -105,6 +105,16 @@ (employee-addresses employee2)) ((t t 2 2 2))) + (deftest :oodml/select/11 + (values (mapcar #'(lambda (x) (slot-value x 'emplid)) + (clsql:select 'employee :order-by '(([emplid] :asc)) + :flatp t)) + (mapcar #'(lambda (x) (slot-value x 'emplid)) + (clsql:select 'employee :order-by '(([emplid] :desc)) + :flatp t))) + (1 2 3 4 5 6 7 8 9 10) + (10 9 8 7 6 5 4 3 2 1)) + ;; test retrieval is deferred (deftest :oodm/retrieval/1 (every #'(lambda (e) (not (slot-boundp e 'company))) -- 2.34.1