diff --git a/sqlx-core/src/sqlite/arguments.rs b/sqlx-core/src/sqlite/arguments.rs index d3604f315a..abbe7fdd3b 100644 --- a/sqlx-core/src/sqlite/arguments.rs +++ b/sqlx-core/src/sqlite/arguments.rs @@ -61,6 +61,14 @@ impl SqliteArguments<'_> { if name.starts_with('?') { // parameter should have the form ?NNN atoi(name[1..].as_bytes()).expect("parameter of the form ?NNN") + } else if name.starts_with('$') { + // parameter should have the form $NNN + atoi(name[1..].as_bytes()).ok_or_else(|| { + err_protocol!( + "parameters with non-integer names are not currently supported: {}", + name + ) + })? } else { return Err(err_protocol!("unsupported SQL parameter format: {}", name)); } diff --git a/tests/sqlite/sqlite.rs b/tests/sqlite/sqlite.rs index dc1af83b4c..1761fdc3e4 100644 --- a/tests/sqlite/sqlite.rs +++ b/tests/sqlite/sqlite.rs @@ -269,6 +269,22 @@ fn it_binds_parameters() -> anyhow::Result<()> { Ok(()) } +#[sqlx_macros::test] +fn it_binds_dollar_parameters() -> anyhow::Result<()> { + let mut conn = new::().await?; + + let v: (i32, i32) = sqlx::query_as("SELECT $1, $2") + .bind(10_i32) + .bind(11_i32) + .fetch_one(&mut conn) + .await?; + + assert_eq!(v.0, 10); + assert_eq!(v.1, 11); + + Ok(()) +} + #[sqlx_macros::test] async fn it_executes_queries() -> anyhow::Result<()> { let mut conn = new::().await?;