forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LT03.yml
263 lines (243 loc) · 4.44 KB
/
LT03.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
rule: LT03
passes_on_before_default:
pass_str: |
select
a
+ b
from foo
fails_on_after_default:
fail_str: |
select
a +
b
from foo
fix_str: |
select
a
+ b
from foo
fails_on_after_default_on_and:
fail_str: |
select
a AND
b
from foo
fix_str: |
select
a
AND b
from foo
fails_on_after_with_comment_order_preserved:
fail_str: |
select
a AND
-- comment1!
-- comment2!
b
from foo
fix_str: |
select
a
-- comment1!
-- comment2!
AND b
from foo
passes_on_before_explicit:
pass_str: |
select
a
+ b
from foo
configs: &operator_after
layout:
type:
binary_operator:
line_position: leading
comparison_operator:
line_position: leading
fails_on_after_explicit:
fail_str: |
select
a +
b
from foo
fix_str: |
select
a
+ b
from foo
configs: *operator_after
fails_on_after_multi_explicit:
fail_str: |
SELECT
*
FROM
foo
WHERE
(g > z) AND
(
(a = 'a' AND b = 'b') OR
(a = 'a' AND b = 'e') OR
(a = 'c' AND b = 'g') OR
(a = 'c' AND b = 'e') OR
1 = 1
);
fix_str: |
SELECT
*
FROM
foo
WHERE
(g > z)
AND (
(a = 'a' AND b = 'b')
OR (a = 'a' AND b = 'e')
OR (a = 'c' AND b = 'g')
OR (a = 'c' AND b = 'e')
OR 1 = 1
);
configs: *operator_after
fails_on_before_override:
fail_str: |
select
a
+ b
from foo
fix_str: |
select
a +
b
from foo
configs: &operator_before
layout:
type:
binary_operator:
line_position: trailing
comparison_operator:
line_position: trailing
passes_on_after_override:
pass_str: |
select
a +
b
from foo
configs: *operator_before
fails_on_before_override_with_comment_order:
fail_str: |
select
a -- comment1!
-- comment2!
-- comment3!
+ b
from foo
fix_str: |
select
a + -- comment1!
-- comment2!
-- comment3!
b
from foo
configs: *operator_before
fails_on_after_override_with_comment_order:
fail_str: |
select
a + -- comment1!
-- comment2!
-- comment3!
b
from foo
fix_str: |
select
a -- comment1!
-- comment2!
-- comment3!
+ b
from foo
configs: *operator_after
# Fix the different variations of problematic comments in a leading case.
fails_leading_with_comments:
fail_str: |
SELECT
1 +
/* foo */ 2,
1 + -- foo
2,
1 /* foo */ +
2,
1 /* foo */ + -- foo
/* foo */ 2
fix_str: |
SELECT
1
/* foo */ + 2,
1 -- foo
+ 2,
1 /* foo */
+ 2,
1 /* foo */ -- foo
/* foo */ + 2
configs: *operator_after
# Fix the different variations of problematic comments in a trailing case.
fails_trailing_with_comments:
fail_str: |
SELECT
1
+ /* foo */ 2,
1 -- foo
+ 2,
1
/* foo */ + 2,
1 -- foo
/* foo */ + /* foo */ 2
fix_str: |
SELECT
1 +
/* foo */ 2,
1 + -- foo
2,
1 +
/* foo */ 2,
1 + -- foo
/* foo */ /* foo */ 2
configs: *operator_before
passes_templated_newline:
pass_str: |
{% macro binary_literal(expression) %}
X'{{ expression }}'
{% endmacro %}
select
*
from my_table
where
a = {{ binary_literal("0000") }}
fails_templated_code_non_templated_newline:
fail_str: |
{% macro binary_literal(expression) %}
X'{{ expression }}'
{% endmacro %}
select
*
from my_table
where
a =
{{ binary_literal("0000") }}
passes_operator_alone_on_line:
# Special case: An operator on a line by itself is always okay.
pass_str: |
SELECT
'asdf'
||
'jklm'
fixes_tuple_error_issue:
# https://github.com/sqlfluff/sqlfluff/issues/4184
# NB: This one isn't fixable.
fail_str: |
select * from foo
where c is not null and -- comment
{% if true -%}a >= b and
-- comment.
{% endif %}
true
configs:
indentation:
template_blocks_indent: false