Skip to content

Columns are created in the wrong order for >= 10 columns #76

@ahwatts

Description

@ahwatts

I have the following tbl macro (from the readme) and table definition:

(defmacro tbl [name & elements]
  `(-> (table ~name)
       (timestamps)
       ~@(reverse elements)
       (surrogate-key)))

(tbl :foo
     (integer :column_01)
     (integer :column_02)
     (integer :column_03)
     (integer :column_04)
     (integer :column_05)
     (integer :column_06)
     (integer :column_07))

With the :id, :created_on, and :updated_on columns, the table has 10 columns, and generates the columns out-of-order (I'm using an SQLite database):

CREATE TABLE foo (
    column_01 INTEGER, 
    column_04 INTEGER, 
    column_02 INTEGER, 
    updated_on TIMESTAMP, 
    created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
    column_06 INTEGER, 
    column_07 INTEGER, 
    column_03 INTEGER,
    id INTEGER, 
    column_05 INTEGER, 
    CONSTRAINT foo_primary_key_id PRIMARY KEY (id))

If I comment out any one of the above columns, e.g. the :column_07 column (to keep the ordering), the columns are in the correct order:

CREATE TABLE foo (
    id INTEGER, 
    column_01 INTEGER, 
    column_02 INTEGER, 
    column_03 INTEGER, 
    column_04 INTEGER, 
    column_05 INTEGER, 
    column_06 INTEGER, 
    created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
    updated_on TIMESTAMP, 
    CONSTRAINT foo_primary_key_id PRIMARY KEY (id))

I'm using [lobos "1.0.0-beta3"], with [org.clojure/clojure "1.6.0"]. I'm on Linux, though I've also seen this behavior on Windows. My java version is:

java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

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