File: std_RF01_LT09_test.py

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (28 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Tests observed conflict between RF01 & LT09.

Root cause was BaseSegment.copy().
"""

from sqlfluff.core import FluffConfig, Linter


def test__rules__std_RF01_LT09_copy() -> None:
    """Tests observed conflict between RF01 & LT09.

    https://github.com/sqlfluff/sqlfluff/issues/5203
    """
    sql = """
SELECT
    DISTINCT `FIELD`
FROM `TABLE`;
"""
    cfg = FluffConfig.from_kwargs(
        dialect="mysql",
        rules=["RF01", "LT09"],
    )
    result = Linter(config=cfg).lint_string(sql)
    for violation in result.violations:
        assert "Unexpected exception" not in violation.description
    assert len(result.violations) == 1
    only_violation = result.violations[0]
    assert only_violation.rule_code() == "LT09"