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