Skip to content

Commit 6606afb

Browse files
committed
Support hyphen in identifier names
1 parent 4192bde commit 6606afb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/utils/BasicPostgresSecurityValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class BasicPostgresSecurityValidator implements PostgresSecurityValidator
4343
* Documentation</a>
4444
*/
4545
private static final String DEFAULT_IDENTIFIER_PATTERN =
46-
"^[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$";
46+
"^[a-zA-Z_][a-zA-Z0-9_-]*(\\.[a-zA-Z_][a-zA-Z0-9_-]*)*$";
4747

4848
/**
4949
* Default pattern for JSON field names within JSONB columns.

document-store/src/test/java/org/hypertrace/core/documentstore/postgres/utils/PostgresSecurityValidatorTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ void testValidIdentifierWithNumbers() {
3131
assertDoesNotThrow(() -> validator.validateIdentifier("col_1"));
3232
}
3333

34+
@Test
35+
void testValidIdentifierWithHyphens() {
36+
assertDoesNotThrow(() -> validator.validateIdentifier("API.repo-url"));
37+
}
38+
3439
@Test
3540
void testInvalidIdentifierNull() {
3641
SecurityException ex =

0 commit comments

Comments
 (0)