# SQL beta
The 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
- Type: String (opens new window)
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
name = "sql"
# enabled
- Type: Boolean (opens new window)
- Presence: mandatory
- Description: Toggle whether this analyzer should be run.
- Example:
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
andspace
- Default Value: "space"
- Example:
[analyzers.meta]
indent_unit = "tab"
# comma_style
- Type: String (opens new window)
- Presence: optional
- Description: The comma style to enforce.
- Available Values:
trailing
andleading
- Default Value: "trailing"
- Example:
[analyzers.meta]
comma_style = "trailing"
# capitalisation_policy
- Type: String (opens new window)
- Presence: optional
- Description: The capitalization policy to enforce.
- Available Value:
consistent
,upper
,lower
andcapitalise
. - 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 theSELECT
clause e.g.SELECT 1 + 2 FROM blah
. It will still fail if there are multiple columns. - Available Values:
true
andfalse
- 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
andconsistent
- 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"