Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:license {:name "Eclipse Public License"}
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/java.jdbc "0.1.1"]
[org.clojure/tools.macro "0.1.1"]]
[org.clojure/tools.macro "0.1.1"]
[org.flatland/ordered "1.4.0"]]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.5.4 now :)

:profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
;:1.5 {:dependencies [[org.clojure/clojure "1.5.0-beta1"]]}
:dev
Expand Down
7 changes: 4 additions & 3 deletions src/lobos/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
(:use (clojure [walk :only [postwalk]]
[set :only [union]]
[string :only [replace]])
lobos.utils))
lobos.utils
flatland.ordered.map))

(ast/import-all)

Expand Down Expand Up @@ -689,15 +690,15 @@
[name & [columns constraints indexes]]
(name-required name "table")
(Table. name
(or columns {})
(or columns (ordered-map))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to order the whole expression :

(ordered-map (or columns {}))

Beause there is other places in code where columns should be ordered. See defmethod analyze [::standard Table] in analyzer.clj

(or constraints {})
(or indexes {})))

(defmacro table
"Constructs an abstract table definition containing the given
elements."
[name & elements]
`(-> (table* ~name) ~@(reverse elements)))
`(-> (table* ~name) ~@elements))

;; -----------------------------------------------------------------------------

Expand Down
15 changes: 14 additions & 1 deletion test/lobos/test/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,20 @@
"Table with column")
(is (= (table :foo (unique :bar [:a]))
(Table. :foo {} {:bar (UniqueConstraint. :bar :unique [:a])} {}))
"Table with constraint"))
"Table with constraint")
(is (= (list :col1 :col2 :col3 :col4 :col5 :col6 :col7 :col8 :col9 :col10)
(keys (:columns (table :foo
(column :col1 nil nil)
(column :col2 nil nil)
(column :col3 nil nil)
(column :col4 nil nil)
(column :col5 nil nil)
(column :col6 nil nil)
(column :col7 nil nil)
(column :col8 nil nil)
(column :col9 nil nil)
(column :col10 nil nil)))))
"Table with many ordered columns"))

;;;; Schema definition tests

Expand Down