Maintain column order from migration, even with 10+ columns#54
Open
hotwoofy wants to merge 2 commits intobudu:masterfrom
Open
Maintain column order from migration, even with 10+ columns#54hotwoofy wants to merge 2 commits intobudu:masterfrom
hotwoofy wants to merge 2 commits intobudu:masterfrom
Conversation
Owner
|
Looks good, I'll probably work a bit on Lobos during the holidays and merge it then. Thanks for your patience. |
|
@budu any update on this issue? I really like Lobos but I'm considering other options because of this issue :( |
Author
|
@jplaza one workaround in the meantime is to use my fork, the other is to write your migrations for large tables in two steps - first create it with just the ID, the alter it to append the rest of the columns. |
jprudent
reviewed
Sep 15, 2016
| (name-required name "table") | ||
| (Table. name | ||
| (or columns {}) | ||
| (or columns (ordered-map)) |
There was a problem hiding this comment.
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
jprudent
reviewed
Sep 15, 2016
| [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"]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, 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.