pub enum Dialect {
Postgres,
Sqlite,
}Expand description
A supported database dialect.
Variants§
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub fn from_database(database: &str) -> Self
pub fn from_database(database: &str) -> Self
Pick the dialect from the manifest’s stack.database ("sqlite" → SQLite, else the
Postgres default).
Sourcepub fn id_pk_ddl(self) -> &'static str
pub fn id_pk_ddl(self) -> &'static str
The id primary-key column DDL (no trailing comma). Postgres generates the UUID in the
database; SQLite has no UUID generator, so the app supplies it on insert.
Sourcepub fn app_generates_id(self) -> bool
pub fn app_generates_id(self) -> bool
Whether the app must generate id on insert (SQLite) rather than the database (Postgres).
Sourcepub fn column_type(self, ty: FieldType) -> &'static str
pub fn column_type(self, ty: FieldType) -> &'static str
The SQL column type for a scalar field.
Sourcepub fn timestamp_type_default(self) -> &'static str
pub fn timestamp_type_default(self) -> &'static str
The TYPE NOT NULL DEFAULT ... fragment for the created_at/updated_at columns.
Sourcepub fn now_expr(self) -> &'static str
pub fn now_expr(self) -> &'static str
The SQL expression for “now” used in UPDATE ... SET updated_at = <now>.
Sourcepub fn placeholder(self, n: usize) -> String
pub fn placeholder(self, n: usize) -> String
A bind placeholder for parameter n (1-based): $n on Postgres, ?n on SQLite.
Sourcepub fn pool_options(self) -> &'static str
pub fn pool_options(self) -> &'static str
The sqlx pool-options type.
Sourcepub fn sqlx_module(self) -> &'static str
pub fn sqlx_module(self) -> &'static str
The sqlx submodule the pool types live in (sqlx::postgres / sqlx::sqlite).
Sourcepub fn sqlx_feature(self) -> &'static str
pub fn sqlx_feature(self) -> &'static str
The sqlx feature to enable in the generated Cargo.toml.
Sourcepub fn unique_violation_code(self) -> &'static str
pub fn unique_violation_code(self) -> &'static str
The integrity-error code a unique violation reports (mapped to 409 in generated code).
Postgres SQLSTATE 23505; SQLite extended result code 2067 (SQLITE_CONSTRAINT_UNIQUE).
Sourcepub fn foreign_key_violation_code(self) -> &'static str
pub fn foreign_key_violation_code(self) -> &'static str
The integrity-error code a foreign-key violation reports (mapped to 409).
Postgres 23503; SQLite 787 (SQLITE_CONSTRAINT_FOREIGNKEY).
Sourcepub fn example_url(self, project: &str) -> String
pub fn example_url(self, project: &str) -> String
An example DATABASE_URL for .env.example.
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.