1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum Dialect {
6 Postgres,
8 Mysql,
10 Sqlite,
12}
13
14impl Dialect {
15 pub fn placeholder(&self, index: usize) -> String {
17 match self {
18 Dialect::Postgres => format!("${}", index),
19 Dialect::Mysql => "?".to_string(),
20 Dialect::Sqlite => "?".to_string(),
21 }
22 }
23
24 pub fn quote(&self, ident: &str) -> String {
26 match self {
27 Dialect::Postgres => format!("\"{}\"", ident),
28 Dialect::Mysql => format!("`{}`", ident),
29 Dialect::Sqlite => format!("\"{}\"", ident),
30 }
31 }
32}