SQL
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
.deepsource.toml
name
name
- Type: String
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
name = "sql"
enabled
enabled
- Type: Boolean
- Presence: optional
- Description: Toggle whether this analyzer should be run.
- Example:
enabled = true
meta
meta
- Type: Table
- 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
meta
fieldsmax_line_length
max_line_length
- Type: Integer
- 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
tab_space_size
- Type: Integer
- 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
indent_unit
- Type: String
- 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
comma_style
- Type: String
- Presence: optional
- Description: The comma style to enforce.
- Available Values:
trailing
andleading
- Default Value: "trailing"
- Example:
[analyzers.meta]
comma_style = "trailing"
capitalisation_policy
capitalisation_policy
- Type: String
- 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
allow_scalar
- Type: Boolean
- 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
single_table_references
- Type: String
- 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"
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, 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"
Updated over 1 year ago