All rules

Style

postgresql/prefer-in-list-over-or

Prefer `x IN (a, b, c)` over `x = a OR x = b OR x = c`.

  • Type suggestion
  • Recommended off
  • Fixable no

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

Incorrect
SELECT * FROM t WHERE x = 1 OR x = 2 OR x = 3;

Correct

Correct
SELECT * FROM t WHERE x IN (1, 2, 3);
Correct
SELECT * FROM t WHERE x = 1 OR y = 2; -- mixed lhs: not in scope

Configure 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

This rule has no options.

Try this rule

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.

0 errors 0 warnings parse 0ms · rules 0ms
Diagnostics

No issues found.

2 rules enabled.

Rule under test prefer-in-list-over-or — plus no-syntax-error as a safety net.
eslint-plugin-postgresql

An ESLint plugin that lints .sql files with real PostgreSQL grammar and a curated set of best-practice rules.

© 2026 eslint-plugin-postgresql contributors Built on libpg-query · PostgreSQL 17