bynk.mysql.sql_param_count
Error A literal MySql statement has a different number of ? placeholders than the list literal passed with it holds, in a project that has a schema.sql.
When the project has a schema.sql, Bynk counts the parameters of each literal MySql statement: each ? takes the next value. It checks a list written out in place, or a name let-bound to one. A ? inside a single-quoted string literal, a backtick-quoted name or a comment (-- or /* … */) is text, not a parameter, as the driver reads it; the driver does not skip a double-quoted string or a # comment, so a ? in one is counted, and string literals are written with single quotes. Pass one MySqlValue for each ?, or change the SQL. ??, which mysql2 reads as an identifier placeholder, is counted as two parameters and is not supported.
Example
let _ <- Legacy.all("SELECT id FROM orders WHERE id = ? AND qty > ?", [MySqlInteger(id)]) // ✗ two parameters, one value
let _ <- Legacy.all("SELECT id FROM orders WHERE id = ? AND qty > ?", [MySqlInteger(id), MySqlInteger(5)]) // ✓In the Book
See also
- Every code in its category, Other, on the diagnostic index.
bynk explain bynk.mysql.sql_param_countshows the same from the installed toolchain, without a network.