diff --git a/core/src/main/java/com/datastrato/gravitino/connector/capability/Capability.java b/core/src/main/java/com/datastrato/gravitino/connector/capability/Capability.java index 3cd425b7fd3..21a45db3342 100644 --- a/core/src/main/java/com/datastrato/gravitino/connector/capability/Capability.java +++ b/core/src/main/java/com/datastrato/gravitino/connector/capability/Capability.java @@ -94,7 +94,7 @@ class DefaultCapability implements Capability { * *

$ - End of the string */ - private static final String DEFAULT_NAME_PATTERN = "^[a-zA-Z0-9_][a-zA-Z0-9_/=-]{0,63}$"; + private static final String DEFAULT_NAME_PATTERN = "^\\w[\\w/=-]{0,63}$"; @Override public CapabilityResult columnNotNull() { diff --git a/core/src/test/java/com/datastrato/gravitino/connector/capability/TestCapability.java b/core/src/test/java/com/datastrato/gravitino/connector/capability/TestCapability.java index 0d955adac59..75a68dc35a0 100644 --- a/core/src/test/java/com/datastrato/gravitino/connector/capability/TestCapability.java +++ b/core/src/test/java/com/datastrato/gravitino/connector/capability/TestCapability.java @@ -18,6 +18,12 @@ void testDefaultNameSpecification() { CapabilityResult result = Capability.DEFAULT.specificationOnName(scope, "_name_123_/_=-"); Assertions.assertTrue(result.supported()); + result = Capability.DEFAULT.specificationOnName(scope, "name_123_/_=-"); + Assertions.assertTrue(result.supported()); + + result = Capability.DEFAULT.specificationOnName(scope, "Name_123_/_=-"); + Assertions.assertTrue(result.supported()); + // test for reserved name result = Capability.DEFAULT.specificationOnName(scope, SECURABLE_ENTITY_RESERVED_NAME); Assertions.assertFalse(result.supported()); @@ -44,6 +50,18 @@ void testDefaultNameSpecification() { Assertions.assertFalse(result.supported()); Assertions.assertTrue(result.unsupportedMessage().contains("is illegal")); + result = Capability.DEFAULT.specificationOnName(scope, "-name_start_with-"); + Assertions.assertFalse(result.supported()); + Assertions.assertTrue(result.unsupportedMessage().contains("is illegal")); + + result = Capability.DEFAULT.specificationOnName(scope, "/name_start_with/"); + Assertions.assertFalse(result.supported()); + Assertions.assertTrue(result.unsupportedMessage().contains("is illegal")); + + result = Capability.DEFAULT.specificationOnName(scope, "=name_start_with="); + Assertions.assertFalse(result.supported()); + Assertions.assertTrue(result.unsupportedMessage().contains("is illegal")); + // test for long name StringBuilder longName = new StringBuilder(); for (int i = 0; i < 64; i++) {