Fixed#8239: Query mismatch while searching for - and _ makes data overlap (#8476)

* Fixed#8239: Query mismatch while searching for - and _ makes data overlap

* Fixed#8239: Query mismatch while searching for - and _ makes data overlap
This commit is contained in:
Parth Panchal 2022-11-01 18:20:03 +05:30 committed by GitHub
parent 0701ef955e
commit af85b9629d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,6 +93,9 @@ public class ListFilter {
}
private String getFqnPrefixCondition(String tableName, String fqnPrefix) {
if (fqnPrefix.contains("_") || fqnPrefix.contains("-")) {
fqnPrefix = format(fqnPrefix);
}
return tableName == null
? String.format("fullyQualifiedName LIKE '%s%s%%'", fqnPrefix, Entity.SEPARATOR)
: String.format("%s.fullyQualifiedName LIKE '%s%s%%'", tableName, fqnPrefix, Entity.SEPARATOR);
@ -138,4 +141,8 @@ public class ListFilter {
private String escape(String name) {
return name.replace("'", "''");
}
private String format(String name) {
return name.contains("-") ? name.replaceAll("-", "\\\\-") : name.replaceAll("_", "\\\\_");
}
}