X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Fsyntax.lisp;h=68fa8aad7462b2e5ccacffc82d7271537a7d81b1;hp=7e1906b9e4d22055a497c54ac546f5335f3803e9;hb=HEAD;hpb=406feeb749bb475bec8077a2716a5b6089bd9072 diff --git a/sql/syntax.lisp b/sql/syntax.lisp index 7e1906b..68fa8aa 100644 --- a/sql/syntax.lisp +++ b/sql/syntax.lisp @@ -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 @@ -155,7 +163,7 @@ keyword arguments is specified." (string (make-instance 'sql :string string)) (attribute - (make-instance 'sql-ident-attribute :name attribute + (make-instance 'sql-ident-attribute :name attribute :qualifier (or table alias) :type type)) ((and table (not attribute))