Skip to main content

sarj-sql-lint

Custom SQL lint rules for Postgres migrations. AST-based via sqlfluff for the SARJ101 rule + zero-dependency pygrep regex hooks for migration-hygiene checks. Designed for pre-commit.

uv tool install sarj-sql-lint

Rules

Code id Flags
SARJ101 enforce-timestamptz TIMESTAMP without WITH TIME ZONE — use TIMESTAMPTZ
SARJ102 idempotent-ddl CREATE TABLE/INDEX/EXTENSION/SCHEMA/SEQUENCE/TYPE, ADD COLUMN, DROP TABLE/INDEX without IF [NOT] EXISTS
SARJ103 no-pg-enum CREATE TYPE ... AS ENUM / ALTER TYPE ... ADD VALUE — use TEXT + CHECK constraint
SARJ104 prefer-text-over-varchar VARCHAR(n) / CHARACTER VARYING(n) — use TEXT (+ CHECK length if needed)
SARJ105 insert-requires-on-conflict INSERT INTO statement (multi-line aware) with no ON CONFLICT clause
SARJ106 prefer-jsonb JSON column type or ::json cast — use JSONB
SARJ107 no-limit-offset OFFSET keyword — use cursor pagination (WHERE id > :cursor ... LIMIT n)
SARJ108 index-concurrently CREATE INDEX without CONCURRENTLY — locks the table against writes
SARJ109 prefer-uuidv7-default gen_random_uuid() (random UUIDv4) — use uuidv7() so keys are time-ordered

All scanning runs over a comment/string/dollar-quote-masked view of the source, so keywords inside --//* */ comments, '...' literals, $tag$...$tag$ bodies and "..." identifiers never match.

Suppression

Add a -- sarj-noqa comment on the offending line to silence a diagnostic; scope it to specific codes with -- sarj-noqa: SARJ101, SARJ108.

Pre-commit

- repo: https://github.com/sarj-ai/standards
  rev: sql-v0.1.0
  hooks:
    - id: sarj-enforce-timestamptz
      files: '\.sql$'
    - id: sarj-idempotent-ddl
      files: '\.sql$'
    - id: sarj-ban-postgres-enums
      files: '\.sql$'
    - id: sarj-ban-create-trigger
      files: '\.sql$'
    - id: sarj-prefer-text-over-varchar
      files: '\.sql$'
    - id: sarj-insert-requires-on-conflict
      files: '\.sql$'
    - id: sarj-prefer-jsonb
      files: '\.sql$'
    - id: sarj-no-limit-offset
      files: '\.sql$'
    - id: sarj-prefer-uuidv7-default
      files: '\.sql$'

CLI

sarj-sql-lint check --rule enforce-timestamptz svcs/db/db/migrations/*.sql
sarj-sql-lint list-rules

Diagnostic format is path:line:col: CODE message — Ruff-compatible.

Each rule's source under src/sarj_sql_lint/rules/ carries its own description and diagnostic message.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sarj_sql_lint-0.5.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sarj_sql_lint-0.5.0-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file sarj_sql_lint-0.5.0.tar.gz.

File metadata

  • Download URL: sarj_sql_lint-0.5.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sarj_sql_lint-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f78f6b7491c8ed8099d315718f993a65fd3ba5b34ad9031740f4f8643886623e
MD5 3ea51bad929292de61a6410bb61603c1
BLAKE2b-256 897efe2aed2f485eda1752063093948e33bd335ad3939f22cb1d59c2a3705479

See more details on using hashes here.

File details

Details for the file sarj_sql_lint-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: sarj_sql_lint-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sarj_sql_lint-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e4a0bb94092043014f0fb03bc9d283b3f58b1f510e5704f2161ca0f941b53b8
MD5 793e0ec8e61ffbfb4a6190b61b6a3a91
BLAKE2b-256 c0fc207c3e5dadf3a08089bc4a569c4ae7498c3e78fa610bb37527c9e8e5336c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.16.1

2 files

0.16.0

2 files

0.15.0

2 files

0.14.1

2 files

0.14.0

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

1 file

0.12.0

1 file

0.11.0

1 file

0.10.0

1 file

0.9.0

1 file

0.8.0

1 file

0.7.0

1 file

0.6.6

1 file

0.6.5

1 file

0.6.4

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

2 files

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page