-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Bug Description
rust-analyzer and cargo complains about the casing of a variable leading to false negatives
Minimal Reproduction
use sqlx::{prelude::FromRow, Connection, SqliteConnection};
const DATABASE_URL: &str = "./mydb/sqlite";
#[derive(Debug, FromRow)]
#[sqlx(rename_all = "UPPERCASE")]
pub struct ObjInfo {
pub name: String,
}
pub async fn get_info(name: &str) -> Result<ObjInfo, Box<dyn std::error::Error>> {
let mut conn = SqliteConnection::connect(DATABASE_URL).await?;
let param = format!("{}%", name);
let record = sqlx::query!("SELECT MYNAME FROM mytable WHERE MYNAME = ?", param)
.fetch_one(&mut conn)
.await?;
Ok(ObjInfo {
name: record.MYNAME.unwrap_or_default()
})
}
gives the error on the query as so:
Field `MYNAME` should have snake_case name, e.g. `myname`
Variable `sqlx_query_as_NAME` should have snake_case name, e.g. `sqlx_query_as_name`
Info
- SQLx version: 0.7.4
- SQLx features enabled:
sqlx = { version = "0.7.4", features = ["chrono", "macros", "runtime-tokio", "sqlite"] } - Database server and version: Sqlite
- Operating system: windows and openbsd
rustc --version: rustc 1.79.0 (129f3b996 2024-06-10)
Reactions are currently unavailable