mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-28 19:05:53 +00:00
Fix isParent method to correctly identify FQN parent-child relationships (#17208)
This commit is contained in:
parent
87c302ebf7
commit
e93bf7024f
@ -117,7 +117,9 @@ public class FullyQualifiedName {
|
||||
|
||||
public static boolean isParent(String childFqn, String parentFqn) {
|
||||
// Returns true if the childFqn is indeed the child of parentFqn
|
||||
return childFqn.startsWith(parentFqn) && childFqn.length() > parentFqn.length();
|
||||
// Adding "." ensures that we are checking for a true parent-child relationship
|
||||
// For example, "a.b.c" should be a child of "a.b" but "a.b c" should not be a child of "a.b"
|
||||
return childFqn.startsWith(parentFqn + ".") && childFqn.length() > parentFqn.length();
|
||||
}
|
||||
|
||||
private static class SplitListener extends FqnBaseListener {
|
||||
|
@ -103,5 +103,6 @@ class FullyQualifiedNameTest {
|
||||
assertFalse(FullyQualifiedName.isParent("a", "a.b.c"));
|
||||
assertFalse(FullyQualifiedName.isParent("a.b", "a.b.c"));
|
||||
assertFalse(FullyQualifiedName.isParent("a.b.c", "a.b.c"));
|
||||
assertFalse(FullyQualifiedName.isParent("a.b c", "a.b"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user