Skip to content

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

Flip mariadb during table editing support check (#68171)

Ngoc Khuatb98eb79b38ba
diff --git a/src/metabase/driver/mysql.clj b/src/metabase/driver/mysql.clj
index fd6e4b73627..a5162855770 100644
--- a/src/metabase/driver/mysql.clj
+++ b/src/metabase/driver/mysql.clj
@@ -120,6 +120,15 @@
[database]
(-> database :dbms_version :flavor (= "MariaDB")))
+(defn- mysql?
+ "Returns true if the database is MySQL (not MariaDB).
+ Returns true for unsynced databases (unknown flavor)."
+ [db]
+ (= "MySQL"
+ (if-let [conn (:connection db)]
+ (->> ^java.sql.Connection conn .getMetaData .getDatabaseProductName)
+ (-> db :dbms_version :flavor))))
+
(defn mariadb-connection?
"Returns true if the database is MariaDB."
[driver conn]
@@ -146,7 +155,7 @@
(defmethod driver/database-supports? [:mysql :metadata/table-writable-check]
[driver _feat db]
(and (= driver :mysql)
- (not (mariadb? db))
+ (mysql? db)
(not (try
(partial-revokes-enabled? driver db)
(catch Exception e
diff --git a/test/metabase/driver/mysql_test.clj b/test/metabase/driver/mysql_test.clj
index c4341b5c3f3..8166ce94b30 100644
--- a/test/metabase/driver/mysql_test.clj
+++ b/test/metabase/driver/mysql_test.clj
@@ -974,7 +974,8 @@
:password "password"
:ssl true
:additional-options "trustServerCertificate=true")]
- (mt/with-temp [:model/Database database {:engine "mysql", :details user-connection-details}]
+ (mt/with-temp [:model/Database database {:engine "mysql", :details user-connection-details
+ :dbms_version {:flavor "MySQL"}}]
(testing "With partial_revokes OFF (default), metadata/table-writable-check is supported"
(jdbc/execute! spec "SET GLOBAL partial_revokes = OFF;")
(is (true? (driver/database-supports? driver/*driver* :metadata/table-writable-check database))