pub enum Dialect {
SQLite,
PostgreSQL,
MySQL,
}Expand description
SQL dialect for database-specific behavior
This enum represents the supported SQL database dialects in Drizzle ORM. Each dialect has different placeholder syntax, type mappings, and SQL generation rules.
§Examples
use drizzle_types::Dialect;
let dialect = Dialect::PostgreSQL;
assert!(dialect.uses_numbered_placeholders());
let sqlite = Dialect::SQLite;
assert!(!sqlite.uses_numbered_placeholders());Variants§
SQLite
SQLite - uses ? positional placeholders
Compatible with: rusqlite, libsql, turso
PostgreSQL
PostgreSQL - uses $1, $2, ... numbered placeholders
Compatible with: tokio-postgres, postgres, sqlx
MySQL
MySQL - uses ? positional placeholders
Compatible with: mysql, sqlx
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub const fn uses_numbered_placeholders(&self) -> bool
pub const fn uses_numbered_placeholders(&self) -> bool
Returns true if this dialect uses numbered placeholders ($1, $2, ...)
Currently only PostgreSQL uses numbered placeholders.
SQLite and MySQL use positional ? placeholders.
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse a dialect from a string (case-insensitive)
Supports various common aliases:
- SQLite:
"sqlite","turso","libsql" - PostgreSQL:
"postgresql","postgres","pg" - MySQL:
"mysql"
§Examples
use drizzle_types::Dialect;
assert_eq!(Dialect::parse("sqlite"), Some(Dialect::SQLite));
assert_eq!(Dialect::parse("postgres"), Some(Dialect::PostgreSQL));
assert_eq!(Dialect::parse("pg"), Some(Dialect::PostgreSQL));
assert_eq!(Dialect::parse("unknown"), None);Sourcepub const fn table_prefix(&self) -> &'static str
pub const fn table_prefix(&self) -> &'static str
Get the table attribute prefix for this dialect in generated code
Used by schema parsers and code generators.
Sourcepub const fn index_prefix(&self) -> &'static str
pub const fn index_prefix(&self) -> &'static str
Get the index attribute prefix for this dialect in generated code
Sourcepub const fn schema_derive(&self) -> &'static str
pub const fn schema_derive(&self) -> &'static str
Get the schema derive attribute for this dialect