Skip to content
Snippets Groups Projects
Unverified Commit 0843dafb authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Realize DB transient rows in after-select hook before calling `driver.u/features` (#42744)

parent 4a6dfe40
Branches
Tags
No related merge requests found
......@@ -181,7 +181,7 @@
(cond-> database
;; TODO - this is only really needed for API responses. This should be a `hydrate` thing instead!
(driver.impl/registered? driver)
(assoc :features (driver.u/features driver database))
(assoc :features (driver.u/features driver (t2.realize/realize database)))
(and (driver.impl/registered? driver)
(:details database)
......
......@@ -309,6 +309,16 @@
(is (partial= {:details {}}
db))))))
(deftest ^:parallel after-select-driver-features-realize-db-row-test
;; This test is necessary because driver multimethods should be able to assume that the db argument is a Database
;; instance, not a transient row. Otherwise a call like `(mi/instance-of :model/Database db)` will return false
;; when it should return true.
(testing "Make sure selecting a database calls `driver/database-supports?` with a database instance"
(mt/with-temp [Database {db-id :id} {:engine (u/qualified-name ::test)}]
(mt/with-dynamic-redefs [driver/database-supports? (fn [_ _ db]
(is (true? (mi/instance-of? :model/Database db))))]
(is (some? (t2/select-one-fn :features Database :id db-id)))))))
(deftest hydrate-tables-test
(is (= ["CATEGORIES"
"CHECKINS"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment