pub struct MySqlProjectionGenerator { /* private fields */ }Expand description
MySQL SQL projection generator.
MySQL uses JSON_OBJECT() for field projection, similar to PostgreSQL’s jsonb_build_object().
Generates efficient SQL that projects only requested JSON fields.
§Example
use fraiseql_db::projection_generator::MySqlProjectionGenerator;
let generator = MySqlProjectionGenerator::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 MySqlProjectionGenerator
impl MySqlProjectionGenerator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new MySQL 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 MySQL projection SQL for specified fields.
Generates a JSON_OBJECT() call that selects only the requested fields
from the JSON column.
§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 MySqlProjectionGenerator
impl RefUnwindSafe for MySqlProjectionGenerator
impl Send for MySqlProjectionGenerator
impl Sync for MySqlProjectionGenerator
impl Unpin for MySqlProjectionGenerator
impl UnsafeUnpin for MySqlProjectionGenerator
impl UnwindSafe for MySqlProjectionGenerator
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