fix: support metadata comment search
Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
1 parent
745f7f60b0
commit
f2c429afd9
3 files changed
+124
-21
No files matched your search
@@ -102,13 +102,21 @@ public final class MetadataListConstraints {
|
||||
}
|
||||
|
||||
public boolean nameMatches(String name) {
|
||||
return textMatches(name);
|
||||
}
|
||||
|
||||
public boolean nameOrCommentMatches(String name, String comment) {
|
||||
return textMatches(name) || textMatches(comment);
|
||||
}
|
||||
|
||||
private boolean textMatches(String text) {
|
||||
if (filter.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (name == null) {
|
||||
if (text == null) {
|
||||
return false;
|
||||
}
|
||||
String candidate = name.toLowerCase(Locale.ROOT);
|
||||
String candidate = text.toLowerCase(Locale.ROOT);
|
||||
return candidate.contains(filter) || (filter.length() >= 2 && fuzzySubsequenceMatches(candidate, filter));
|
||||
}
|
||||
|
||||
@@ -118,7 +126,8 @@ public final class MetadataListConstraints {
|
||||
int max = limit == null ? Integer.MAX_VALUE : limit;
|
||||
int start = offset == null ? 0 : offset;
|
||||
for (TableInfo table : tables) {
|
||||
if (!nameMatches(table.getName()) || !tableTypeAllowed(table.getTable_type())) {
|
||||
if (!nameOrCommentMatches(table.getName(), table.getComment())
|
||||
|| !tableTypeAllowed(table.getTable_type())) {
|
||||
continue;
|
||||
}
|
||||
if (skipped++ < start) {
|
||||
@@ -138,7 +147,8 @@ public final class MetadataListConstraints {
|
||||
int max = limit == null ? Integer.MAX_VALUE : limit;
|
||||
int start = offset == null ? 0 : offset;
|
||||
for (ObjectInfo object : objects) {
|
||||
if (!nameMatches(object.getName()) || !objectTypeAllowed(object.getObject_type())) {
|
||||
if (!nameOrCommentMatches(object.getName(), object.getComment())
|
||||
|| !objectTypeAllowed(object.getObject_type())) {
|
||||
continue;
|
||||
}
|
||||
if (skipped++ < start) {
|
||||
|
||||
Reference in new issue
Block a user