File: std_LT05_LT09_combo_test.py

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (44 lines) | stat: -rw-r--r-- 1,514 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Tests the combination of LT05 and LT09.

LT05: no long lines
LT09: single selects should be on SELECT line
"""

import sqlfluff


def test__rules__std_LT05_LT09_long_line_lint():
    """Verify a long line that causes a clash between LT05 and LT09 is not changed."""
    sql = (
        "SELECT\n1000000000000000000000000000000000000000000000000000000000000000000000"
        "000000000000000000000000000000\n"
    )
    result = sqlfluff.lint(sql)
    assert "LT05" in [r["code"] for r in result]
    assert "LT09" in [r["code"] for r in result]


def test__rules__std_LT05_LT09_long_line_fix():
    """Verify clash between LT05 & LT09 does not add multiple newlines (see #1424)."""
    sql = (
        "SELECT 10000000000000000000000000000000000000000000000000000000000000000000000"
        "00000000000000000000000000000\n"
    )
    result = sqlfluff.fix(sql)
    assert result == (
        "SELECT\n    100000000000000000000000000000000000000000000000000000000000000000"
        "0000000000000000000000000000000000\n"
    )


def test__rules__std_LT05_LT09_long_line_fix2():
    """Verify clash between LT05 & LT09 does not add multiple newlines (see #1424)."""
    sql = (
        "SELECT\n    100000000000000000000000000000000000000000000000000000000000000000"
        "0000000000000000000000000000000000\n"
    )
    result = sqlfluff.fix(sql)
    assert result == (
        "SELECT 10000000000000000000000000000000000000000000000000000000000000000000000"
        "00000000000000000000000000000\n"
    )