Using a SQL Formatter Before Pull Request Review

Jun 2026 • Updated August 2026 • 9 min read • By Tarak Moyyi

Tarak Moyyi is a software engineer and the developer and maintainer of CompareStack.

Unformatted SQL hides review bugs

A wall of unbroken SQL in a pull request trains reviewers to skim. Missing JOIN conditions, duplicated filters, and accidental SELECT * patterns hide in dense text. Formatting does not change execution semantics, but it changes what humans notice.

Teams that adopt a shared layout—keywords on separate lines, indented JOIN chains, aligned column lists—report faster reviews and fewer post-merge incidents on reporting queries.

A pre-review formatting ritual

Before opening a PR, paste the query into CompareStack’s SQL formatter and read it clause by clause: sources, filters, grouping, ordering. If the formatted shape does not match your mental model, fix logic before asking teammates for review.

Attach formatted SQL to the PR description or ticket even when the repo stores a minified version—reviewers should not need to run a local formatter to see structure.

Pair formatting with diff tools

When updating a stored procedure or view, format both old and new versions, then compare with Text Compare. Structural changes (new JOIN, removed WHERE predicate) pop out as line additions and removals instead of inline character noise.

For data migration scripts, compare rollback and forward scripts side by side to ensure every INSERT has a matching DELETE or compensating step.

Limits of browser formatters

CompareStack’s SQL formatter improves readability for review and documentation. It does not replace dialect-specific linters, EXPLAIN plans, or migration testing in staging. Use it as the first human-readable pass, not the last quality gate before production.

What reviewers should scan first

After formatting, scan JOIN keys, WHERE filters that affect row counts, and SELECT * or unbounded date ranges. Those patterns cause more production incidents than keyword casing debates.

Ask authors to include sample row counts or EXPLAIN highlights for heavy reporting queries. Formatting makes the SQL readable; metrics make the risk clear.

Team checklist before merge

Use CompareStack’s SQL formatter for the readability pass, then keep dialect linters and CI as the merge gate.

  • SQL formatted and attached to the PR description.
  • Old vs new versions diffed when altering existing objects.
  • Secrets and customer literals redacted from examples.
  • Staging run completed for migration scripts.

PR template additions that help reviewers

Paste formatted SQL into the PR description or a linked ticket. Call out join keys, filter predicates, and whether the query is expected to touch large tables. Link an EXPLAIN when performance is relevant.

If the change updates an existing query, include a Text Compare of formatted old versus new so reviewers see structural edits immediately.

Reviewer checklist

Confirm FROM/JOIN sources match the ticket. Verify WHERE filters enforce tenancy and soft-delete rules. Check GROUP BY completeness for selected columns. Look for accidental cartesian risks when ON clauses are missing or weak.

Formatting makes these checks possible in minutes; unformatted walls of text make them unlikely under deadline pressure.

  • Formatted SQL attached to the PR.
  • Old vs new compared when editing existing queries.
  • EXPLAIN included for hot paths.
  • No credentials in samples.

FAQ: SQL in pull requests

Should SQL live in the app or in migration files? Follow your team standard; either way, format before review.

What about ORM-generated SQL? Capture the generated statement from logs, format it, and review as if it were hand-written—ORMs do not remove join mistakes.

Related guides