E0341
Text where a sink literal type is required, such as a String, an Untrusted<String>, a string literal, or an interpolated string passed to Db.query as query text. Only a sql"..." literal makes an SqlLiteral, so SQL can't be built from text. Reported instead of E0220. Spans the expression.
Machine-applicable fix: none.
Example
This program fails with E0341.
use std.sql
fn run(db: sql.Db, id: Untrusted<String>) {
let rows = db.query("SELECT * FROM users", [id])
}
Fixed
The same program, fixed.
use std.sql
fn run(db: sql.Db, id: Untrusted<String>) {
let rows = db.query(sql"SELECT * FROM users WHERE id = ?", [id])
}
Listed in the checker notes. oskac explain E0341 prints this entry offline.