Skip to content
Snippets Groups Projects
Commit 3fe3a0fd authored by Cam Saul's avatar Cam Saul
Browse files

:bird: Add H2 driver support for new-style connection details. Use 'db'

instead of 'connectionString' since that's what JDBC calls it
parent e2910f09
Branches
Tags
No related merge requests found
......@@ -604,21 +604,21 @@ CorvusServices.service('CorvusCore', ['$resource', 'User', function($resource, U
name: 'H2',
fields: [{
displayName: "Connection String",
fieldName: "connectionString",
fieldName: "db",
placeholder: "file:/Users/camsaul/bird_sightings/toucans;AUTO_SERVER=TRUE"
}],
parseDetails: function(details) {
// Check for new-style details
if (details.connectionString) return details;
if (details.db) return details;
// Otherwise parse legacy details
return {
connectionString: details.conn_str
db: details.conn_str
};
},
buildDetails: function(details) {
// add conn_str for backwards-compatibility
details.conn_str = details.connectionString;
details.conn_str = details.db;
return details;
}
},
......
(ns metabase.driver.h2
(:require [clojure.set :as set]
[korma.db :as kdb]
(:require [korma.db :as kdb]
[metabase.driver :as driver]
[metabase.driver.generic-sql :as generic-sql]))
......@@ -11,8 +10,9 @@
:db-type :h2 ; what are we using this for again (?)
:make-pool? false)))
(defn- database->connection-details [database]
(set/rename-keys (:details database) {:conn_str :db}))
(defn- database->connection-details [{:keys [details]}]
{:db (or (:db details) ; new-style connection details call it 'db'
(:conn_str details))}) ; legacy instead calls is 'conn_str'
;; ## SYNCING
......
(ns metabase.driver.h2-test
(:require [expectations :refer :all]
[metabase.driver.h2 :refer :all]
[metabase.test.util :refer [resolve-private-fns]]))
(resolve-private-fns metabase.driver.h2 database->connection-details)
;; # Check that database->connection-details works with both new-style and legacy details
;; ## new-style
(expect {:db
"file:/Users/cam/birdly/bird_sightings.db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1"}
{:details {:db "file:/Users/cam/birdly/bird_sightings.db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1"}})
;; ## legacy
(expect {:db "file:/Users/cam/birdly/bird_sightings.db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1"}
{:details {:conn_str "file:/Users/cam/birdly/bird_sightings.db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1"}})
......@@ -114,6 +114,9 @@
field-avg-length field-percent-urls)"
{:arglists '([namespace-symb & fn-symbs])}
[namespc fn-name & more]
{:pre [(symbol? namespc)
(symbol? fn-name)
(every? symbol? more)]}
`(do (def ~fn-name (ns-resolve '~namespc '~fn-name))
~(when (seq more)
`(resolve-private-fns ~namespc ~(first more) ~@(rest more)))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment