Hi,
I changed my code to use this function instead of (quey-dao ...)
(defun select-limited-dao (type &key (test t) limit offset order-by desc) (let ((query `(:select * :from ,type :where ,(if (stringp test) `(:raw ,test) test)))) (progn (if order-by (setf query `(:order-by ,query ,order-by))) (if desc (setf query `(:desc ,query))) (if limit (setf query `(:limit ,query ,limit ,(if offset offset ())))) (query-dao type (sql-compile query)))))
But I got a strange error testing this function. The problem is with :desc
(select-limited-dao 'entity :order-by 'column :desc t)
Database error 42601: syntax error at or near "DESC" Query: ((SELECT * FROM entity WHERE true) ORDER BY column) DESC
Then I tried with quey-dao and got the same error:
(query-dao 'entity (:desc (:order-by (:select '* :from 'entity :where t) 'column)))
Database error 42601: syntax error at or near "DESC" Query: ((SELECT * FROM entity WHERE true) ORDER BY column) DESC
I think I'm using :desc in a wrong way.
The query sent to Postgress is: "((SELECT * FROM entity WHERE true) ORDER BY column) DESC"
This quey works: "(SELECT * FROM entity WHERE true) ORDER BY column DESC"
I'm using Postgres 8.2 under OS X 10.4.10 and SBCL 1.0.6
On 9/27/07, Marijn Haverbeke marijnh@gmail.com wrote:
Hi Renato,
I guess you are right that the interface of SELECT-DAO is a bit limited, but as Ryszard says it would be hard to extend its functionality in a clean way, and, after playing with a keyword-argument implementation for a bit I concluded that providing all this functionality in such a function would basically be yet another syntax to do the same thing. So my advice is to just use QUERY-DAO for more complex cases.
Regards, Marijn _______________________________________________ postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel