Skip to main content

drep/languages/definitions/
sql.rs

1//! SQL: sqlfluff over `.sql`.
2
3use crate::languages::spec::{
4    DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
5};
6
7/// SQL deterministic checker.
8pub static SQLFLUFF: ToolSpec = ToolSpec {
9    name: "sqlfluff",
10    command: &["sqlfluff", "lint", "--format", "json"],
11    local_paths: &["venv/bin/sqlfluff", ".venv/bin/sqlfluff"],
12    config_files: &[".sqlfluff"],
13    config_flag: None,
14    output_format: OutputFormat::Sqlfluff,
15    diagnostics_stream: DiagnosticsStream::Stdout,
16    timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
17    timeout_context: None,
18    establishes_compilation: false,
19    serial_in_repository: false,
20    accepts_files: true,
21    reads_other_sources: true,
22};
23
24/// SQL language entry.
25///
26/// `.sql` covers hand-written migrations, stored procedures and query files
27/// alike, all of which sqlfluff reads.
28pub static SQL: LanguageSupport = LanguageSupport {
29    name: "sql",
30    display_name: "SQL",
31    extensions: &[".sql"],
32    filenames: &[],
33    filename_prefixes: &[],
34    tools: &[&SQLFLUFF],
35    conventions: &[
36        "Queries that scan a whole table where an index exists",
37        "Joins missing a predicate, and accidental cross joins",
38        "NULL equality filtering out the rows it meant to match",
39        "Migrations that lock or rewrite a large table",
40        "Ordering without a tiebreaker that pages nondeterministically",
41    ],
42    vendored_dirs: &[],
43};
44
45/// The family's entries in registration order. See `ALL_LANGUAGES`.
46pub(crate) static FAMILY: &[&LanguageSupport] = &[&SQL];