Write a Common Lisp macro to handle this code pattern:
(select-dao class (where-and fields-and-values class))

Problem: Macro call that should be transformed by select-dao

Macro definition:
(defmacro select-dao (class &body clauses)
  "Build custom queries with SxQL.

Example:

  (select-dao 'tweet
    (where (:like :status \"%Japan%\")))

You can use \"includes\" to eagerly load another table and prevent the \"N+1 query\" performance problem:

  (select-dao 'tweet
    (includes 'user)
    (where (:like :status \"%Japan%\")))

You can use \"joins\" to add JOIN clauses for filtering by related table columns.
Note: \"joins\" does NOT automatically load foreign objects. Use \"includes\" if you need the ghost slots populated:

  ;; Filter by related table - ghost slot NOT populated
  (select-dao 'blog
    (joins 'user)
    (where (:= :user.status \"active\")))

  ;; Filter AND load foreign objects
  (select-dao 'blog
    (joins 'user)
    (includes 'user)
    (where (:= :user.status \"active\")))

See the SxQL documentation for the available clauses and operators."
  (with-gensyms (sql clause results include-classes foreign-class)
    (once-only (class)
      `(#+sb-package-locks locally #+sb-package-locks (declare (sb-ext:disable-package-locks sxql:where))
        #-sb-package-locks cl-package-locks:with-packages-unlocked #-sb-package-locks (sxql)
        (progn
          (setf ,class (ensure-class ,class))
          (let* ((sxql:*sql-symbol-conversion* #'unlispify)
                 (,sql
                   (sxql:select :*
                                (sxql:from (sxql:make-sql-symbol (table-name ,class)))))
                 (,include-classes '()))
            (macrolet ((where (expression)
                         `(sxql:make-clause :where ,(expand-op expression ',class))))
              ;; ignore compiler-note when includes is not used
              #+sbcl (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))
              (flet ((includes (&rest classes)
                       (appendf ,include-classes (mapcar #'ensure-class classes))
                       nil)
                     (joins (foreign-class &key (type :inner))
                       (let ((foreign-class (ensure-class foreign-class)))
                         (add-child ,sql
                                   (ecase type
                                     (:inner (sxql:inner-join
                                               (sxql:make-sql-symbol (table-name foreign-class))
                                               :on (make-join-condition ,class foreign-class)))
                                     (:left (sxql:left-join
                                              (sxql:make-sql-symbol (table-name foreign-class))
                                              :on (make-join-condition ,class foreign-class)))))
                         nil)))
                (dolist (,clause (list ,@clauses))
                  (when ,clause
                    (add-child ,sql ,clause)))
                (let ((,results (select-by-sql ,class ,sql)))
                  (unless *want-cursor*
                    (dolist (,foreign-class (remove-duplicates ,include-classes))
                      (include-foreign-objects ,foreign-class ,results)))
                  (values ,results ,sql))))))))))

Macroexpansion:
(let ((#:class259 class)) (locally (declare (sb-ext:disable-package-locks where)) (progn (setf #:class259 (ensure-class #:class259)) (let* ((*sql-symbol-conversion* (function unlispify)) (#:sql254 (select :* (from (make-sql-symbol (table-name #:class259))))) (#:include-classes257 (quote nil))) (macrolet ((where (expression) (sb-int:quasiquote (make-clause :where #S(sb-impl::comma :expr (expand-op expression (quote #:class259)) :kind 0))))) (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note)) (flet ((includes (&rest classes) (appendf #:include-classes257 (mapcar (function ensure-class) classes)) nil) (joins (foreign-class &key (type :inner)) (let ((foreign-class (ensure-class foreign-class))) (add-child #:sql254 (ecase type (:inner (inner-join (make-sql-symbol (table-name foreign-class)) :on (make-join-condition #:class259 foreign-class))) (:left (left-join (make-sql-symbol (table-name foreign-class)) :on (make-join-condition #:class259 foreign-class))))) nil))) (dolist (#:clause255 (list (where-and fields-and-values class))) (when #:clause255 (add-child #:sql254 #:clause255))) (let ((#:results256 (select-by-sql #:class259 #:sql254))) (unless *want-cursor* (dolist (#:foreign-class258 (remove-duplicates #:include-classes257)) (include-foreign-objects #:foreign-class258 #:results256))) (values #:results256 #:sql254))))))))