Skip to content

literal-case

SQLstylefix: safedefault: offsql/sqlfluff

Reports NULL, TRUE or FALSE not in the case that the policy option sets. With consistent (the default) the first one written fixes the case (upper, lower or capitalise) and a later one that cannot be in it is reported; the other values name the case. The fix writes the word in that case.

These literals are written as values in the query. Using one case for them keeps them uniform and easy to find.

To fix, write the literal in the case that the policy gives.

Reported
SELECT a, B, COUNT(c), sum(d), NULL, true, cast(e as INT), cast(f as text)
...
WHERE a = 1;
After the fix
SELECT a, b, COUNT(c), SUM(d), NULL, TRUE, CAST(e AS INT), CAST(f AS TEXT)
...
WHERE a = 1;
sql:
lint:
rules:
literal-case:
level: warn # off (default), warn, error
options:
policy: "consistent"
Option Type Default Description
policy string "consistent" The case the words must be in: consistent follows the first one written.
Values: consistent, upper, lower, capitalise

Enabled by the presets: sql/sqlfluff.

Suppress one line with sudsy-disable-next-line literal-case in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
sqlfluff CP04 full