pub enum Dialect {
SQLite,
PostgreSQL,
MySQL,
}Expand description
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<Self>
pub const fn parse(s: &str) -> Option<Self>
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)]".