pub trait IntoSafeQuery<DB: Database> {
// Required method
fn into_sql_and_args(
self,
) -> Result<(SqlStr, Option<DB::Arguments>), SqlError>;
}Expand description
Splits a query into its SQL text and bound arguments for safe execution.
Lets Connection query methods accept either a bindless &str — wrapped
as sqlx::AssertSqlSafe and run through the unprepared text protocol — or a
parameterized sqlx::query(..).bind(..) value, without callers writing the
wrapper at every call site. Callers remain responsible for ensuring bindless
strings carry no injection (via read-only validation and identifier quoting).
The returned SqlStr owns its text, so no input borrow escapes. The
(SqlStr, Option<_>) pair is itself an sqlx::Execute value: a None
argument set routes through the unprepared text protocol, Some through a
prepared statement.
Required Methods§
Sourcefn into_sql_and_args(self) -> Result<(SqlStr, Option<DB::Arguments>), SqlError>
fn into_sql_and_args(self) -> Result<(SqlStr, Option<DB::Arguments>), SqlError>
Returns the SQL text and the bound arguments, if any.
§Errors
SqlError::Query — extracting bound arguments failed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".