oxide_sql_core/dialect/
mod.rs

1//! SQL Dialect support.
2//!
3//! Different databases have slightly different SQL syntax. This module provides
4//! a trait for dialect-specific behavior.
5
6mod generic;
7
8pub use generic::GenericDialect;
9
10/// Trait for SQL dialect-specific behavior.
11pub trait Dialect {
12    /// Returns the name of the dialect.
13    fn name(&self) -> &'static str;
14
15    /// Returns the identifier quote character (e.g., `"` for standard SQL, `` ` `` for MySQL).
16    fn identifier_quote(&self) -> char {
17        '"'
18    }
19
20    /// Returns the string escape character.
21    fn string_escape(&self) -> &'static str {
22        "''"
23    }
24
25    /// Returns the parameter placeholder style.
26    fn parameter_placeholder(&self) -> &'static str {
27        "?"
28    }
29
30    /// Returns whether the dialect supports RETURNING clause.
31    fn supports_returning(&self) -> bool {
32        false
33    }
34
35    /// Returns whether the dialect supports UPSERT (ON CONFLICT).
36    fn supports_upsert(&self) -> bool {
37        false
38    }
39
40    /// Returns whether the dialect supports LIMIT with OFFSET.
41    fn supports_limit_offset(&self) -> bool {
42        true
43    }
44
45    /// Quotes an identifier if necessary.
46    fn quote_identifier(&self, name: &str) -> String {
47        let quote = self.identifier_quote();
48        format!("{quote}{name}{quote}")
49    }
50}