budu/lobos — pull request #54 by hotwoofy (2012-12-14 21:41:51+00:00)
Title: Maintain column order from migration, even with 10+ columns

Currently, up to 9 columns, the correct order is maintained in the table definition (first listing below). However, upon hitting 10 columns, the order is lost (second listing). I've forced the column map to now be ordered, and now any number of columns can be added without losing the order (third listing). I've done this by taking a dependency on [ordered](https://github.com/flatland/ordered), I hope that's acceptable.

The driver for this was ClojureQL's implementation of JDBC's `.getGeneratedKeys`, which expects a primary key column to be the first that it finds when inserting.

```
user> (pprint (table :test
(integer :col1)
(integer :col2)
(integer :col3)
(integer :col4)
(integer :col5)
(integer :col6)
(integer :col7)
(integer :col7)
(integer :col8)
(integer :col9)))
{:name :test,
:columns
{:col1
{:cname :col1,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()},
.
.
.
{:cname :col9,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()}},
:constraints {},
:indexes {}}
```

```
user> (pprint (table :test
(integer :col1)
(integer :col2)
(integer :col3)
(integer :col4)
(integer :col5)
(integer :col6)
(integer :col7)
(integer :col7)
(integer :col8)
(integer :col9)
(integer :col10)))
{:name :test,
:columns
{:col6
{:cname :col6,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()},
:col7
{:cname :col7,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()},
:col4
{:cname :col4,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()},
:col5
.
.
.
```

```
user> (pprint (table :test
(integer :col1)
(integer :col2)
(integer :col3)
(integer :col4)
(integer :col5)
(integer :col6)
(integer :col7)
(integer :col7)
(integer :col8)
(integer :col9)
(integer :col10)))
{:name :test,
:columns
{:col1
{:cname :col1,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()},
:col2
.
.
.
{:cname :col10,
:data-type {:name :integer, :args [], :options {}},
:default nil,
:auto-inc nil,
:not-null nil,
:others ()}},
:constraints {},
:indexes {}}
```