提交 00de9bdb authored 作者: Florian Léger's avatar Florian Léger

TableLink: column names are always case insensitive for MySQL

上级 0c46e47e
...@@ -63,6 +63,7 @@ public class TableLink extends Table { ...@@ -63,6 +63,7 @@ public class TableLink extends Table {
private boolean supportsMixedCaseIdentifiers; private boolean supportsMixedCaseIdentifiers;
private boolean globalTemporary; private boolean globalTemporary;
private boolean readOnly; private boolean readOnly;
private boolean targetsMySql;
public TableLink(Schema schema, int id, String name, String driver, public TableLink(Schema schema, int id, String name, String driver,
String url, String user, String password, String originalSchema, String url, String user, String password, String originalSchema,
...@@ -75,6 +76,7 @@ public class TableLink extends Table { ...@@ -75,6 +76,7 @@ public class TableLink extends Table {
this.originalSchema = originalSchema; this.originalSchema = originalSchema;
this.originalTable = originalTable; this.originalTable = originalTable;
this.emitUpdates = emitUpdates; this.emitUpdates = emitUpdates;
this.targetsMySql = isMySqlUrl(this.url);
try { try {
connect(); connect();
} catch (DbException e) { } catch (DbException e) {
...@@ -319,7 +321,10 @@ public class TableLink extends Table { ...@@ -319,7 +321,10 @@ public class TableLink extends Table {
} }
private String convertColumnName(String columnName) { private String convertColumnName(String columnName) {
if ((storesMixedCase || storesLowerCase) && if(targetsMySql) {
// MySQL column names are not case-sensitive on any platform
columnName = StringUtils.toUpperEnglish(columnName);
} else if ((storesMixedCase || storesLowerCase) &&
columnName.equals(StringUtils.toLowerEnglish(columnName))) { columnName.equals(StringUtils.toLowerEnglish(columnName))) {
columnName = StringUtils.toUpperEnglish(columnName); columnName = StringUtils.toUpperEnglish(columnName);
} else if (storesMixedCase && !supportsMixedCaseIdentifiers) { } else if (storesMixedCase && !supportsMixedCaseIdentifiers) {
...@@ -586,6 +591,11 @@ public class TableLink extends Table { ...@@ -586,6 +591,11 @@ public class TableLink extends Table {
return url.startsWith("jdbc:oracle:"); return url.startsWith("jdbc:oracle:");
} }
private static boolean isMySqlUrl(String url) {
return url.startsWith("jdbc:mysql:")
|| url.startsWith("jdbc:mariadb:");
}
@Override @Override
public ArrayList<Index> getIndexes() { public ArrayList<Index> getIndexes() {
return indexes; return indexes;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论