table name

This commit is contained in:
Filipriec
2026-08-25 13:01:32 +02:00
parent ed01d1ec5b
commit aea54f8d33
12 changed files with 135 additions and 45 deletions

View File

@@ -9,6 +9,13 @@ use unicode_properties::{GeneralCategoryGroup, UnicodeEmoji, UnicodeGeneralCateg
/// labels in a few query paths, so the limit is measured in UTF-8 bytes.
pub const MAX_ALIAS_BYTES: usize = 63;
/// The case-insensitive key used to compare public table names. Table names
/// have a deliberately small ASCII vocabulary, so PostgreSQL's `lower()` and
/// this function produce the same stored key.
pub fn canonical_table_name(table_name: &str) -> String {
table_name.to_ascii_lowercase()
}
/// Whether a display alias contains control, formatting, private-use, or
/// unassigned characters that should never be persisted as visible naming.
pub fn has_disallowed_alias_characters(alias: &str) -> bool {
@@ -68,6 +75,11 @@ pub fn canonical_alias(alias: &str) -> String {
mod tests {
use super::*;
#[test]
fn table_names_compare_without_ascii_case() {
assert_eq!(canonical_table_name("Sales-2026_Q4"), "sales-2026_q4");
}
#[test]
fn aliases_compare_by_compatibility_case_and_without_emoji() {
assert_eq!(canonical_alias("Apple"), "apple");