Skip to content
Snippets Groups Projects
Commit b383f05b authored by Tom Robinson's avatar Tom Robinson
Browse files

Merge branch 'master' of github.com:metabase/metabase into dash-filter-search-widget

parents 0107d121 bc867a5d
No related branches found
No related tags found
No related merge requests found
......@@ -189,21 +189,11 @@
["3" "2014-09-15" "" "8" "56"]
["4" "2014-03-11" "" "5" "4"]
["5" "2013-05-05" "" "3" "49"]]
(with-db (get-or-create-database! defs/test-data)
(let [db (Database :name "test-data")]
(jdbc/with-db-connection [conn {:classname "org.h2.Driver", :subprotocol "h2", :subname "mem:test-data"}]
;; test-data doesn't include any null date values, add a date column to ensure we can handle null dates on export
(jdbc/execute! conn "ALTER TABLE CHECKINS ADD COLUMN MYDATECOL DATE")
(sync/sync-database! db)
(try
(let [result ((user->client :rasta) :post 200 "dataset/csv" :query
(json/generate-string (wrap-inner-query
(query checkins))))]
(take 5 (parse-and-sort-csv result)))
(finally
;; ensure we remove the column when we're done otherwise subsequent tests will break
(jdbc/execute! conn "ALTER TABLE CHECKINS DROP COLUMN MYDATECOL")
(sync/sync-database! db)))))))
(with-db (get-or-create-database! defs/test-data-with-null-date-checkins)
(let [result ((user->client :rasta) :post 200 "dataset/csv" :query
(json/generate-string (wrap-inner-query
(query checkins))))]
(take 5 (parse-and-sort-csv result)))))
;; DateTime fields are untouched when exported
(expect
......
......@@ -66,6 +66,15 @@
(mapv (fn [[username last-login password-text]]
[username (date-only last-login) (time-only last-login) password-text])
rows))
(for [[table-name :as orig-def] (di/slurp-edn-table-def "test-data")
:when (= table-name "users")]
orig-def)))
(di/def-database-definition test-data-with-null-date-checkins
(di/update-table-def "checkins"
#(vec (concat % [{:field-name "null_only_date" :base-type :type/Date}]))
(fn [rows]
(mapv #(conj % nil) rows))
(di/slurp-edn-table-def "test-data")))
(def test-data-map
......
......@@ -181,11 +181,12 @@
invocation)."
[table-name-to-update update-table-def-fn update-rows-fn table-def]
(vec
(for [[table-name table-def rows] table-def
:when (= table-name table-name-to-update)]
[table-name
(update-table-def-fn table-def)
(update-rows-fn rows)])))
(for [[table-name table-def rows :as orig-table-def] table-def]
(if (= table-name table-name-to-update)
[table-name
(update-table-def-fn table-def)
(update-rows-fn rows)]
orig-table-def))))
(defmacro def-database-definition
"Convenience for creating a new `DatabaseDefinition` named by the symbol DATASET-NAME."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment