Skip to content
31 changes: 31 additions & 0 deletions crates/sqlbuild-analysis/src/compiler/_helpers/sql_tests/glue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! Projections of planned SQL tests into the facts the compiler reports.

use std::collections::HashSet;

use crate::compiler::models::SqlTestPlan;

const ERROR_SEVERITY: &str = "error";
const DEFAULT_WORKERS: usize = 4;

/// Each distinct error-severity warning message of one planned test, in warning order.
pub(crate) fn error_messages(plan: &SqlTestPlan) -> Vec<String> {
let mut seen: HashSet<&str> = HashSet::new();
plan.warnings
.iter()
.filter(|warning| warning.severity == ERROR_SEVERITY)
.filter(|warning| seen.insert(warning.message.as_str()))
.map(|warning| warning.message.clone())
.collect()
}

pub(crate) fn default_workers() -> usize {
DEFAULT_WORKERS
}

pub(crate) fn default_true() -> bool {
true
}

pub(crate) fn default_set_difference() -> String {
"EXCEPT".to_string()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod cte_slices;
pub mod cte_sql;
pub mod expected_columns;
pub mod extraction;
pub mod glue;
pub mod helper_names;
pub mod helper_scope;
pub mod markers;
Expand Down
Loading
Loading