Pulled a flet out into a method (select-table-sql-expr) which can be
authorRuss Tyndall <russ@acceleration.net>
Thu, 3 Sep 2009 21:34:38 +0000 (17:34 -0400)
committerNathan Bird <nathan@acceleration.net>
Thu, 30 Jun 2011 20:56:28 +0000 (16:56 -0400)
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.

  prev: 53bf64089da7f091d748f46eb95ebeb39d990dd9

sql/oodml.lisp

index ec54a346aa8db48b3d1b500fd3e0ec79b168738b..fced9aad186871523aa8a309a3dc5cf3ef612cbc 100644 (file)
@@ -1075,6 +1075,11 @@ 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
@@ -1088,8 +1093,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))
@@ -1116,10 +1119,10 @@ maximum of MAX-LEN instances updated in each query."
            (sel-tables (collect-table-refs where))
            (tables (remove-if #'null
                               (remove-duplicates
-                               (append (mapcar #'table-sql-expr sclasses)
+                               (append (mapcar #'select-table-sql-expr sclasses)
                                        (mapcan #'(lambda (jc-list)
                                                    (mapcar
-                                                    #'(lambda (jc) (when jc (table-sql-expr jc)))
+                                                    #'(lambda (jc) (when jc (select-table-sql-expr jc)))
                                                     jc-list))
                                                immediate-join-classes)
                                        sel-tables)