sqlload 0.27.0

SQL data loading tooling. Pre-release, under development.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Table names for tabs.

/// The table a tab loads as when the source names no ranges: its title in lower case, with each run of other characters than letters and digits as one `_`.
pub fn tab_name(title: &str) -> String {
    let mut name = String::new();
    for character in title.trim().chars().flat_map(char::to_lowercase) {
        match character.is_alphanumeric() {
            true => name.push(character),
            false if !name.is_empty() && !name.ends_with('_') => name.push('_'),
            false => {}
        }
    }
    name.trim_end_matches('_').to_owned()
}