All rules

Style

postgresql/prefer-current-timestamp-over-now

Prefer SQL-standard `CURRENT_TIMESTAMP` over `now()` / `LOCALTIMESTAMP`.

  • Type layout
  • Recommended off
  • Fixable yes

Why this matters

`CURRENT_TIMESTAMP` is portable across SQL engines, while `now()` is PostgreSQL-only. The rule also flags `LOCALTIMESTAMP` / `LOCALTIME` and rewrites them to `CURRENT_TIMESTAMP` / `CURRENT_TIME` — the `LOCAL*` variants return the timezone-naive `timestamp` / `time` types, which is rarely what application code actually wants.

Examples

Incorrect

Incorrect
INSERT INTO events (created_at) VALUES (now());
Incorrect
SELECT LOCALTIMESTAMP, LOCALTIME FROM t;

Correct

Correct
INSERT INTO events (created_at) VALUES (CURRENT_TIMESTAMP);
Correct
SELECT CURRENT_TIMESTAMP, CURRENT_TIME FROM t;

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-current-timestamp-over-now": "warn",
    },
  },
];

Options

This rule has no options.

Try this rule

Edit the SQL — only prefer-current-timestamp-over-now 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-current-timestamp-over-now — 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