提交 8dc0ecdd authored 作者: Thomas Mueller's avatar Thomas Mueller

H2 Console: auto-complete of identifiers did not work correctly for H2 databases in MySQL mode.

上级 255f9ddd
......@@ -40,6 +40,11 @@ public class DbContents {
*/
boolean isH2;
/**
* True if this is a H2 database in MySQL mode.
*/
boolean isH2ModeMySQL;
/**
* True if this is a PostgreSQL database.
*/
......@@ -94,6 +99,14 @@ public class DbContents {
String url = meta.getURL();
if (url != null) {
isH2 = url.startsWith("jdbc:h2:");
if (isH2) {
ResultSet rs = meta.getConnection().createStatement().executeQuery(
"SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='MODE'");
rs.next();
if ("MYSQL".equals(rs.getString(1))) {
isH2ModeMySQL = true;
}
}
isOracle = url.startsWith("jdbc:oracle:");
isPostgreSQL = url.startsWith("jdbc:postgresql:");
// isHSQLDB = url.startsWith("jdbc:hsqldb:");
......@@ -182,8 +195,7 @@ public class DbContents {
/**
* Add double quotes around an identifier if required.
* For the H2 database, only keywords are quoted; for other databases,
* all identifiers are.
* For the H2 database, all identifiers are quoted.
*
* @param identifier the identifier
* @return the quoted identifier
......@@ -192,7 +204,7 @@ public class DbContents {
if (identifier == null) {
return null;
}
if (isH2) {
if (isH2 && !isH2ModeMySQL) {
return Parser.quoteIdentifier(identifier);
}
return StringUtils.toUpperEnglish(identifier);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论