Diagnostic codes
Every Finding check reports has a code. Drop a code with --ignore CODE or
ignore = [...] in [tool.sqlassert] (see CLI).
Unproved assertions
An assertion that is not proved is reported with one code per marker. Its
Causes say where the Property is lost; --explain prints the whole proof.
| Code |
Marker |
unproved-unique |
ASSERT UNIQUE(...) |
unproved-not-null-unique |
ASSERT NOT NULL UNIQUE(...), ASSERT PRIMARY KEY(...) |
unproved-not-null |
ASSERT NOT NULL(...) |
unproved-not-null-elements |
ASSERT NOT NULL ELEMENTS(...) |
unproved-foreign-key |
ASSERT FOREIGN KEY(...) REFERENCES ... |
unproved-determines |
ASSERT DETERMINES(...) |
unproved-enum |
ASSERT ENUM(...) |
unproved-exhaustive |
ASSERT EXHAUSTIVE |
unproved-unique-join |
ASSERT UNIQUE (or NOT MANY TO MANY) before a join |
unproved-many-to-one-join |
ASSERT MANY TO ONE |
unproved-one-to-many-join |
ASSERT ONE TO MANY |
unproved-one-to-one-join |
ASSERT ONE TO ONE |
unproved-exactly-one-join |
ASSERT EXACTLY ONE |
Diagnostics
A Diagnostic says what the analysis could not do, and why. A warning is a
Diagnostic that never fails check: the SQL is supported, but a fact is
missing (often one a connection would supply) and is treated as unknown.
Markers
| Code |
Meaning |
What to do |
unrecognized-marker |
A /**...**/ comment is not a sqlassert marker: a bare /**UNIQUE**/, a typo. |
Write it as the message suggests, e.g. /**ASSERT UNIQUE**/. |
unattached-marker |
A marker is malformed (a value listed twice in ENUM) or not where it can apply (EXHAUSTIVE not before a simple CASE). |
Fix it as the message says. |
unanalyzed-assertion |
The marker is in a part of the program the analysis does not model (a CASE inside a function call, a CTE nothing reads). |
Move it, or remove it. |
unknown-asserted-column |
The marker names a column the Select Expression does not output. |
Name an output column. |
unresolved-asserted-column |
The marker's columns cannot be resolved: they are ambiguous, or the Select Expression reads a relation whose columns are unknown. |
Alias the columns apart, or declare the relation with CREATE TABLE. |
unknown-referenced-column |
A FOREIGN KEY ... REFERENCES rel(cols) names a column rel does not have. |
Fix the referenced columns. |
cardinality-on-filtering-join |
A cardinality marker is on a SEMI or ANTI join, which outputs no right rows. |
Remove it. |
duplicate-declaration |
A relation is declared more than once, so no proof about it is accepted. |
Declare it once. |
always-null-column (warning) |
A proved Property holds only because a column it names is always NULL. |
Check the column: it is probably a mistake. |
SQL the analysis does not support
| Code |
Meaning |
What to do |
sql-parse-failed |
The SQL could not be parsed (in this dialect). |
Fix the SQL, or pass the right --dialect. |
unsupported-statement |
A statement is neither a CREATE nor the root select (or an ALTER TABLE other than adding a constraint or NOT NULL). |
Remove it from the analyzed program. |
unsupported-create-statement |
A CREATE of a kind other than TABLE, VIEW, INDEX or SCHEMA. |
Remove it, or ignore the code. |
multiple-root-selects |
A program has more than one root select. |
Put one query per file, or make the others views. |
recursive-view-definition |
A view is defined recursively. |
Not supported. |
unsupported-natural-join |
NATURAL JOIN anywhere in the program. |
Write ON or USING. |
unsupported-construct (warning or error) |
A construct the analysis does not model yet (a COLLATE, a case-sensitive quoted PostgreSQL identifier, ...), which may be why an assertion is UNKNOWN. |
Rewrite it if you can; otherwise the facts it touches are unknown. |
Schema
| Code |
Meaning |
What to do |
undeclared-table (warning) |
A table has no CREATE TABLE in the program, so its keys, nullability and column types are unknown. |
Add its CREATE TABLE, or analyze with a connection (analyze_database). |
constraint-without-table |
An ALTER TABLE or CREATE INDEX names a table not created earlier, so its constraints are ignored. |
Create the table first. |
invalid-foreign-key-constraint |
A foreign key pairs a different number of columns on each side. |
Fix the constraint. |
ignored-check-constraint (warning) |
A CHECK states no Enumerated Domain: only col IN (...) and col = v over literals, joined by AND, do. |
Nothing, or state the domain with DECLARE ENUM. |
Ambiguous or engine-dependent SQL
| Code |
Meaning |
What to do |
ambiguous-column (warning) |
A column in a subquery may belong to its own FROM or the outer query, since some tables have no declared columns. |
Qualify it, or declare the tables. |
ambiguous-duplicate-column (warning) |
A name that a derived table outputs more than once is referenced; sqlassert reads the first, as DuckDB does. |
Give the repeated columns distinct aliases. |
composite-comparison (warning) |
A comparison of arrays, rows or maps whose elements may be NULL may itself be NULL. |
If the elements are never NULL, DECLARE NOT NULL ELEMENTS(...). |
zoned-timestamp-cast (warning) |
A cast of a zoned timestamp is compared where the engine keeps each value's zone (Trino, Snowflake). |
Compare the timestamps, or convert to one zone first. |
unknown-function (warning) |
sqlassert knows no result type for a function in this dialect, so an equality on it proves nothing. |
CAST the call to the type it returns. |
Catalog (with a connection)
| Code |
Meaning |
What to do |
catalog-relation-not-found |
A relation the SQL reads is not in the database catalog. |
Check the name, schema and connection. |
catalog-metadata-unavailable |
Catalog metadata (a table, a view definition) could not be read. |
Check the connection's permissions. |
incomplete-catalog-metadata |
Catalog metadata was read but is incomplete, or a view definition is not one analyzable CREATE VIEW. |
Declare the relation in the SQL instead. |
unbound-foreign-key (warning) |
A catalog foreign key onto a table the SQL declares cannot be bound to that declaration (a referenced column it lacks, or a table declared twice). |
Declare the table once, with the referenced columns. |