(defun create-table-2 (table-name value-type)
(create-table (table-name :if-not-exists t)
((id :type value-type :primary-key t))))
(defun insert-into-2 (table-name value)
(insert-into table-name
(set= :id (get-universal-time) :value value)))
The two functions above both pass table-name into their respective sxql macros. We can see below that table-name is treated differently by each macro. create-table uses the literal symbol table-name and insert-into uses the variable table-name.
> (create-table-2 'my-table 'foo)
#<SXQL-STATEMENT: CREATE TABLE IF NOT EXISTS table-name (
id FOO PRIMARY KEY
)>
> (insert-into 'my-table 'foo)
#<SXQL-STATEMENT: INSERT INTO my-table foo>
I suspect this is because the create-table macro expands table-name into a quoted list but insert-into expands into the literal symbol.
(MAKE-STATEMENT :CREATE-TABLE '(TABLE-NAME :IF-NOT-EXISTS T)
(LIST
(SXQL.CLAUSE:MAKE-COLUMN-DEFINITION-CLAUSE 'ID :TYPE 'INTEGER
:PRIMARY-KEY T)))
(MAKE-STATEMENT :INSERT-INTO TABLE-NAME
(SET= :ID (GET-UNIVERSAL-TIME) :VALUE VALUE))
Any thoughts on how this might be fixed? I've tried grokking the code but my macro foo isn't there yet.
The two functions above both pass
table-nameinto their respective sxql macros. We can see below thattable-nameis treated differently by each macro.create-tableuses the literal symboltable-nameandinsert-intouses the variabletable-name.I suspect this is because the
create-tablemacro expandstable-nameinto a quoted list butinsert-intoexpands into the literal symbol.Any thoughts on how this might be fixed? I've tried grokking the code but my macro foo isn't there yet.