go
data_error
ai_generated
true
error: sql: expected 2 arguments, got 3
ID: go/database-sql-query-arg-mismatch
80%Fix Rate
88%Confidence
0Evidence
2024-05-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.20 | active | — | — | — |
Root Cause
The number of placeholders in the SQL query does not match the number of arguments passed to Query or Exec.
generic中文
SQL 查询中的占位符数量与传给 Query 或 Exec 的参数数量不匹配。
Workarounds
-
95% success
Ensure the number of placeholders matches the number of arguments exactly.
-
90% success
Use named parameters with sql.Named to avoid count mismatches.
Dead Ends
Common approaches that don't work:
-
80% fail
This changes the query logic and may cause unintended results or errors.
-
90% fail
The query will not execute, and subsequent operations may fail.