sqlload 0.91.1

SQL data loading tooling.
//! How a warehouse compares an existing column's spelling with a name SQLLoad writes.

use crate::adapters::dispatch::main::dialect::sql_adapter::sql_adapter;
use crate::column_types::models::Warehouse;

/// Whether `warehouse` would store `column` under its own spelling when SQLLoad writes it, so a load can reach it by name; always when the warehouse is unknown.
pub(crate) fn kept_as_written(column: &str, warehouse: Option<Warehouse>) -> bool {
    warehouse.is_none_or(|warehouse| sql_adapter(warehouse).stored_name(column) == column)
}

/// Whether the existing `column` is the one a column SQLLoad writes as `named` lands in, by `warehouse`'s rules; exact when the warehouse is unknown.
pub(crate) fn reaches(column: &str, named: &str, warehouse: Option<Warehouse>) -> bool {
    match warehouse {
        Some(warehouse) => {
            let adapter = sql_adapter(warehouse);
            adapter.is_stored_as(column, &adapter.stored_name(named))
        }
        None => column == named,
    }
}