mod expr;
mod stmt;
use crate::ast::TableInternalId;
pub trait ToSqlContext {
fn get_table_name(&self, id: TableInternalId) -> &str;
fn get_column_name(&self, table_id: TableInternalId, col_idx: usize) -> &str;
}
pub trait ToSqlString {
fn to_sql_string<C: ToSqlContext>(&self, context: &C) -> String;
}
impl<T: ToSqlString> ToSqlString for Box<T> {
fn to_sql_string<C: ToSqlContext>(&self, context: &C) -> String {
T::to_sql_string(&self, context)
}
}
#[cfg(test)]
mod tests {
use super::ToSqlContext;
struct TestContext;
impl ToSqlContext for TestContext {
fn get_column_name(&self, _table_id: crate::ast::TableInternalId, _col_idx: usize) -> &str {
"placeholder_column"
}
fn get_table_name(&self, _id: crate::ast::TableInternalId) -> &str {
"placeholder_table"
}
}
}