Skip to content

Diagnostics

Automation should depend on diagnostic codes and source ranges, not English message text. The machine-readable registry is exported as diagnosticRegistry from @typed-sql/core.

CodeMeaning
TSQ001SQL syntax could not be parsed.
TSQ002SQL exceeded a parser resource limit.
TSQ003Conditional SQL exceeded the structural variant limit.
TSQ004Structural SQL requires an explicitly trusted fragment.
TSQ007The schema snapshot and dialect do not match.
TSQ100A referenced table does not exist.
TSQ101A referenced column does not exist.
TSQ102A column reference is ambiguous.
TSQ103A relation alias or qualified column is unknown.
TSQ104A result expression needs an explicit output name.
TSQ105Two result columns produce the same property name.
TSQ106A cast target is invalid or unknown.
TSQ107An unqualified table name is ambiguous.
TSQ108A relation alias is duplicated.
TSQ202A function is unknown.
TSQ203An operator cannot be inferred safely.
TSQ204A function overload is ambiguous.
TSQ205A composed parameter has incompatible structural contexts.
TSQ210Recursive CTE inference is not supported safely.
TSQ211A CTE name is duplicated.
TSQ212A CTE does not return rows.
TSQ213A CTE column list has the wrong arity.
TSQ214INSERT source and target arities differ.
TSQ215A JOIN USING column is not unique on both sides.
TSQ216A scalar subquery does not return exactly one column.
TSQ217An IN subquery does not return exactly one column.
TSQ301The live schema or type policy differs from the generated snapshot.
TSQ401The dialect surface is intentionally unsupported.

Fixes

A diagnostic may include a structured SqlDiagnosticFix. Editor tooling validates its offsets and converts it to the editor's native edit format.

For example, TSQ004 can offer a preferred “Mark as sql.fragment” fix. The edit adds the explicit trust marker without copying, evaluating, or changing the nested template contents.

Unknown versus diagnostic

A conservative unknown means the SQL can remain valid but typed-sql cannot prove a narrower type. A diagnostic means the configured grammar found invalid, ambiguous, unsafe, stale, or deliberately unsupported behavior.

Released under the MIT License.