pub enum Dialect {
SQLite,
PostgreSQL,
MySQL,
}Expand description
The SQL dialect a value type or schema targets, known at runtime.
A supported SQL database: SQLite, PostgreSQL or MySQL.
Parse one from a name with Dialect::parse or str::parse; print it
with Display ("sqlite", "postgresql", "mysql").
§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, with ? positional placeholders.
Compatible with: rusqlite, libsql, turso
PostgreSQL
PostgreSQL, with $1, $2, ... numbered placeholders.
Compatible with: tokio-postgres, postgres
MySQL
MySQL, with ? positional placeholders.
Compatible with: mysql
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 the dialect uses numbered placeholders ($1, $2, ...).
Only PostgreSQL does; SQLite and MySQL use ?.
Sourcepub const fn parse(s: &str) -> Option<Dialect>
pub const fn parse(s: &str) -> Option<Dialect>
Parses a dialect name, ignoring case. Returns None for an unknown name.
Accepted names:
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
Returns the start of the table attribute used in generated code, such
as "#[PostgresTable".
Sourcepub const fn index_prefix(&self) -> &'static str
pub const fn index_prefix(&self) -> &'static str
Returns the start of the index attribute used in generated code, such
as "#[PostgresIndex".
Sourcepub const fn schema_derive(&self) -> &'static str
pub const fn schema_derive(&self) -> &'static str
Returns the schema derive attribute used in generated code, such as
"#[derive(PostgresSchema)]".
Trait Implementations§
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 UnsafeUnpin 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<List> ListIncludes<Nil, ()> for List
impl<Mk> MarkerAggValidFor<()> for Mk
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