Skip to content

Commit 3bcd51d

Browse files
authored
Merge pull request #287 from dpsutton/changes-for-metabase-53
Update for metabase 53/master
2 parents cb907c1 + 6f5f600 commit 3bcd51d

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

.github/workflows/check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
env:
1313
# Temporarily using a fork to disable a few failing tests
1414
METABASE_REPOSITORY: slvrtrn/metabase
15-
METABASE_VERSION: 0.52.x-ch
15+
METABASE_VERSION: 0.53.x-ch
1616

1717
jobs:
1818
check-local-current-version:

test/metabase/driver/clickhouse_impersonation_test.clj

+21-22
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[metabase.driver.sql-jdbc.connection :as sql-jdbc.conn]
99
[metabase.driver.sql-jdbc.execute :as sql-jdbc.execute]
1010
[metabase.query-processor.store :as qp.store]
11-
[metabase.sync :as sync]
11+
[metabase.sync.core :as sync]
1212
[metabase.test :as mt]
1313
[metabase.test.data.clickhouse :as ctd]
1414
[metabase.util :as u]
@@ -156,26 +156,25 @@
156156
(t2.with-temp/with-temp [:model/Database db cluster-details]
157157
(mt/with-db db (sync/sync-database! db)
158158

159-
(defn- check-impersonation!
160-
[roles expected]
161-
(advanced-perms.api.tu/with-impersonations!
162-
{:impersonations [{:db-id (mt/id) :attribute "impersonation_attr"}]
163-
:attributes {"impersonation_attr" roles}}
164-
(is (= expected
165-
(-> {:query select-query}
166-
mt/native-query
167-
mt/process-query
168-
mt/rows)))))
159+
(letfn [(check-impersonation! [roles expected]
160+
(advanced-perms.api.tu/with-impersonations!
161+
{:impersonations [{:db-id (mt/id) :attribute "impersonation_attr"}]
162+
:attributes {"impersonation_attr" roles}}
163+
(is (= expected
164+
(-> {:query select-query}
165+
mt/native-query
166+
mt/process-query
167+
mt/rows)))))]
169168

170-
(is (= [["a"] ["b"] ["c"]]
171-
(-> {:query select-query}
172-
mt/native-query
173-
mt/process-query
174-
mt/rows)))
169+
(is (= [["a"] ["b"] ["c"]]
170+
(-> {:query select-query}
171+
mt/native-query
172+
mt/process-query
173+
mt/rows)))
175174

176-
(check-impersonation! "row_a" [["a"]])
177-
(check-impersonation! "row_b" [["b"]])
178-
(check-impersonation! "row_c" [["c"]])
179-
(check-impersonation! "row_a,row_c" [["a"] ["c"]])
180-
(check-impersonation! "row_b,row_c" [["b"] ["c"]])
181-
(check-impersonation! "row_a,row_b,row_c" [["a"] ["b"] ["c"]])))))))
175+
(check-impersonation! "row_a" [["a"]])
176+
(check-impersonation! "row_b" [["b"]])
177+
(check-impersonation! "row_c" [["c"]])
178+
(check-impersonation! "row_a,row_c" [["a"] ["c"]])
179+
(check-impersonation! "row_b,row_c" [["b"] ["c"]])
180+
(check-impersonation! "row_a,row_b,row_c" [["a"] ["b"] ["c"]]))))))))

test/metabase/driver/clickhouse_test.clj

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
(driver/db-default-timezone :clickhouse spec))))))
4040

4141
(deftest ^:parallel clickhouse-connection-string
42-
(mt/with-dynamic-redefs [;; This function's implementation requires the connection details to actually connect to the
43-
;; database, which is orthogonal to the purpose of this test.
44-
clickhouse/cloud? (constantly false)]
42+
(mt/with-dynamic-fn-redefs [ ;; This function's implementation requires the connection details to actually connect to the
43+
;; database, which is orthogonal to the purpose of this test.
44+
clickhouse/cloud? (constantly false)]
4545
(testing "connection with no additional options"
4646
(is (= ctd/default-connection-params
4747
(sql-jdbc.conn/connection-details->spec
@@ -72,9 +72,9 @@
7272
{:dbname nil}))))))
7373

7474
(deftest ^:parallel clickhouse-connection-string-select-sequential-consistency
75-
(mt/with-dynamic-redefs [;; This function's implementation requires the connection details to actually
76-
;; connect to the database, which is orthogonal to the purpose of this test.
77-
clickhouse/cloud? (constantly true)]
75+
(mt/with-dynamic-fn-redefs [ ;; This function's implementation requires the connection details to actually
76+
;; connect to the database, which is orthogonal to the purpose of this test.
77+
clickhouse/cloud? (constantly true)]
7878
(testing "connection with no additional options"
7979
(is (= (assoc ctd/default-connection-params :select_sequential_consistency true)
8080
(sql-jdbc.conn/connection-details->spec

test/metabase/test/data/clickhouse.clj

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
(ns metabase.test.data.clickhouse
22
"Code for creating / destroying a ClickHouse database from a `DatabaseDefinition`."
33
(:require
4+
[clojure.java.io :as io]
45
[clojure.java.jdbc :as jdbc]
56
[clojure.string :as str]
67
[clojure.test :refer :all]
78
[metabase.db.query :as mdb.query]
9+
[metabase.driver :as driver]
810
[metabase.driver.ddl.interface :as ddl.i]
911
[metabase.driver.sql-jdbc.connection :as sql-jdbc.conn]
1012
[metabase.driver.sql-jdbc.execute :as sql-jdbc.execute]
1113
[metabase.driver.sql.util :as sql.u]
1214
[metabase.lib.schema.common :as lib.schema.common]
1315
[metabase.query-processor.test-util :as qp.test]
14-
[metabase.sync.sync-metadata :as sync-metadata]
16+
[metabase.sync.core :as sync]
1517
[metabase.test.data.interface :as tx]
1618
[metabase.test.data.sql :as sql.tx]
1719
[metabase.test.data.sql-jdbc :as sql-jdbc.tx]
@@ -24,6 +26,11 @@
2426

2527
(sql-jdbc.tx/add-test-extensions! :clickhouse)
2628

29+
(defmethod driver/database-supports? [:clickhouse :metabase.driver.sql-jdbc.sync.describe-table-test/describe-view-fields]
30+
[_driver _feature _db] true)
31+
(defmethod driver/database-supports? [:clickhouse :metabase.driver.sql-jdbc.sync.describe-table-test/describe-materialized-view-fields]
32+
[_driver _feature _db] false)
33+
2734
(def default-connection-params
2835
{:classname "com.clickhouse.jdbc.ClickHouseDriver"
2936
:subprotocol "clickhouse"
@@ -178,7 +185,8 @@
178185
;; (println "### Executing create-test-db! with details:" details)
179186
(jdbc/with-db-connection
180187
[spec (sql-jdbc.conn/connection-details->spec :clickhouse (merge {:engine :clickhouse} details))]
181-
(let [statements (as-> (slurp "modules/drivers/clickhouse/test/metabase/test/data/datasets.sql") s
188+
(let [raw-statements (slurp (io/resource "metabase/test/data/clickhouse_datasets.sql"))
189+
statements (as-> raw-statements s
182190
(str/split s #";")
183191
(map str/trim s)
184192
(filter seq s))]
@@ -216,7 +224,7 @@
216224
[:model/Database database
217225
{:engine :clickhouse
218226
:details (tx/dbdef->connection-details :clickhouse :db {:database-name "metabase_test"})}]
219-
(sync-metadata/sync-db-metadata! database)
227+
(sync/sync-db-metadata! database)
220228
(f database)))
221229

222230
(defmethod tx/dataset-already-loaded? :clickhouse

0 commit comments

Comments
 (0)