Skip to content

Commit

Permalink
Remove unnessary crawl in get_select_statement_info (#1974)
Browse files Browse the repository at this point in the history
Co-authored-by: Danny Jones <51742311+WittierDinosaur@users.noreply.github.com>
  • Loading branch information
jpy-git and WittierDinosaur committed Nov 25, 2021
1 parent 1cb0be5 commit 3bca62f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/sqlfluff/core/rules/analysis/select.py
Expand Up @@ -31,8 +31,6 @@ def get_select_statement_info(
# potential others.
sc = segment.get_child("select_clause")
reference_buffer = list(sc.recursive_crawl("object_reference"))
# Add any wildcard references
reference_buffer += list(sc.recursive_crawl("wildcard_identifier"))
for potential_clause in (
"where_clause",
"groupby_clause",
Expand Down
4 changes: 2 additions & 2 deletions src/sqlfluff/rules/L027.py
@@ -1,10 +1,10 @@
"""Implementation of Rule L027."""

from sqlfluff.core.rules.base import LintResult
from sqlfluff.rules.L025 import Rule_L025
from sqlfluff.rules.L020 import Rule_L020


class Rule_L027(Rule_L025):
class Rule_L027(Rule_L020):
"""References should be qualified if select has more than one referenced table/view.
NB: Except if they're present in a USING clause.
Expand Down
15 changes: 15 additions & 0 deletions test/rules/std_L027_test.py
@@ -0,0 +1,15 @@
"""Tests the python routines within L027."""

import sqlfluff


def test__rules__std_L027_wildcard_single_count():
"""Verify that L027 is only raised once for wildcard (see issue #1973)."""
sql = """
SELECT *
FROM foo
INNER JOIN bar;
"""
result = sqlfluff.lint(sql)
assert "L027" in [r["code"] for r in result]
assert [r["code"] for r in result].count("L027") == 1

0 comments on commit 3bca62f

Please sign in to comment.