Skip to content

Inconsistent treatment of table-name as variable or symbol. #51

@jpittis

Description

@jpittis
(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions