use super::types::{CanonicalType, TypeCategory, TypeSupport};
pub trait Dialect: Send + Sync + 'static {
fn name(&self) -> &'static str;
fn ddl_type(&self, t: &CanonicalType) -> String;
fn cast_name(&self, t: &CanonicalType) -> Option<String>;
fn type_category(&self, t: &CanonicalType) -> TypeCategory;
fn type_support(&self, t: &CanonicalType) -> TypeSupport;
fn quote_ident(&self, s: &str) -> String;
fn placeholder(&self, n: usize) -> String;
fn cast_expr(&self, placeholder: &str, cast: &str) -> String;
fn now_fn(&self) -> &'static str;
fn uuid_default_expr(&self) -> &'static str;
fn returning_clause(&self, cols: &str) -> String;
fn upsert_conflict(&self, conflict_cols: &[&str], set_pairs: &str) -> String;
fn to_one_subquery(&self, col_exprs: &[String], from_clause: &str) -> String;
fn to_many_subquery(&self, col_exprs: &[String], from_clause: &str) -> String;
fn json_extract_text(&self, col: &str, key: &str) -> String;
fn json_extract_typed(&self, col: &str, key: &str, t: &CanonicalType) -> String;
fn case_insensitive_like(&self, col: &str, placeholder: &str) -> String;
fn sys_json_type(&self) -> &'static str;
fn sys_timestamp_type(&self) -> &'static str;
fn sys_timestamp_default(&self) -> String {
format!(
"{} NOT NULL DEFAULT {}",
self.sys_timestamp_type(),
self.now_fn()
)
}
fn sys_bigserial_type(&self) -> &'static str;
fn sys_bytes_type(&self) -> &'static str;
fn audit_timestamp_type(&self) -> &'static str;
fn supports_schemas(&self) -> bool {
true
}
fn default_now_plus_hours(&self, hours: u32) -> Option<String> {
Some(format!("NOW() + INTERVAL '{} hours'", hours))
}
fn supports_rls(&self) -> bool;
fn supports_named_enum_types(&self) -> bool;
fn supports_index_include(&self) -> bool;
fn set_tenant_session_sql(&self, tenant_id: &str) -> Option<String>;
}