pub enum DatabaseType {
PostgreSQL,
}Expand description
Database types supported by FraiseQL.
FraiseQL is PostgreSQL-only: the MySQL, SQLite and SQL Server variants were removed with their adapters (G2 decision on #374 — the non-PostgreSQL dialects were never production-correct, see #721/#799). The enum is kept — rather than replaced with a unit type — so that SQL-generation seams stay explicitly tagged with the dialect they emit, and a future backend addition is a compile-time-visible change at every match site.
§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 variant is a
semver-breaking change (minor version bump with migration guide).
Variants§
PostgreSQL
PostgreSQL database (the only supported backend).
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'");Sourcepub fn dialect(self) -> &'static dyn SqlDialect
pub fn dialect(self) -> &'static dyn SqlDialect
Return the SqlDialect that renders SQL for this database.
The two dialect abstractions — this enum, used by the ORDER BY renderer,
and the SqlDialect trait, used by the WHERE generator — resolve to
the same implementation here, so neither can carry its own copy of a
rendering rule.
Sourcepub fn typed_json_field_expr(
self,
key: &str,
field_type: ScalarFieldType,
) -> String
pub fn typed_json_field_expr( self, key: &str, field_type: ScalarFieldType, ) -> String
Return a SQL expression that extracts and casts a value from the data JSONB
column for ORDER BY sorting.
When field_type is ScalarFieldType::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).
The cast itself comes from SqlDialect::cast_expr_as — the same call the
WHERE generator makes — so an ORDER BY and a filter on one field agree.
§Examples
use fraiseql_db::{DatabaseType, ScalarFieldType};
assert_eq!(
DatabaseType::PostgreSQL.typed_json_field_expr("amount", ScalarFieldType::Numeric),
"(data->>'amount')::numeric"
);Trait Implementations§
Source§impl Clone for DatabaseType
impl Clone for DatabaseType
impl Copy for DatabaseType
Source§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
impl Eq for DatabaseType
Source§impl Hash for DatabaseType
impl Hash for DatabaseType
Source§impl PartialEq for DatabaseType
impl PartialEq for DatabaseType
Source§impl Serialize for DatabaseType
impl Serialize 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.