mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-03 07:45:30 +00:00
fix(mysql): gate com_stmt_execute encode on non-empty params, not non-null params
This commit is contained in:
parent
dc0d325738
commit
cf78472d6d
@ -18,7 +18,7 @@ impl<'q> Encode<'_, Capabilities> for Execute<'q> {
|
|||||||
buf.push(0); // NO_CURSOR
|
buf.push(0); // NO_CURSOR
|
||||||
buf.extend(&0_u32.to_le_bytes()); // iterations (always 1): int<4>
|
buf.extend(&0_u32.to_le_bytes()); // iterations (always 1): int<4>
|
||||||
|
|
||||||
if !self.arguments.values.is_empty() {
|
if !self.arguments.types.is_empty() {
|
||||||
buf.extend(&*self.arguments.null_bitmap);
|
buf.extend(&*self.arguments.null_bitmap);
|
||||||
buf.push(1); // send type to server
|
buf.push(1); // send type to server
|
||||||
|
|
||||||
|
@ -200,3 +200,38 @@ async fn it_caches_statements() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sqlx_macros::test]
|
||||||
|
async fn it_can_bind_null_and_non_null_issue_540() -> anyhow::Result<()> {
|
||||||
|
let mut conn = new::<MySql>().await?;
|
||||||
|
|
||||||
|
let row = sqlx::query("SELECT ?, ?")
|
||||||
|
.bind(50_i32)
|
||||||
|
.bind(None::<i32>)
|
||||||
|
.fetch_one(&mut conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let v0: Option<i32> = row.get(0);
|
||||||
|
let v1: Option<i32> = row.get(1);
|
||||||
|
|
||||||
|
assert_eq!(v0, Some(50));
|
||||||
|
assert_eq!(v1, None);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx_macros::test]
|
||||||
|
async fn it_can_bind_only_null_issue_540() -> anyhow::Result<()> {
|
||||||
|
let mut conn = new::<MySql>().await?;
|
||||||
|
|
||||||
|
let row = sqlx::query("SELECT ?")
|
||||||
|
.bind(None::<i32>)
|
||||||
|
.fetch_one(&mut conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let v0: Option<i32> = row.get(0);
|
||||||
|
|
||||||
|
assert_eq!(v0, None);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user