Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L027: Remove unnessary crawl in get_select_statement_info #1974

Merged
merged 2 commits into from Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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