changed generate-sql-reference to read [foo bar] and [foo.bar] as the same attribute...
authorRuss Tyndall <russ@acceleration.net>
Sun, 12 Jun 2011 15:58:39 +0000 (11:58 -0400)
committerNathan Bird <nathan@acceleration.net>
Thu, 30 Jun 2011 21:13:17 +0000 (17:13 -0400)
sql/syntax.lisp

index 4ec07f5f2ce4ae193fe682754882f2343ea98c01..68fa8aad7462b2e5ccacffc82d7271537a7d81b1 100644 (file)
@@ -110,9 +110,17 @@ reader syntax is disabled."
 
 (defun generate-sql-reference (&rest arglist)
   (cond ((= (length arglist) 1) ; string, table or attribute
-         (if (stringp (car arglist))
-             (sql-expression :string (car arglist))
-             (sql-expression :attribute (car arglist))))
+         (let ((arg (first arglist)))
+           (typecase arg
+             (string (sql-expression :string arg))
+             (symbol ;; handle . separated names
+              (let* ((sn (symbol-name arg))
+                     (idx (position #\. sn)))
+                (cond
+                  (idx (sql-expression :table (intern (subseq sn 0 idx))
+                                       :attribute (intern (subseq sn (+ idx 1))) ))
+                  (T (sql-expression :attribute arg))))
+              ))))
         ((<= 2 (length arglist))
          (let ((sqltype (when (keywordp (caddr arglist)) (caddr arglist) nil)))
            (cond