Closed wedobetter closed 2 years ago
Parameters can only stand in for values in a query, not arbitrary substrings. Things like table and column names need to be directly inline in the query.
Right, I never used params in SQL, I thought they were interpolated before the DB query.
Then in my case what I need is a format!("...{}...")
instead.
Thank you!
(My second week learning Rust) I can't figure out why this is not being parsed:
giving me:
thread 'main' panicked at 'called
Result::unwrap()on an
Errvalue: Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42601), message: "syntax error at or near \"$2\"", detail: None, hint: None, position: Some(Original(14)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1176), routine: Some("scanner_yyerror") }) }', src/ds.rs:32:10 stack backtrace:
This doesn't work either:
I have obviously checked if this would work fine and it does:
db.query("CREATE INDEX username_idx ON users (username)", &[]) .await.unwrap();
Cargo.toml