table name
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user