pub enum Dialect {
SQLite,
PostgreSQL,
MySQL,
}Expand description
Re-export the unified Dialect enum from drizzle-types 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<Dialect>
pub fn parse(s: &str) -> Option<Dialect>
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
Trait Implementations§
Source§impl DialectExt for Dialect
impl DialectExt for Dialect
impl Copy for Dialect
impl Eq for Dialect
impl StructuralPartialEq for Dialect
Auto Trait Implementations§
impl Freeze for Dialect
impl RefUnwindSafe for Dialect
impl Send for Dialect
impl Sync for Dialect
impl Unpin for Dialect
impl UnwindSafe for Dialect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more