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};
22
23/// SQL language entry.
24///
25/// `.sql` covers hand-written migrations, stored procedures and query files
26/// alike, all of which sqlfluff reads.
27pub static SQL: LanguageSupport = LanguageSupport {
28    name: "sql",
29    display_name: "SQL",
30    extensions: &[".sql"],
31    filenames: &[],
32    filename_prefixes: &[],
33    tools: &[&SQLFLUFF],
34    conventions: &[
35        "Queries that scan a whole table where an index exists",
36        "Joins missing a predicate, and accidental cross joins",
37        "NULL equality filtering out the rows it meant to match",
38        "Migrations that lock or rewrite a large table",
39        "Ordering without a tiebreaker that pages nondeterministically",
40    ],
41    vendored_dirs: &[],
42};
43
44/// The family's entries in registration order. See `ALL_LANGUAGES`.
45pub(crate) static FAMILY: &[&LanguageSupport] = &[&SQL];