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

Merge branch 'master' into ssl_connection_option

parents 6023c5ea 71c6a063
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,7 @@
[metabase.driver :as driver]
(metabase.driver [interface :refer :all]
[sync :as driver-sync])
(metabase.driver.generic-sql [connection :as connection]
[query-processor :as qp]
(metabase.driver.generic-sql [query-processor :as qp]
[util :refer :all])))
(defrecord SqlDriver [column->base-type
......@@ -15,13 +14,15 @@
sql-string-length-fn]
IDriver
;; Connection
(can-connect? [_ database]
(connection/test-connection (-> database
database->connection-details
connection-details->connection-spec)))
(can-connect? [this database]
(can-connect-with-details? this (database->connection-details database)))
(can-connect-with-details? [_ details]
(connection/test-connection (connection-details->connection-spec details)))
(let [connection (connection-details->connection-spec details)]
(= 1 (-> (exec-raw connection "SELECT 1" :results)
first
vals
first))))
;; Query Processing
(process-query [_ query]
......
(ns metabase.driver.generic-sql.connection
(:require [clojure.tools.logging :as log]
[korma.core :as k]
[metabase.driver :as driver]))
(defn test-connection
"Test whether we can performa a very simple SQL query against CONNECTION.
(This will probably throw an Exception if we cannot).
(test-connection (korma.db/postgres {:db \"metabase\", :port 5432, ...})) -> true"
[connection]
(= 1 (-> (k/exec-raw connection "SELECT 1" :results)
first
vals
first)))
......@@ -2,7 +2,6 @@
(:require [expectations :refer :all]
[metabase.db :refer [sel]]
[metabase.driver :as driver]
[metabase.driver.generic-sql.connection :refer :all]
[metabase.models.database :refer [Database]]
[metabase.test-data :refer :all]))
......
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