From 53bf64089da7f091d748f46eb95ebeb39d990dd9 Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Thu, 3 Sep 2009 17:34:38 -0400 Subject: [PATCH] Pulled a flet out into a method (select-table-sql-expr) which can be overridden to supply a different implementation. The impetus for this is that I wanted to select from a function's results aliased as the table instead of the table directly. --- sql/oodml.lisp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sql/oodml.lisp b/sql/oodml.lisp index 2a5b051..9aff2c8 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -874,6 +874,10 @@ maximum of MAX-LEN instances updated in each query." (car objects) objects)))) +(defmethod select-table-sql-expr ((table T)) + "Turns an object representing a table into the :from part of the sql expression that will be executed " + (sql-expression :table (view-table table))) + (defun find-all (view-classes &rest args &key all set-operation distinct from where group-by having @@ -887,8 +891,6 @@ maximum of MAX-LEN instances updated in each query." (flet ((ref-equal (ref1 ref2) (string= (sql-output ref1 database) (sql-output ref2 database))) - (table-sql-expr (table) - (sql-expression :table (view-table table))) (tables-equal (table-a table-b) (when (and table-a table-b) (string= (string (slot-value table-a 'name)) @@ -914,15 +916,15 @@ maximum of MAX-LEN instances updated in each query." (fullsels (apply #'append (mapcar #'append sels immediate-join-sels))) (sel-tables (collect-table-refs where)) (tables (remove-if #'null - (remove-duplicates - (append (mapcar #'table-sql-expr sclasses) - (mapcan #'(lambda (jc-list) - (mapcar - #'(lambda (jc) (when jc (table-sql-expr jc))) - jc-list)) - immediate-join-classes) - sel-tables) - :test #'tables-equal))) + (remove-duplicates + (append (mapcar #'select-table-sql-expr sclasses) + (mapcan #'(lambda (jc-list) + (mapcar + #'(lambda (jc) (when jc (select-table-sql-expr jc))) + jc-list)) + immediate-join-classes) + sel-tables) + :test #'tables-equal))) (order-by-slots (mapcar #'(lambda (ob) (if (atom ob) ob (car ob))) (listify order-by))) (join-where nil)) -- 2.34.1