Skip to content

Commit

Permalink
Support Pascal case for L030
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Feb 28, 2022
1 parent a1571ac commit 19f3e8f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/sqlfluff/core/default_config.cfg
Expand Up @@ -114,7 +114,7 @@ ignore_words = None

[sqlfluff:rules:L030]
# Function names
capitalisation_policy = consistent
extended_capitalisation_policy = consistent
# Comma separated list of words to ignore for this rule
ignore_words = None

Expand Down
4 changes: 4 additions & 0 deletions src/sqlfluff/rules/L030.py
Expand Up @@ -42,6 +42,10 @@ class Rule_L030(Rule_L010):
("type", "function_name_identifier"),
("type", "bare_function"),
]
config_keywords = [
"extended_capitalisation_policy",
"ignore_words",
]
_description_elem = "Function names"

def _get_fix(self, segment, fixed_raw):
Expand Down
24 changes: 12 additions & 12 deletions test/fixtures/rules/std_rule_cases/L030.yml
Expand Up @@ -3,38 +3,39 @@ rule: L030
# Inconsistent capitalisation of functions
test_fail_inconsistent_function_capitalisation_1:
fail_str: SELECT MAX(id), min(id) from table

fix_str: SELECT MAX(id), MIN(id) from table

test_fail_inconsistent_function_capitalisation_2:
fail_str: SELECT MAX(id), min(id) from table

fix_str: SELECT max(id), min(id) from table

configs:
rules:
L030:
capitalisation_policy: lower
extended_capitalisation_policy: lower

test_bare_functions:
fail_str: SELECT current_timestamp from table

fix_str: SELECT CURRENT_TIMESTAMP from table

configs:
rules:
L030:
capitalisation_policy: upper
extended_capitalisation_policy: upper

test_bare_functions_2:
fail_str: SELECT current_timestamp, min(a) from table

fix_str: SELECT CURRENT_TIMESTAMP, MIN(a) from table
configs:
rules:
L030:
extended_capitalisation_policy: upper

test_bare_functions_3:
fail_str: SELECT current_timestamp, min(a) from table
fix_str: SELECT Current_Timestamp, Min(a) from table
configs:
rules:
L030:
capitalisation_policy: upper
extended_capitalisation_policy: pascal

test_fail_capitalization_after_comma:
fail_str: SELECT FLOOR(dt) ,count(*) FROM test
Expand All @@ -44,9 +45,8 @@ test_fail_fully_qualified_function_mixed_functions:
fail_str: SELECT COUNT(*), project1.foo(value1) AS value2
fix_str: SELECT COUNT(*), project1.FOO(value1) AS value2

test_fail_fully_qualified_function_mixed_case:
fail_str: SELECT project1.FoO(value1) AS value2
fix_str: SELECT project1.FOO(value1) AS value2
test_pass_fully_qualified_function_pascal_case:
pass_str: SELECT project1.FoO(value1) AS value2

test_pass_ignore_word:
pass_str: SELECT MAX(id), min(id) FROM TABLE1
Expand Down

0 comments on commit 19f3e8f

Please sign in to comment.