Skip to content
Snippets Groups Projects
Unverified Commit 7f9bfd0e authored by metamben's avatar metamben Committed by GitHub
Browse files

Configure foreign key support for Mongo to allow implicit joins (#29566)

* Configure foreign key support for Mongo to allow implicit joins
parent 9929f6de
Branches
Tags
No related merge requests found
......@@ -261,6 +261,14 @@
:standard-deviation-aggregations]]
(defmethod driver/supports? [:mongo feature] [_driver _feature] true))
;; We say Mongo supports foreign keys so that the front end can use implicit
;; joins. In reality, Mongo doesn't support foreign keys.
;; Only define an implementation for `:foreign-keys` if none exists already.
;; In test extensions we define an alternate implementation, and we don't want
;; to stomp over that if it was loaded already.
(when-not (get (methods driver/supports?) [:mongo :foreign-keys])
(defmethod driver/supports? [:mongo :foreign-keys] [_ _] true))
(defmethod driver/database-supports? [:mongo :expressions]
[_driver _feature db]
(-> (:dbms_version db)
......
......@@ -6,6 +6,8 @@
[clojure.test :refer :all]
[flatland.ordered.map :as ordered-map]
[medley.core :as m]
[metabase.config :as config]
[metabase.driver :as driver]
[metabase.driver.ddl.interface :as ddl.i]
[metabase.driver.mongo.util :refer [with-mongo-connection]]
[metabase.test.data.interface :as tx]
......@@ -21,6 +23,9 @@
(defmethod tx/supports-time-type? :mongo [_driver] false)
(defmethod tx/supports-timestamptz-type? :mongo [_driver] false)
;; during unit tests don't treat Mongo as having FK support
(defmethod driver/supports? [:mongo :foreign-keys] [_ _] (not config/is-test?))
(defn ssl-required?
"Returns if the mongo server requires an SSL connection."
[]
......@@ -53,7 +58,7 @@
{:pass password}))))
(defn- destroy-db! [driver dbdef]
(with-mongo-connection [mongo-connection (tx/dbdef->connection-details driver :server dbdef)]
(with-mongo-connection [^com.mongodb.DB mongo-connection (tx/dbdef->connection-details driver :server dbdef)]
(mg/drop-db (.getMongo mongo-connection) (tx/escaped-database-name dbdef))))
(def ^:dynamic *remove-nil?*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment