Skip to content

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

Driver table CRUD to skip QP (#63427)

Ngoc Khuat3275cb9a4470
diff --git a/src/metabase/driver/sql_jdbc.clj b/src/metabase/driver/sql_jdbc.clj
index 5869138e78c..47d76bf6b4e 100644
--- a/src/metabase/driver/sql_jdbc.clj
+++ b/src/metabase/driver/sql_jdbc.clj
@@ -153,14 +153,16 @@
(defmethod driver/create-table! :sql-jdbc
[driver database-id table-name column-definitions & {:keys [primary-key]}]
(let [sql (create-table!-sql driver table-name column-definitions :primary-key primary-key)]
- (driver-api/execute-write-sql! database-id sql)))
+ (jdbc/with-db-transaction [conn (sql-jdbc.conn/db->pooled-connection-spec database-id)]
+ (jdbc/execute! conn sql))))
(defmethod driver/drop-table! :sql-jdbc
[driver db-id table-name]
(let [sql (first (sql/format {:drop-table [:if-exists (keyword table-name)]}
:quoted true
:dialect (sql.qp/quote-style driver)))]
- (driver-api/execute-write-sql! db-id sql)))
+ (jdbc/with-db-transaction [conn (sql-jdbc.conn/db->pooled-connection-spec db-id)]
+ (jdbc/execute! conn sql))))
(defmethod driver/truncate! :sql-jdbc
[driver db-id table-name]
@@ -209,7 +211,8 @@
column-definitions)}
:quoted true
:dialect (sql.qp/quote-style driver)))]
- (driver-api/execute-write-sql! db-id sql))))
+ (jdbc/with-db-transaction [conn (sql-jdbc.conn/db->pooled-connection-spec db-id)]
+ (jdbc/execute! conn sql)))))
;; kept for get-method driver compatibility
#_{:clj-kondo/ignore [:deprecated-var]}