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