Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Co-authored-by: Barry Hart <[email protected]>
  • Loading branch information
alanmcruickshank and barrywhart authored Jan 16, 2023
1 parent 6f7f454 commit c24a636
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sqlfluff/core/default_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ spacing_within = inline
spacing_before = any
spacing_after = any

[sqlfluff:layout:type:placeholder]
# Placeholders exist "outside" the rendered SQL syntax
# so we shouldn't enforce any particular spacing around
# them.
spacing_before = any
spacing_after = any

# By setting a selection of clauses to "alone", we hint to the reflow
# algorithm that in the case of a long single line statement, the
# first place to add newlines would be around these clauses.
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/rules/std_rule_cases/L006.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,21 @@ pass_tsql_assignment_operator:

pass_concat_string:
pass_str: SELECT 'barry' || 'pollard'

test_pass_placeholder_spacing:
# Test for spacing issues around placeholders
# https://github.com/sqlfluff/sqlfluff/issues/4253
pass_str: |
{% set is_dev_environment = true %}
SELECT *
FROM table
WHERE
some_col IS TRUE
{% if is_dev_environment %}
AND created_at >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)
{% else %}
AND created_at >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)
{% endif %}
AND TRUE
;

0 comments on commit c24a636

Please sign in to comment.