pub struct SqliteProjectionGenerator { /* private fields */ }Expand description
SQLite SQL projection generator.
SQLite’s JSON support is more limited than PostgreSQL and MySQL.
Uses json_object() with json_extract() to project fields.
§Example
use fraiseql_db::projection_generator::SqliteProjectionGenerator;
let generator = SqliteProjectionGenerator::new();
let fields = vec!["id".to_string(), "name".to_string()];
let sql = generator.generate_projection_sql(&fields).unwrap();
assert!(sql.contains("json_object"));Implementations§
Source§impl SqliteProjectionGenerator
impl SqliteProjectionGenerator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new SQLite projection generator with default JSON column name.
Default JSON column: “data”
Sourcepub fn with_column(json_column: &str) -> Self
pub fn with_column(json_column: &str) -> Self
Create projection generator with custom JSON column name.
§Arguments
json_column- Name of the JSON column in the database table
Sourcepub fn generate_projection_sql(&self, fields: &[String]) -> Result<String>
pub fn generate_projection_sql(&self, fields: &[String]) -> Result<String>
Generate SQLite projection SQL for specified fields.
Generates a json_object() call that selects only the requested fields.
§Arguments
fields- JSON field names to project
§Returns
SQL fragment that can be used in a SELECT clause
§Errors
Returns FraiseQLError::Validation if any field name cannot be safely projected.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SqliteProjectionGenerator
impl RefUnwindSafe for SqliteProjectionGenerator
impl Send for SqliteProjectionGenerator
impl Sync for SqliteProjectionGenerator
impl Unpin for SqliteProjectionGenerator
impl UnsafeUnpin for SqliteProjectionGenerator
impl UnwindSafe for SqliteProjectionGenerator
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more