Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Allow both db and dbname in Redshift connection details (#64748)

metamben7ee5fffead44
diff --git a/modules/drivers/redshift/src/metabase/driver/redshift.clj b/modules/drivers/redshift/src/metabase/driver/redshift.clj
index 25c6169fcc8..5af20113b9a 100644
--- a/modules/drivers/redshift/src/metabase/driver/redshift.clj
+++ b/modules/drivers/redshift/src/metabase/driver/redshift.clj
@@ -465,7 +465,7 @@
(defmethod sql-jdbc.conn/connection-details->spec :redshift
[_ {:keys [host port db dbname], :as opts}]
(when (and db dbname)
- (throw (ex-info "Redshift connection details cannot contain both 'db' and 'dbname' options" {})))
+ (log/warn "Redshift connection details should not contain both 'db' and 'dbname' options. Ignoring 'dbname'."))
(sql-jdbc.common/handle-additional-options
(merge
{:classname "com.amazon.redshift.jdbc42.Driver"
diff --git a/modules/drivers/redshift/test/metabase/driver/redshift_test.clj b/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
index 96463cef3a8..fb565ac8e4d 100644
--- a/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
+++ b/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
@@ -541,5 +541,6 @@
(sql-jdbc.conn/connection-details->spec :redshift (assoc options :db "test-db"))))
(is (= {:classname "com.amazon.redshift.jdbc42.Driver", :subprotocol "redshift", :subname "//test.example.com:/test-db", :ssl true, :OpenSourceSubProtocolOverride false}
(sql-jdbc.conn/connection-details->spec :redshift (assoc options :dbname "test-db"))))
- (is (thrown-with-msg? Exception #"Redshift connection details cannot contain both 'db' and 'dbname' options"
- (sql-jdbc.conn/connection-details->spec :redshift (assoc options :dbname "test-dbname" :db "test-db")))))))
+ (is (= {:classname "com.amazon.redshift.jdbc42.Driver", :subprotocol "redshift", :subname "//test.example.com:/test-db", :ssl true, :OpenSourceSubProtocolOverride false}
+ (sql-jdbc.conn/connection-details->spec :redshift (assoc options :dbname "test-dbname" :db "test-db")))
+ ":db should take precedence"))))
diff --git a/test/metabase/warehouses/api_test.clj b/test/metabase/warehouses/api_test.clj
index bc6baa62d75..2cefad064a4 100644
--- a/test/metabase/warehouses/api_test.clj
+++ b/test/metabase/warehouses/api_test.clj
@@ -36,6 +36,7 @@
[metabase.util.cron :as u.cron]
[metabase.util.i18n :refer [deferred-tru]]
[metabase.util.malli.schema :as ms]
+ [metabase.util.quick-task :as quick-task]
[metabase.util.random :as u.random]
[metabase.warehouse-schema.table :as schema.table]
[metabase.warehouses.api :as api.database]
@@ -1417,9 +1418,9 @@
;; Five minutes
(def ^:private long-timeout (* 5 60 1000))
-(defn- deliver-when-db [promise-to-deliver expected-db]
+(defn- deliver-when-db [promise-to-deliver expected-db-id]
(fn [db]
- (when (= (u/the-id db) (u/the-id expected-db))
+ (when (= (u/the-id db) expected-db-id)
(deliver promise-to-deliver true))))
(deftest trigger-metadata-sync-for-db-test
@@ -1427,11 +1428,13 @@
(let [sync-called? (promise)
analyze-called? (promise)]
(mt/with-premium-features #{:audit-app}
- (mt/with-temp [:model/Database {db-id :id :as db} {:engine "h2", :details (:details (mt/db))}]
- (with-redefs [sync-metadata/sync-db-metadata! (deliver-when-db sync-called? db)
- analyze/analyze-db! (deliver-when-db analyze-called? db)]
+ (mt/with-temp [:model/Database {db-id :id} {:engine "h2", :details (:details (mt/db))}]
+ ;; redefine quick-task/submit-task! so as not to depend on the capacity of the quick-task executor
+ (with-redefs [quick-task/submit-task! future-call
+ sync-metadata/sync-db-metadata! (deliver-when-db sync-called? db-id)
+ analyze/analyze-db! (deliver-when-db analyze-called? db-id)]
(snowplow-test/with-fake-snowplow-collector
- (mt/user-http-request :crowberto :post 200 (format "database/%d/sync_schema" (u/the-id db)))
+ (mt/user-http-request :crowberto :post 200 (format "database/%d/sync_schema" db-id))
;; Block waiting for the promises from sync and analyze to be delivered. Should be delivered instantly,
;; however if something went wrong, don't hang forever, eventually timeout and fail
(testing "sync called?"