Why this matters
`IN (...)` is shorter, easier to read, and gives the planner a single set instead of N disjunctions. The rule only collapses chains where every disjunct is an equality on the same left-hand side; mixed predicates are out of scope.
Examples
Incorrect
SELECT * FROM t WHERE x = 1 OR x = 2 OR x = 3;Correct
SELECT * FROM t WHERE x IN (1, 2, 3);SELECT * FROM t WHERE x = 1 OR y = 2; -- mixed lhs: not in scopeConfigure it
// eslint.config.js
import postgresql from "eslint-plugin-postgresql";
export default [
{
files: ["**/*.sql"],
languageOptions: {
parser: postgresql.configs.recommended.languageOptions.parser,
},
plugins: { postgresql },
rules: {
"postgresql/prefer-in-list-over-or": "warn",
},
},
]; Options
Edit the SQL — only prefer-in-list-over-or is enabled.
Pre-filled with the first incorrect example. Toggle off in the rule shelf to see how the diagnostic disappears.
Diagnostics
No issues found.
2 rules enabled.
Rule under test
prefer-in-list-over-or — plus no-syntax-error as a safety net.