by SQLFix (LX AI)

Last updated: 2026-11-04

Why generated SQL needs a deterministic safety pass

A model can produce plausible SQL. That is the problem. Generated statements are usually syntactically valid, so a destructive query looks like ordinary output to a reviewer skimming a diff. A deterministic ruleset catches the handful of patterns that matter before the statement reaches a database.

Plausible is not safe

DROP TABLE users without a WHERE clause, an unqualified UPDATE that rewrites every row, and a DELETE with no predicate are all valid SQL. Nothing in the syntax marks them as dangerous; only context does. Reviewers who read for correctness rather than for blast radius are the usual path by which these reach production.

Rules that run before you copy

SQLFix screens each statement with the sql-safety@2026-07-19 ruleset. The checks are deterministic — the same input produces the same flags whether or not a live model is configured.

Each flag names the construct it matched, so a reviewer can accept or reject it without re-reading the whole statement.

The query is untrusted until reviewed

Treat output as a draft: read the explanation, check the tables and predicates, and run it in a read-only role first. Parameterized statements still belong in application code — generating SQL for a human to inspect is a different job from executing it behind a request handler.

A practical review order: confirm the target table, confirm the predicate, confirm the role the statement runs under. Flags that survive that check are usually the ones worth acting on.

What the ruleset does not do

It does not execute the query, inspect your schema, or certify that the statement is correct. Business logic, permissions, and indexes remain your own review. The output is a reviewed draft with a severity list, not a guarantee that a statement is safe to run.

Draft and screen a query

Decision-support drafts. Not legal advice, certification, or a guarantee that a query is safe to run. Reviewed by SQLFix (LX AI), 2026-11-04.