Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle MariaDB independently of MySQL #3530

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public final class DatabaseProduct
*/
public static final DatabaseProduct MYSQL = new DatabaseProduct("MySQL", "mysql");

/**
* The Product name and the JDBC scheme to recognize a MariaDB DB.
*/
public static final DatabaseProduct MARIADB = new DatabaseProduct("MariaDB", "mariadb");

/**
* The Product name and the JDBC scheme to recognize a PostgreSQL DB.
*/
Expand All @@ -83,13 +88,6 @@ public final class DatabaseProduct
*/
public static final DatabaseProduct UNKNOWN = new DatabaseProduct("Unknown", "unknown");

/**
* The Product name and the JDBC scheme to recognize a MariaDB DB.
* <p>
* Keeping it private until we think it's different enough from MySQL behavior to justify it's own branches.
*/
private static final DatabaseProduct MARIADB = new DatabaseProduct("MariaDB", "mariadb");

/**
* @see #getProductName()
*/
Expand Down Expand Up @@ -156,8 +154,10 @@ public static DatabaseProduct toProduct(String productNameOrJDBCScheme)
{
// See documentation above on why we check starts with for DB2
product = DB2;
} else if (isMySQL(productNameOrJDBCScheme)) {
} else if (matches(productNameOrJDBCScheme, MYSQL)) {
product = MYSQL;
} else if (matches(productNameOrJDBCScheme, MARIADB)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this. It means that any code which does something specific for MySQL/MariaDB will be broken because the type won't be = MYSQL anymore.

To me, MariaDB and MySQL are not different enough from query behavior point of view to justify this very risky change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with your feedback.

I tried, in this pull request, to make sure to update all code that might relies on the database being MySQL/MariaDB but I cannot be 100% confident on covering all the code (especially if constant defined in DatabaseProduct are not used). So I'm closing this pull request.

In order to solve my issue in Admin Tools, I created another pull request that modify the code of the extension rather than the code of the platform.
This should be far less risky.

product = MARIADB;
} else if (matches(productNameOrJDBCScheme, POSTGRESQL)) {
product = POSTGRESQL;
} else if (matches(productNameOrJDBCScheme, MSSQL)) {
Expand All @@ -169,11 +169,6 @@ public static DatabaseProduct toProduct(String productNameOrJDBCScheme)
return product;
}

private static boolean isMySQL(String productNameOrJDBCScheme)
{
return matches(productNameOrJDBCScheme, MYSQL) || matches(productNameOrJDBCScheme, MARIADB);
}

private static boolean matches(String productNameOrJDBCScheme, DatabaseProduct product)
{
return product.getProductName().equalsIgnoreCase(productNameOrJDBCScheme)
Expand Down
Loading