querydown/dialects/
dialect.rs

1use crate::syntax_tree::{Date, Duration};
2
3pub trait Dialect {
4    /// Quote a table or column for use in SQL.
5    fn quote_identifier(&self, ident: &str) -> String;
6
7    /// Quote a string for use in SQL.
8    fn quote_string(&self, string: &str) -> String;
9
10    /// Render a date literal
11    fn date(&self, date: &Date) -> String;
12
13    /// Render a duration literal
14    fn duration(&self, duration: &Duration) -> String;
15
16    /// Render a table and column reference
17    fn table_column(&self, table: &str, column: &str) -> String {
18        let quoted_table = self.quote_identifier(table);
19        let quoted_column = self.quote_identifier(column);
20        format!("{}.{}", quoted_table, quoted_column)
21    }
22}