mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-09 06:42:57 +00:00
chore: relax table name constraint (#4766)
chore/relax-table-name-constraint: Updated NAME_PATTERN to allow '@' and '#' characters and adjusted tests for new table name validation rules.
This commit is contained in:
@@ -144,7 +144,7 @@ use crate::rpc::router::{region_distribution, RegionRoute, RegionStatus};
|
||||
use crate::rpc::store::BatchDeleteRequest;
|
||||
use crate::DatanodeId;
|
||||
|
||||
pub const NAME_PATTERN: &str = r"[a-zA-Z_:-][a-zA-Z0-9_:\-\.]*";
|
||||
pub const NAME_PATTERN: &str = r"[a-zA-Z_:-][a-zA-Z0-9_:\-\.@#]*";
|
||||
pub const MAINTENANCE_KEY: &str = "__maintenance";
|
||||
|
||||
const DATANODE_TABLE_KEY_PREFIX: &str = "__dn_table";
|
||||
|
||||
@@ -229,7 +229,7 @@ impl StatementExecutor {
|
||||
ensure!(
|
||||
NAME_PATTERN_REG.is_match(&create_table.table_name),
|
||||
InvalidTableNameSnafu {
|
||||
table_name: create_table.table_name.clone(),
|
||||
table_name: &create_table.table_name,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1516,6 +1516,12 @@ mod test {
|
||||
assert!(!NAME_PATTERN_REG.is_match("/adaf"));
|
||||
assert!(!NAME_PATTERN_REG.is_match("🈲"));
|
||||
assert!(NAME_PATTERN_REG.is_match("hello"));
|
||||
assert!(NAME_PATTERN_REG.is_match("test@"));
|
||||
assert!(!NAME_PATTERN_REG.is_match("@test"));
|
||||
assert!(NAME_PATTERN_REG.is_match("test#"));
|
||||
assert!(!NAME_PATTERN_REG.is_match("#test"));
|
||||
assert!(!NAME_PATTERN_REG.is_match("@"));
|
||||
assert!(!NAME_PATTERN_REG.is_match("#"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user