[postmodern-devel] Quoted lists with QUERY or SQL

Marijn Haverbeke marijnh at gmail.com
Tue Nov 30 08:36:56 UTC 2010


> Is there a reason that query doesn't support evaluated lists?

Yes. These macros also accept string input, and assume that everything
that's not a list starting with a keyword will evaluate to a string.

> If so, how would you recommend this be done?

You can either add an sql-compile around your sql-expr, which does a
run-time compilation of an s-sql expression (normally they happen at
compile time), or do something like this:

(defmethod count-persistent-objects ((store list) class-name
                                     &key (where t) &allow-other-keys)
  (with-connection store
    (sql (:select (:count '*) :from class-name :where
           (:raw (if (stringp where) where (sql-compile where)))))))

Best,
Marijn




More information about the postmodern-devel mailing list