limbo_sqlite3_parser/to_sql_string/
mod.rs1mod expr;
4mod stmt;
5
6use crate::ast::TableInternalId;
7
8pub trait ToSqlContext {
10 fn get_table_name(&self, id: TableInternalId) -> &str;
14 fn get_column_name(&self, table_id: TableInternalId, col_idx: usize) -> &str;
16}
17
18pub trait ToSqlString {
20 fn to_sql_string<C: ToSqlContext>(&self, context: &C) -> String;
22}
23
24impl<T: ToSqlString> ToSqlString for Box<T> {
25 fn to_sql_string<C: ToSqlContext>(&self, context: &C) -> String {
26 T::to_sql_string(&self, context)
27 }
28}
29
30#[cfg(test)]
31mod tests {
32 use super::ToSqlContext;
33
34 struct TestContext;
35
36 impl ToSqlContext for TestContext {
37 fn get_column_name(&self, _table_id: crate::ast::TableInternalId, _col_idx: usize) -> &str {
38 "placeholder_column"
39 }
40
41 fn get_table_name(&self, _id: crate::ast::TableInternalId) -> &str {
42 "placeholder_table"
43 }
44 }
45}