sqlload 0.41.0

SQL data loading tooling.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! A child table's name as dlt's default naming gives it.

use crate::load_naming::_helpers::snake_case::shortened;
use crate::load_naming::constants::CHILD_TABLE_SEPARATOR;
use crate::load_naming::main::_dlt_identifier::dlt_identifier;

/// The child table of `parent` (a name dlt's naming gave) for its list field `field`, as dlt's `shorten_fragments` joins them: `field` normalised as one name (its `__` merged), joined to `parent` with `__`, and the whole shortened to `max_length` with a tag of the joined name.
pub(in crate::load_naming) fn dlt_child_table(
    parent: &str,
    field: &str,
    max_length: Option<usize>,
) -> String {
    let joined = format!(
        "{parent}{CHILD_TABLE_SEPARATOR}{}",
        dlt_identifier(field, max_length)
    );
    shortened(joined.clone(), &joined, max_length)
}