# SQL beta

SQL Analyzer helps you write good SQL and catch errors and bad SQL before it hits your database.

This section covers configuration specific to the SQL analyzer. Please make sure to read the general configuration guide first.

# Configuration - .deepsource.toml

# name

name = "sql"

# enabled

enabled = true

# meta

  • Type: Table(opens new window)
  • Presence: optional
  • Description: Analyzer specific metadata to tweak its behavior. These values are used to customize the checkers.
  • Example:
[analyzers.meta]
  max_line_length = 100
  tab_space_size = 4
  indent_unit = "tab"
  comma_style = "trailing"
  capitalisation_policy = "consistent"
  allow_scalar = true
  single_table_references = "consistent"

# Available meta fields

# max_line_length

  • Type: Integer(opens new window)
  • Presence: optional
  • Description: The maximum length of a line to allow without raising a violation
  • Available Value: Any positive integer value.
  • Default Value: 80
  • Example:
[analyzers.meta]
  max_line_length = 100

# tab_space_size

  • Type: Integer(opens new window)
  • Presence: optional
  • Description: The number of spaces to consider equal to one tab.
  • Available Value: Any positive integer value.
  • Default Value: 4
  • Example:
[analyzers.meta]
  tab_space_size = 4

# indent_unit

  • Type: String(opens new window)
  • Presence: optional
  • Description: Whether to use tabs or spaces to add new indents.
  • Available Values: tab and space
  • Default Value: "space"
  • Example:
[analyzers.meta]
  indent_unit = "tab"

# comma_style

  • Type: String(opens new window)
  • Presence: optional
  • Description: The comma style to to enforce.
  • Available Values: trailing and leading
  • Default Value: "trailing"
  • Example:
[analyzers.meta]
  comma_style = "trailing"

# capitalisation_policy

  • Type: String(opens new window)
  • Presence: optional
  • Description: The capitalisation policy to enforce.
  • Available Value: consistent, upper, lower and capitalise.
  • Default Value: "consistent"
  • Example:
[analyzers.meta]
  capitalisation_policy = "consistent"

# allow_scalar

  • Type: Boolean(opens new window)
  • Presence: optional
  • Description: If true then there would be no issues if there is only one element in the SELECT clause e.g. SELECT 1 + 2 FROM blah. It will still fail if there are multiple columns.
  • Available Values: true and false
  • Default Value: true
  • Example:
[analyzers.meta]
  allow_scalar = true

# single_table_references

  • Type: String(opens new window)
  • Presence: optional
  • Description: The expectation for references in single-table SELECT.
  • Available Values: qualified, unqualified and consistent
  • Default Value: "consistent"
  • Example:
[analyzers.meta]
  single_table_references = "consistent"

TIP

The meta options are optional and should be provided only if you want the value to be something other than the default value. If no value is passed for a meta field then the analyzer will automatically consider the default value.

# Sample config

version = 1

[[analyzers]]
name = "sql"
enabled = true

  [analyzers.meta]
    max_line_length = 100
    tab_space_size = 4
    indent_unit = "tab"
    comma_style = "trailing"
    capitalisation_policy = "consistent"
    allow_scalar = true
    single_table_references = "consistent"

Last Updated: 9/29/2020, 7:15:36 AM