pub enum DatabaseType {
PostgreSQL,
MySQL,
SQLite,
SQLServer,
}Expand description
Database types supported by FraiseQL.
§Stability
This enum is intentionally not #[non_exhaustive]. All match sites in the
codebase must handle every variant explicitly, giving compile-time assurance that
new database backends are fully integrated before release.
Adding a new variant is a semver-breaking change (minor version bump with
migration guide), because downstream exhaustive match expressions will fail
to compile. If you match on DatabaseType and want forward compatibility, add
a wildcard arm:
match db_type {
DatabaseType::PostgreSQL => { /* ... */ }
DatabaseType::MySQL => { /* ... */ }
DatabaseType::SQLite => { /* ... */ }
DatabaseType::SQLServer => { /* ... */ }
// no wildcard needed — exhaustive by design
}Variants§
PostgreSQL
PostgreSQL database (primary, full feature set).
MySQL
MySQL database (secondary support).
SQLite
SQLite database (local dev, testing).
SQLServer
SQL Server database (enterprise).
Implementations§
Source§impl DatabaseType
impl DatabaseType
Sourcepub fn json_field_expr(self, key: &str) -> String
pub fn json_field_expr(self, key: &str) -> String
Return a SQL expression that extracts a text value from the data JSONB column.
The key must already be validated via OrderByClause::validate_field_name
and converted to snake_case storage form via OrderByClause::storage_key.
§Examples
use fraiseql_db::DatabaseType;
assert_eq!(DatabaseType::PostgreSQL.json_field_expr("created_at"), "data->>'created_at'");
assert_eq!(DatabaseType::MySQL.json_field_expr("name"), "JSON_UNQUOTE(JSON_EXTRACT(data, '$.name'))");Sourcepub fn typed_json_field_expr(
self,
key: &str,
field_type: OrderByFieldType,
) -> String
pub fn typed_json_field_expr( self, key: &str, field_type: OrderByFieldType, ) -> String
Return a SQL expression that extracts and casts a value from the data JSONB
column for ORDER BY sorting.
When field_type is OrderByFieldType::Text this is identical to
json_field_expr. For numeric, date, and boolean
types the expression is wrapped in a dialect-specific cast so the database
sorts by the typed value instead of the raw text ("9" > "10" is wrong for
numbers).
§Examples
use fraiseql_db::{DatabaseType, OrderByFieldType};
assert_eq!(
DatabaseType::PostgreSQL.typed_json_field_expr("amount", OrderByFieldType::Numeric),
"(data->>'amount')::numeric"
);
assert_eq!(
DatabaseType::MySQL.typed_json_field_expr("amount", OrderByFieldType::Numeric),
"CAST(JSON_UNQUOTE(JSON_EXTRACT(data, '$.amount')) AS DECIMAL(38,12))"
);Sourcepub const fn supports(self, feature: Feature) -> bool
pub const fn supports(self, feature: Feature) -> bool
Check whether this dialect supports feature.
All checks are const-friendly and zero-cost at runtime.
Sourcepub const fn suggestion_for(self, feature: Feature) -> Option<&'static str>
pub const fn suggestion_for(self, feature: Feature) -> Option<&'static str>
Return a human-readable migration suggestion for an unsupported feature.
None means no specific guidance is available beyond the error message.
Trait Implementations§
Source§impl Clone for DatabaseType
impl Clone for DatabaseType
Source§fn clone(&self) -> DatabaseType
fn clone(&self) -> DatabaseType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DatabaseType
impl Debug for DatabaseType
Source§impl<'de> Deserialize<'de> for DatabaseType
impl<'de> Deserialize<'de> for DatabaseType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for DatabaseType
impl Display for DatabaseType
Source§impl Hash for DatabaseType
impl Hash for DatabaseType
Source§impl PartialEq for DatabaseType
impl PartialEq for DatabaseType
Source§fn eq(&self, other: &DatabaseType) -> bool
fn eq(&self, other: &DatabaseType) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for DatabaseType
impl Serialize for DatabaseType
impl Copy for DatabaseType
impl Eq for DatabaseType
impl StructuralPartialEq for DatabaseType
Auto Trait Implementations§
impl Freeze for DatabaseType
impl RefUnwindSafe for DatabaseType
impl Send for DatabaseType
impl Sync for DatabaseType
impl Unpin for DatabaseType
impl UnsafeUnpin for DatabaseType
impl UnwindSafe for DatabaseType
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.