-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I have found these related issues/pull requests
Related Issues/PRs: None found
Description
Currently, when using sqlx::query_with(&sql, args).bind(x), the .bind(x) call appends the parameter to the end of the args list. However, in certain use cases, we need to insert parameters at the beginning of the list instead. For example:
fn some_fn(sql: &str, mut args: Arguments) {
args.add_front(1); // Desired API
sqlx::query_with(sql, args).bind(3).execute(pool).await?;
}In this scenario, we want the parameter 3 to appear before the existing args, not after.
Prefered solution
Introduce a method like add_front() or prepend() to the Arguments type, allowing users to insert parameters at the beginning of the list. Alternatively, provide a way to control the position of .bind() calls relative to existing arguments.
Is this a breaking change? Why or why not?
Is this a breaking change? Why or why not? No, this can be implemented as a non-breaking change by adding new methods to the Arguments type. Existing behavior would remain unchanged.