提交 aad65da0 编写于 作者: S Serge Rider

SQL semantic processing + filters update fix (compare column names ignoring whitespaces)

上级 326da32f
......@@ -35,6 +35,7 @@ import org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.sql.SQLQuery;
import org.jkiss.dbeaver.model.sql.SQLUtils;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.struct.rdb.DBSCatalog;
import org.jkiss.dbeaver.model.struct.rdb.DBSSchema;
......@@ -371,8 +372,8 @@ public class ResultSetUtils
public static boolean equalAttributes(DBCAttributeMetaData attr1, DBCAttributeMetaData attr2) {
return
CommonUtils.equalObjects(attr1.getLabel(), attr2.getLabel()) &&
CommonUtils.equalObjects(attr1.getName(), attr2.getName()) &&
SQLUtils.equalsWithoutExtraSpaces(attr1.getLabel(), attr2.getLabel()) &&
SQLUtils.equalsWithoutExtraSpaces(attr1.getName(), attr2.getName()) &&
CommonUtils.equalObjects(attr1.getEntityMetaData(), attr2.getEntityMetaData()) &&
attr1.getOrdinalPosition() == attr2.getOrdinalPosition() &&
attr1.isRequired() == attr2.isRequired() &&
......
......@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.sql.SQLConstants;
import org.jkiss.dbeaver.model.sql.SQLDataSource;
import org.jkiss.dbeaver.model.sql.SQLUtils;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.virtual.DBVUtils;
......@@ -157,13 +158,13 @@ public abstract class DBDAttributeBinding implements DBSObject, DBSAttributeBase
}
// Match all hierarchy names
for (DBDAttributeBinding a1 = cmpAttr, a2 = this; a1 != null && a2 != null; a1 = a1.getParentObject(), a2 = a2.getParentObject()) {
if (!attr.getName().equals(this.getName())) {
if (!SQLUtils.equalsWithoutExtraSpaces(attr.getName(), this.getName())) {
return false;
}
}
return true;
} else if (attr != null) {
return attr.getName().equals(this.getName());
return SQLUtils.equalsWithoutExtraSpaces(attr.getName(), this.getName());
}
}
return false;
......
......@@ -631,4 +631,40 @@ public final class SQLUtils {
}
return hasFixes ? String.valueOf(fixed) : sql;
}
public static boolean equalsWithoutExtraSpaces(String str1, String str2) {
return removeExtraSpaces(str1).equals(removeExtraSpaces(str2));
}
public static String removeExtraSpaces(String str) {
if (str.indexOf(' ') == -1) {
return str;
}
StringBuilder result = new StringBuilder(str.length());
int length = str.length();
for (int i = 0; i < length; i++) {
char c = str.charAt(i);
if (Character.isWhitespace(c)) {
boolean needsSpace = Character.isLetterOrDigit(c);
for (i = i + 1; i < length; i++) {
c = str.charAt(i);
if (Character.isWhitespace(c)) {
continue;
}
if (needsSpace && Character.isLetterOrDigit(c)) {
// We need exactly one space before letter/digit
result.append(' ');
} else {
// We don't need spaces before control symbols
}
result.append(c);
break;
}
} else {
result.append(c);
}
}
return result.toString();
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册