Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration file

sqlsift check and sqlsift schema look for sqlsift.toml in the current directory and its parents, or use the file given with --config <FILE>. The language server reads it from the workspace root. Command-line options override values from the file. sqlsift init writes a commented starting point for your project.

# Schema
schema = ["db/schema/*.sql"]      # schema files (glob patterns supported)
schema_dir = "db/migrations"      # all .sql files under this directory, in file-name order

# Query files
files = ["queries/**/*.sql"]      # query files to check when none are given on the command line
ignore = ["queries/archive/**", "**/*.generated.sql"]  # query files to skip

dialect = "postgresql"            # postgresql, mysql, sqlite; alpha: snowflake, bigquery, redshift, databricks
templating = "jinja"              # jinja (dbt models) or none
dbt_catalog = "target/catalog.json"  # dbt catalog with the columns of ref() / source() (alpha)
format = "human"                  # human, json, sarif or github
max_warnings = 0                  # fail when more than this many warnings are reported
baseline = "sqlsift-baseline.json"  # known diagnostics that are not reported
embedded_sql_tags = ["sql", "$queryRaw"]  # template literal tags checked in .ts/.js files

# Rules
disable = ["E0006"]               # rules to turn off (same as `E0006 = "off"` below)

[rules]                           # per-rule level: "off", "warn" or "error"
E0008 = "warn"                    # by code...
ambiguous-column = "off"          # ...or by name

[categories]                      # level of every rule in a category
correctness = "error"

Keys

KeyTypeDefaultDescription
schemalist of paths / globs[]Schema files, loaded in order
schema_dirpathnoneDirectory of schema files, loaded recursively in file-name order, skipping rollback migrations
fileslist of paths / globs[]Query files to check when none are given on the command line
ignorelist of globs[]Query files to skip. ** matches any number of directories; a pattern matching a directory skips everything below it. --ignore adds to this list
dialectstring"postgresql"postgresql, mysql or sqlite
templatingstringautojinja masks dbt / Jinja templates in query files, none turns that off. When unset, jinja is used if a dbt_project.yml is in the current directory, next to sqlsift.toml or in a directory above the query file. See dbt and Jinja templates
dbt_catalogpathautodbt catalog.json (from dbt docs generate) with the columns of the models and sources that {{ ref() }} / {{ source() }} name (alpha); schema files are optional with one. When unset, target/catalog.json of the dbt project is used if it exists (unless templating = "none"). --dbt-catalog overrides it. See Columns of models and sources
formatstring"human"human, json, sarif or github
max_warningsintegernoneFail when more than this many warnings are reported
baselinepathnoneBaseline file of known diagnostics, hidden by sqlsift check and the language server; --baseline overrides it. See Baseline
embedded_sql_tagslist of strings["sql"]Tags of the template literals checked as SQL in TypeScript, JavaScript, Vue and Svelte files, matched against the tag expression's last or first identifier (sql matches db.sql, sql.unsafe and sql.type(schema)) (see SQL in TypeScript and JavaScript)
disablelist of rules[]Rules (codes or names) to turn off
[rules]tableLevel per rule: "off", "warn" or "error"
[categories]tableLevel per category: correctness, suspicious, pedantic, style, restriction

Paths

Relative paths and patterns in the file are resolved against the directory containing sqlsift.toml, so the same file works from any subdirectory.

Validation

Unknown keys produce a warning. Invalid dialect, templating or format values, unknown rules or categories and invalid levels are errors (exit code 2), with a suggestion when the name is close to a valid one.