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.
TSQ005Runtime SQL cannot be analyzed statically.
TSQ006Source analysis exceeded a compiler resource limit.
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.
TSQ218A statement writes to a column that is not writable.
TSQ219An INSERT omits a required target column.
TSQ220A recursive CTE has an invalid member shape.
TSQ221A recursive CTE member uses a prohibited aggregate or window function.
TSQ222A named or framed window definition is invalid.
TSQ223A window-function invocation uses a prohibited modifier.
TSQ224An SQLite UPSERT clause is structurally ambiguous or invalid.
TSQ225An SQLite RETURNING expression uses an unavailable result source.
TSQ226An UPSERT conflict target does not match a unique constraint.
TSQ227An SQLite built-in function invocation has an invalid shape.
TSQ228A grouped query or clause contains an aggregate, window, or column reference in an invalid context.
TSQ229A data-modification value cannot be assigned to its target column.
TSQ230An explicit cast has no recorded conversion path.
TSQ301The live schema or type policy differs from the generated snapshot.
TSQ401The dialect surface is intentionally unsupported.
TSQ402Exact analysis requires normalized server evidence.
TSQ403The recorded server version is outside the supported range.
TSQ404The SQL feature is newer than the recorded server version.
TSQ405The SQL feature was removed before the recorded server version.
TSQ406A required server feature, setting, or capability declaration is absent.
TSQ407Recorded server settings make SQL behavior ambiguous.
TSQ500Live database metadata differs from compiler evidence.
TSQ501A query could not be verified safely or completely.
TSQ502Native verification failed; driver details are not persisted.

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.