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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sarj_sql_lint-0.6.4-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sarj_sql_lint-0.6.4-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sarj_sql_lint-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b3bb2faacb69abe1abd25d5523e67470b655ca99de6be5b4e1c26fb86ea6ad
MD5 37b0026b0229ae079142d3f8efb03b1c
BLAKE2b-256 5d961004a5650fc0a83e2697fe0e1b0af640e7b73e275275216aca063f661e76

See more details on using hashes here.

Provenance

The following attestation bundles were made for sarj_sql_lint-0.6.4-py3-none-any.whl:

Publisher: release.yml on sarj-ai/standards

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

This release

0.6.4 This release

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

2 files

0.6.0

2 files

0.5.0

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