REF005: named-query-parameter-mismatch
Named query parameters passed do not match the named query
| Code | REF005 |
| Name | named-query-parameter-mismatch |
| Category | References (REF) |
| Default severity | error |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Compares the parameters of every query binding, and the parameters dict
literal ({'line': 1} or dict(line=1), written in the call) of every
script call of system.db.runNamedQuery, runSFNamedQuery, execQuery
and execUpdate, with the parameters the named query declares: a
parameter the query declares but the binding or call does not pass, and a
parameter it passes but the query does not declare, are both reported.
Calls whose parameters are a variable or are unpacked (**kw) are not
checked: their keys are not known.
Why is this bad?
Section titled “Why is this bad?”The Designer fills a query binding's parameters from the named query when
the binding is created; a mismatch means the query changed afterwards. A
missing parameter is passed as null, so the query silently returns the
wrong rows (or fails on NOT NULL comparisons); an unknown one is
ignored, which usually hides a renamed parameter.
Example
Section titled “Example”Named query Machines/ByLine declares line:
{"type": "query", "config": {"queryPath": "Machines/ByLine", "parameters": {"lineId": "{view.params.line}"}}}Use instead:
{"type": "query", "config": {"queryPath": "Machines/ByLine", "parameters": {"line": "{view.params.line}"}}}Generated from the rule metadata by iglint generate-docs; iglint rule REF005 prints the same page in the terminal. Source: docs/rules/REF005.md.