Expand description
Hyperdrive H5 (#3322): a literal MySql statement’s SQL checked against a
MySQL parser, when the project supplies a schema.sql. It is H4’s check
(see crate::pg_sql) with sqlparser’s MySqlDialect:
bynk.mysql.sql_invalid(a warning): the statement does not parse, or holds more than one command (the driver is not configured for several, so it would refuse it);bynk.mysql.sql_param_count(an error): the number of?placeholders differs from the number of parameters the call passes.
sqlparser is not MySQL’s own parser, so the syntax finding is a warning,
for the reason H4 gives: an advisory check must never block a program that
runs. The placeholder count follows the driver, not the SQL standard, since
what matters is how many values mysql2’s query will consume: a ? is a
parameter unless it is inside a single-quoted string (where a backslash
escapes and a doubled quote is a quote), a backtick name, or a comment
(-- and /* … */). mysql2 (through sql-escaper) does not treat a
double-quoted string or a # comment as quoting, so a ? in either is
counted, as it is substituted; write string literals with single quotes.
Functions§
- check_
statement - The problems with the literal statement
sql, given the number of parameters the call passes when the list is written out (Noneleaves the count unchecked). - placeholder_
count - The number of
?placeholders a statement uses, by MySQL’s lexical rules.