kaqing 2.0.55__py3-none-any.whl → 2.0.57__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- adam/sql/sql_completer.py +394 -228
- adam/sql/term_completer.py +10 -3
- adam/version.py +1 -1
- {kaqing-2.0.55.dist-info → kaqing-2.0.57.dist-info}/METADATA +1 -1
- {kaqing-2.0.55.dist-info → kaqing-2.0.57.dist-info}/RECORD +8 -9
- adam/sql/sql_utils.py +0 -5
- {kaqing-2.0.55.dist-info → kaqing-2.0.57.dist-info}/WHEEL +0 -0
- {kaqing-2.0.55.dist-info → kaqing-2.0.57.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.55.dist-info → kaqing-2.0.57.dist-info}/top_level.txt +0 -0
adam/sql/sql_completer.py
CHANGED
@@ -7,7 +7,131 @@ from sqlparse import tokens as T
|
|
7
7
|
|
8
8
|
from adam.sql.term_completer import TermCompleter
|
9
9
|
|
10
|
+
columns = TermCompleter(['id', 'x.', 'y.', 'z.'])
|
11
|
+
|
10
12
|
class SqlCompleter(Completer):
|
13
|
+
# <select_statement> ::= SELECT <select_list>
|
14
|
+
# FROM <table_expression>
|
15
|
+
# [WHERE <search_condition>]
|
16
|
+
# [<group_by_clause>]
|
17
|
+
# [<having_clause>]
|
18
|
+
# [<order_by_clause>]
|
19
|
+
# [<limit_clause>]
|
20
|
+
|
21
|
+
# <search_condition> ::= <boolean_term>
|
22
|
+
# | <search_condition> OR <boolean_term>
|
23
|
+
|
24
|
+
# <boolean_term> ::= <boolean_factor>
|
25
|
+
# | <boolean_term> AND <boolean_factor>
|
26
|
+
|
27
|
+
# <boolean_factor> ::= [NOT] <predicate>
|
28
|
+
# | ([NOT] <search_condition>)
|
29
|
+
|
30
|
+
# <predicate> ::= <comparison_predicate>
|
31
|
+
# | <between_predicate>
|
32
|
+
# | <in_predicate>
|
33
|
+
# | <like_predicate>
|
34
|
+
# | <null_predicate>
|
35
|
+
# | <exists_predicate>
|
36
|
+
# | <quantified_predicate>
|
37
|
+
# | <unique_predicate>
|
38
|
+
# | <match_predicate>
|
39
|
+
# | <overlaps_predicate>
|
40
|
+
# | <distinct_predicate>
|
41
|
+
# | <member_predicate>
|
42
|
+
# | <submultiset_predicate>
|
43
|
+
# | <set_predicate>
|
44
|
+
|
45
|
+
# <comparison_predicate> ::= <row_value_expression> <comparison_operator> <row_value_expression>
|
46
|
+
# <comparison_operator> ::= '=' | '<>' | '<' | '<=' | '>' | '>='
|
47
|
+
|
48
|
+
# <row_value_expression> ::= <value_expression>
|
49
|
+
# | (<value_expression> [ { <comma> <value_expression> }... ])
|
50
|
+
|
51
|
+
# <value_expression> ::= <numeric_value_expression>
|
52
|
+
# | <string_value_expression>
|
53
|
+
# | <datetime_value_expression>
|
54
|
+
# | <interval_value_expression>
|
55
|
+
# | <boolean_value_expression>
|
56
|
+
# | <user_defined_type_value_expression>
|
57
|
+
# | <reference_value_expression>
|
58
|
+
# | <collection_value_expression>
|
59
|
+
# | <row_value_constructor>
|
60
|
+
# | <case_expression>
|
61
|
+
# | <cast_expression>
|
62
|
+
# | <subquery>
|
63
|
+
# | NULL
|
64
|
+
# | DEFAULT
|
65
|
+
# | <identifier>
|
66
|
+
# | <literal>
|
67
|
+
|
68
|
+
# <insert_statement> ::= INSERT INTO <table_name> [ ( <column_list> ) ]
|
69
|
+
# VALUES ( <value_list> )
|
70
|
+
# | INSERT INTO <table_name> [ ( <column_list> ) ]
|
71
|
+
# <query_expression>
|
72
|
+
|
73
|
+
# <table_name> ::= <identifier>
|
74
|
+
|
75
|
+
# <column_list> ::= <column_name> [ , <column_list> ]
|
76
|
+
|
77
|
+
# <column_name> ::= <identifier>
|
78
|
+
|
79
|
+
# <value_list> ::= <expression> [ , <value_list> ]
|
80
|
+
|
81
|
+
# <query_expression> ::= SELECT <select_list> FROM <table_reference_list> [ WHERE <search_condition> ] [ GROUP BY <grouping_column_list> ] [ HAVING <search_condition> ] [ ORDER BY <sort_specification_list> ]
|
82
|
+
|
83
|
+
# <update_statement> ::= UPDATE <table_name>
|
84
|
+
# SET <set_clause_list>
|
85
|
+
# [WHERE <search_condition>]
|
86
|
+
|
87
|
+
# <set_clause_list> ::= <set_clause> { , <set_clause> }
|
88
|
+
|
89
|
+
# <set_clause> ::= <column_name> = <update_value>
|
90
|
+
|
91
|
+
# <update_value> ::= <expression> | NULL | DEFAULT
|
92
|
+
|
93
|
+
# <search_condition> ::= <boolean_expression>
|
94
|
+
|
95
|
+
# <delete_statement> ::= DELETE FROM <table_name> [ WHERE <search_condition> ]
|
96
|
+
|
97
|
+
# <table_name> ::= <identifier>
|
98
|
+
|
99
|
+
# <search_condition> ::= <boolean_expression>
|
100
|
+
|
101
|
+
# <boolean_expression> ::= <predicate>
|
102
|
+
# | <boolean_expression> AND <predicate>
|
103
|
+
# | <boolean_expression> OR <predicate>
|
104
|
+
# | NOT <predicate>
|
105
|
+
# | ( <boolean_expression> )
|
106
|
+
|
107
|
+
# <predicate> ::= <expression> <comparison_operator> <expression>
|
108
|
+
# | <expression> IS NULL
|
109
|
+
# | <expression> IS NOT NULL
|
110
|
+
# | <expression> LIKE <pattern> [ ESCAPE <escape_character> ]
|
111
|
+
# | <expression> IN ( <expression_list> )
|
112
|
+
# | EXISTS ( <select_statement> )
|
113
|
+
# | ... (other predicates)
|
114
|
+
|
115
|
+
# <comparison_operator> ::= = | <> | != | > | < | >= | <=
|
116
|
+
|
117
|
+
# <expression> ::= <literal>
|
118
|
+
# | <column_name>
|
119
|
+
# | <function_call>
|
120
|
+
# | ( <expression> )
|
121
|
+
# | <expression> <arithmetic_operator> <expression>
|
122
|
+
# | ... (other expressions)
|
123
|
+
|
124
|
+
# <literal> ::= <numeric_literal> | <string_literal> | <boolean_literal> | <date_literal> | ...
|
125
|
+
|
126
|
+
# <column_name> ::= <identifier>
|
127
|
+
|
128
|
+
# <identifier> ::= <letter> { <letter> | <digit> | _ }...
|
129
|
+
|
130
|
+
# <pattern> ::= <string_literal>
|
131
|
+
|
132
|
+
# <escape_character> ::= <string_literal> (single character)
|
133
|
+
|
134
|
+
# <expression_list> ::= <expression> { , <expression> }...
|
11
135
|
def __init__(self, tables: Callable[[], list[str]], dml: str = None, debug = False):
|
12
136
|
super().__init__()
|
13
137
|
self.dml = dml
|
@@ -42,59 +166,67 @@ class SqlCompleter(Completer):
|
|
42
166
|
completer = TermCompleter(['*'])
|
43
167
|
elif state == 'select_a_':
|
44
168
|
completer = TermCompleter(['from'])
|
45
|
-
elif state == "
|
169
|
+
elif state == "select_from_":
|
46
170
|
completer = TermCompleter(self.tables())
|
47
|
-
elif state == "
|
171
|
+
elif state == "select_from_x_":
|
172
|
+
completer = TermCompleter(['as', 'where', 'inner', 'left', 'right', 'full', 'group', 'limit'])
|
173
|
+
elif state == "select_from_x_as_x_":
|
48
174
|
completer = TermCompleter(['where', 'inner', 'left', 'right', 'full', 'group', 'limit'])
|
49
|
-
elif state == "
|
175
|
+
elif state == "select_from_x,":
|
176
|
+
completer = TermCompleter(self.tables())
|
177
|
+
elif state == "select_from_x_as_":
|
178
|
+
completer = TermCompleter(['x', 'y', 'z'])
|
179
|
+
elif state == "select_from_x_as_x,":
|
50
180
|
completer = TermCompleter(self.tables())
|
51
|
-
elif state == "
|
52
|
-
completer =
|
53
|
-
elif state
|
54
|
-
completer = TermCompleter(['=', '<', '<=', '>', '>=', '<>', 'like'])
|
55
|
-
elif state == "
|
181
|
+
elif state == "select_where_":
|
182
|
+
completer = columns
|
183
|
+
elif state in ["select_where_a", "select_where_a_"]:
|
184
|
+
completer = TermCompleter(['=', '<', '<=', '>', '>=', '<>', 'like', 'not'])
|
185
|
+
elif state == "select_where_a_not_":
|
186
|
+
completer = TermCompleter(['like', 'in'])
|
187
|
+
elif state == "select_where_a_op":
|
56
188
|
completer = TermCompleter(["'"])
|
57
|
-
elif state == "
|
189
|
+
elif state == "select_where_sc_":
|
58
190
|
completer = TermCompleter(['and', 'or', 'group', 'limit'])
|
59
|
-
elif state == "
|
191
|
+
elif state == "select_where_sc_limit_":
|
60
192
|
completer = TermCompleter(['1'])
|
61
|
-
elif state == "
|
193
|
+
elif state == "select_from_x_group_":
|
62
194
|
completer = TermCompleter(['by'])
|
63
|
-
elif state == "
|
64
|
-
completer =
|
65
|
-
elif state == "
|
66
|
-
completer =
|
67
|
-
elif state == "
|
195
|
+
elif state == "select_from_x_group_by_":
|
196
|
+
completer = columns
|
197
|
+
elif state == "select_from_x_group_by_a,":
|
198
|
+
completer = columns
|
199
|
+
elif state == "select_from_x_group_by_a_":
|
68
200
|
completer = TermCompleter(['limit'])
|
69
|
-
elif state == "
|
201
|
+
elif state == "select_from_x_group_by_a_limit_":
|
70
202
|
completer = TermCompleter(['1'])
|
71
|
-
elif state == "
|
203
|
+
elif state == "select_from_x_inner_":
|
72
204
|
completer = TermCompleter(['join'])
|
73
|
-
elif state in ["
|
205
|
+
elif state in ["select_join_", "select_from_x_left_join_"]:
|
74
206
|
completer = TermCompleter(self.tables())
|
75
|
-
elif state == "
|
207
|
+
elif state == "select_x_join_y,":
|
76
208
|
completer = TermCompleter(self.tables())
|
77
|
-
elif state == "
|
209
|
+
elif state == "select_x_join_y_":
|
78
210
|
completer = TermCompleter(['on'])
|
79
|
-
elif state == "
|
80
|
-
completer =
|
81
|
-
elif state == "
|
211
|
+
elif state == "select_x_join_y_on_":
|
212
|
+
completer = columns
|
213
|
+
elif state == "select_x_join_y_on_a":
|
82
214
|
completer = TermCompleter(['='])
|
83
|
-
elif state == "
|
84
|
-
completer =
|
85
|
-
elif state == "
|
215
|
+
elif state == "select_x_join_y_on_a_op":
|
216
|
+
completer = columns
|
217
|
+
elif state == "select_x_join_y_on_a_opb_":
|
86
218
|
completer = TermCompleter(['where', 'group', 'limit'])
|
87
|
-
elif state == "
|
219
|
+
elif state == "select_from_x_left_":
|
88
220
|
completer = TermCompleter(['outer', 'join'])
|
89
|
-
elif state == "
|
221
|
+
elif state == "select_from_x_left_outer_":
|
90
222
|
completer = TermCompleter(['join'])
|
91
|
-
elif state == "
|
223
|
+
elif state == "select_from_x_right_":
|
92
224
|
completer = TermCompleter(['outer', 'join'])
|
93
|
-
elif state == "
|
225
|
+
elif state == "select_from_x_right_outer_":
|
94
226
|
completer = TermCompleter(['join'])
|
95
|
-
elif state == "
|
227
|
+
elif state == "select_from_x_full_":
|
96
228
|
completer = TermCompleter(['outer'])
|
97
|
-
elif state == "
|
229
|
+
elif state == "select_from_x_full_outer_":
|
98
230
|
completer = TermCompleter(['join'])
|
99
231
|
|
100
232
|
elif state == "insert_":
|
@@ -102,35 +234,35 @@ class SqlCompleter(Completer):
|
|
102
234
|
elif state == "insert_into_":
|
103
235
|
completer = TermCompleter(self.tables())
|
104
236
|
elif state == "insert_into_x_":
|
105
|
-
completer = TermCompleter(['values'])
|
106
|
-
elif state == "
|
107
|
-
completer =
|
108
|
-
elif state == "
|
109
|
-
completer =
|
110
|
-
elif state == "
|
111
|
-
completer = TermCompleter(['values('])
|
112
|
-
elif state == "
|
237
|
+
completer = TermCompleter(['values(', 'select'])
|
238
|
+
elif state == "insert_into_x_lp_":
|
239
|
+
completer = columns
|
240
|
+
elif state == "insert_into_x_lp_a,":
|
241
|
+
completer = columns
|
242
|
+
elif state == "insert_into_x_lp_a_rp_":
|
243
|
+
completer = TermCompleter(['values(', 'select'])
|
244
|
+
elif state == "insert_values":
|
113
245
|
completer = TermCompleter(['('])
|
114
|
-
elif state == "
|
246
|
+
elif state == "insert_values_lp_":
|
115
247
|
completer = TermCompleter(["'"])
|
116
248
|
|
117
249
|
elif state == "update_":
|
118
250
|
completer = TermCompleter(self.tables())
|
119
251
|
elif state == "update_x_":
|
120
252
|
completer = TermCompleter(['set'])
|
121
|
-
elif state in ["update_x_set_", "
|
122
|
-
completer =
|
253
|
+
elif state in ["update_x_set_", "update_x_set_sc,"]:
|
254
|
+
completer = columns
|
123
255
|
elif state == "update_x_set_a":
|
124
256
|
completer = TermCompleter(['='])
|
125
|
-
elif state == "
|
257
|
+
elif state == "update_x_set_a_op":
|
126
258
|
completer = TermCompleter(["'"])
|
127
|
-
elif state == "
|
259
|
+
elif state == "update_x_set_sc_":
|
128
260
|
completer = TermCompleter(['where'])
|
129
|
-
elif state == "
|
130
|
-
completer =
|
131
|
-
elif state == "
|
261
|
+
elif state == "update_where_":
|
262
|
+
completer = columns
|
263
|
+
elif state == "update_where_a":
|
132
264
|
completer = TermCompleter(['='])
|
133
|
-
elif state == "
|
265
|
+
elif state == "update_where_sc_":
|
134
266
|
completer = TermCompleter(['and', 'or'])
|
135
267
|
|
136
268
|
elif state == "delete_":
|
@@ -139,13 +271,13 @@ class SqlCompleter(Completer):
|
|
139
271
|
completer = TermCompleter(self.tables())
|
140
272
|
elif state == "delete_from_x_":
|
141
273
|
completer = TermCompleter(['where'])
|
142
|
-
elif state == "
|
143
|
-
completer =
|
144
|
-
elif state == "
|
274
|
+
elif state == "delete_where_":
|
275
|
+
completer = columns
|
276
|
+
elif state == "delete_where_a":
|
145
277
|
completer = TermCompleter(['='])
|
146
|
-
elif state == "
|
278
|
+
elif state == "delete_where_a_op":
|
147
279
|
completer = TermCompleter(["'"])
|
148
|
-
elif state == "
|
280
|
+
elif state == "delete_where_sc_":
|
149
281
|
completer = TermCompleter(['and', 'or'])
|
150
282
|
|
151
283
|
if completer:
|
@@ -200,191 +332,225 @@ class SqlCompleter(Completer):
|
|
200
332
|
state = 'select_a'
|
201
333
|
elif state == 'select_a_':
|
202
334
|
if token.ttype == T.Keyword and token.value.lower() == 'from':
|
203
|
-
state = '
|
204
|
-
elif state == '
|
335
|
+
state = 'select_from'
|
336
|
+
elif state == 'select_from':
|
205
337
|
if token.ttype == T.Text.Whitespace:
|
206
|
-
state = '
|
207
|
-
elif state == '
|
338
|
+
state = 'select_from_'
|
339
|
+
elif state == 'select_from_':
|
208
340
|
if token.ttype == T.Name:
|
209
|
-
state = '
|
210
|
-
elif state == '
|
341
|
+
state = 'select_from_x'
|
342
|
+
elif state == 'select_from_x':
|
211
343
|
if token.ttype == T.Text.Whitespace:
|
212
|
-
state = '
|
344
|
+
state = 'select_from_x_'
|
213
345
|
elif token.ttype == T.Punctuation and token.value == ',':
|
214
|
-
state = '
|
215
|
-
elif state == '
|
346
|
+
state = 'select_from_x,'
|
347
|
+
elif state == 'select_from_x,':
|
216
348
|
if token.ttype == T.Name:
|
217
|
-
state = '
|
218
|
-
elif state
|
219
|
-
if token.ttype == T.
|
220
|
-
state = '
|
349
|
+
state = 'select_from_x'
|
350
|
+
elif state in ['select_from_x_', 'select_from_x_as_x_']:
|
351
|
+
if token.ttype == T.Punctuation and token.value == ',':
|
352
|
+
state = 'select_from_x,'
|
353
|
+
elif token.ttype == T.Keyword and token.value.lower() == 'as':
|
354
|
+
state = 'select_from_x_as'
|
355
|
+
elif token.ttype == T.Keyword and token.value.lower() == 'where':
|
356
|
+
state = 'select_where'
|
221
357
|
elif token.ttype == T.Keyword and token.value.lower() == 'limit':
|
222
|
-
state = '
|
358
|
+
state = 'select_where_sc_limit'
|
223
359
|
elif token.ttype == T.Keyword and token.value.lower() == 'group':
|
224
|
-
state = '
|
360
|
+
state = 'select_from_x_group'
|
225
361
|
elif token.ttype == T.Keyword and token.value.lower() == 'group by':
|
226
|
-
state = '
|
362
|
+
state = 'select_from_x_group_by'
|
227
363
|
elif token.ttype == T.Keyword and token.value.lower() == 'inner':
|
228
|
-
state = '
|
364
|
+
state = 'select_from_x_inner'
|
229
365
|
elif token.ttype == T.Keyword and token.value.lower() == 'inner join':
|
230
|
-
state = '
|
366
|
+
state = 'select_join'
|
231
367
|
elif token.ttype == T.Keyword and token.value.lower() == 'left':
|
232
|
-
state = '
|
368
|
+
state = 'select_from_x_left'
|
233
369
|
elif token.ttype == T.Keyword and token.value.lower() in ['left join', 'left outer join']:
|
234
|
-
state = '
|
370
|
+
state = 'select_join'
|
235
371
|
elif token.ttype == T.Keyword and token.value.lower() == 'right':
|
236
|
-
state = '
|
372
|
+
state = 'select_from_x_right'
|
237
373
|
elif token.ttype == T.Keyword and token.value.lower() in ['right join', 'right outer join']:
|
238
|
-
state = '
|
374
|
+
state = 'select_join'
|
239
375
|
elif token.ttype == T.Keyword and token.value.lower() == 'full':
|
240
|
-
state = '
|
376
|
+
state = 'select_from_x_full'
|
241
377
|
elif token.ttype == T.Keyword and token.value.lower() == 'full outer join':
|
242
|
-
state = '
|
243
|
-
elif state == '
|
378
|
+
state = 'select_join'
|
379
|
+
elif state == 'select_from_x_as':
|
244
380
|
if token.ttype == T.Text.Whitespace:
|
245
|
-
state = '
|
246
|
-
elif state == '
|
381
|
+
state = 'select_from_x_as_'
|
382
|
+
elif state == 'select_from_x_as_':
|
247
383
|
if token.ttype == T.Name:
|
248
|
-
state = '
|
249
|
-
elif state == '
|
384
|
+
state = 'select_from_x_as_x'
|
385
|
+
elif state == 'select_from_x_as_x':
|
386
|
+
if token.ttype == T.Text.Whitespace:
|
387
|
+
state = 'select_from_x_as_x_'
|
388
|
+
elif token.ttype == T.Punctuation and token.value == ',':
|
389
|
+
state = 'select_from_x_as_x,'
|
390
|
+
elif state == 'select_from_x_as_x,':
|
391
|
+
if token.ttype == T.Name:
|
392
|
+
state = 'select_from_x'
|
393
|
+
elif state == 'select_where':
|
394
|
+
if token.ttype == T.Text.Whitespace:
|
395
|
+
state = 'select_where_'
|
396
|
+
elif state == 'select_where_':
|
397
|
+
if token.ttype == T.Name:
|
398
|
+
state = 'select_where_a'
|
399
|
+
elif state == 'select_where_a':
|
400
|
+
if token.ttype == T.Text.Whitespace:
|
401
|
+
state = 'select_where_a_'
|
402
|
+
elif token.ttype == T.Operator.Comparison:
|
403
|
+
state = 'select_where_a_op'
|
404
|
+
elif state == 'select_where_a_':
|
250
405
|
if token.ttype == T.Operator.Comparison:
|
251
|
-
state = '
|
252
|
-
|
406
|
+
state = 'select_where_a_op'
|
407
|
+
elif token.ttype == T.Keyword and token.value.lower() == 'not':
|
408
|
+
state = 'select_where_a_not'
|
409
|
+
elif state == 'select_where_a_not':
|
410
|
+
if token.ttype == T.Text.Whitespace:
|
411
|
+
state = 'select_where_a_not_'
|
412
|
+
elif state == 'select_where_a_not_':
|
413
|
+
if token.ttype == T.Operator.Comparison:
|
414
|
+
state = 'select_where_a_not_op'
|
415
|
+
elif state == 'select_where_a_not_op':
|
416
|
+
if token.ttype in [T.Literal.String.Single, T.Name]:
|
417
|
+
state = 'select_where_sc'
|
418
|
+
elif state == 'select_where_a_op':
|
253
419
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
254
|
-
state = '
|
255
|
-
elif state == '
|
420
|
+
state = 'select_where_sc'
|
421
|
+
elif state == 'select_where_sc':
|
256
422
|
if token.ttype == T.Text.Whitespace:
|
257
|
-
state = '
|
258
|
-
elif state == '
|
423
|
+
state = 'select_where_sc_'
|
424
|
+
elif state == 'select_where_sc_':
|
259
425
|
if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
|
260
|
-
state = '
|
426
|
+
state = 'select_where'
|
261
427
|
elif token.ttype == T.Keyword and token.value.lower() == 'group':
|
262
|
-
state = '
|
428
|
+
state = 'select_from_x_group'
|
263
429
|
elif token.ttype == T.Keyword and token.value.lower() == 'group by':
|
264
|
-
state = '
|
430
|
+
state = 'select_from_x_group_by'
|
265
431
|
elif token.ttype == T.Keyword and token.value.lower() == 'limit':
|
266
|
-
state = '
|
267
|
-
elif state == '
|
432
|
+
state = 'select_where_sc_limit'
|
433
|
+
elif state == 'select_from_x_group':
|
268
434
|
if token.ttype == T.Text.Whitespace:
|
269
|
-
state = '
|
270
|
-
elif state == '
|
435
|
+
state = 'select_from_x_group_'
|
436
|
+
elif state == 'select_from_x_group_':
|
271
437
|
if token.ttype == T.Keyword and token.value.lower() == 'by':
|
272
|
-
state = '
|
273
|
-
elif state == '
|
438
|
+
state = 'select_from_x_group_by'
|
439
|
+
elif state == 'select_from_x_group_by':
|
274
440
|
if token.ttype == T.Text.Whitespace:
|
275
|
-
state = '
|
276
|
-
elif state == '
|
441
|
+
state = 'select_from_x_group_by_'
|
442
|
+
elif state == 'select_from_x_group_by_':
|
277
443
|
if token.ttype == T.Name:
|
278
|
-
state = '
|
279
|
-
elif state == '
|
444
|
+
state = 'select_from_x_group_by_a'
|
445
|
+
elif state == 'select_from_x_group_by_a':
|
280
446
|
if token.ttype == T.Text.Whitespace:
|
281
|
-
state = '
|
447
|
+
state = 'select_from_x_group_by_a_'
|
282
448
|
elif token.ttype == T.Punctuation and token.value == ',':
|
283
|
-
state = '
|
284
|
-
elif state == '
|
449
|
+
state = 'select_from_x_group_by_a,'
|
450
|
+
elif state == 'select_from_x_group_by_a,':
|
285
451
|
if token.ttype == T.Name:
|
286
|
-
state = '
|
287
|
-
elif state == '
|
452
|
+
state = 'select_from_x_group_by_a'
|
453
|
+
elif state == 'select_from_x_group_by_a_':
|
288
454
|
if token.ttype == T.Keyword and token.value.lower() == 'limit':
|
289
|
-
state = '
|
290
|
-
elif state == '
|
455
|
+
state = 'select_where_sc_limit'
|
456
|
+
elif state == 'select_where_sc_limit':
|
291
457
|
if token.ttype == T.Text.Whitespace:
|
292
|
-
state = '
|
293
|
-
elif state == '
|
458
|
+
state = 'select_where_sc_limit_'
|
459
|
+
elif state == 'select_from_x_inner':
|
294
460
|
if token.ttype == T.Text.Whitespace:
|
295
|
-
state = '
|
296
|
-
elif state == '
|
461
|
+
state = 'select_from_x_inner_'
|
462
|
+
elif state == 'select_from_x_inner_':
|
297
463
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
298
|
-
state = '
|
299
|
-
elif state == '
|
464
|
+
state = 'select_join'
|
465
|
+
elif state == 'select_join':
|
300
466
|
if token.ttype == T.Text.Whitespace:
|
301
|
-
state = '
|
302
|
-
elif state == '
|
467
|
+
state = 'select_join_'
|
468
|
+
elif state == 'select_join_':
|
303
469
|
if token.ttype == T.Name:
|
304
|
-
state = '
|
470
|
+
state = 'select_x_join_y'
|
305
471
|
|
306
|
-
elif state == '
|
472
|
+
elif state == 'select_from_x_left':
|
307
473
|
if token.ttype == T.Text.Whitespace:
|
308
|
-
state = '
|
309
|
-
elif state == '
|
474
|
+
state = 'select_from_x_left_'
|
475
|
+
elif state == 'select_from_x_left_':
|
310
476
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
311
|
-
state = '
|
477
|
+
state = 'select_join'
|
312
478
|
elif token.ttype == T.Keyword and token.value.lower() == 'outer':
|
313
|
-
state = '
|
314
|
-
elif state == '
|
479
|
+
state = 'select_from_x_left_outer'
|
480
|
+
elif state == 'select_from_x_left_outer':
|
315
481
|
if token.ttype == T.Text.Whitespace:
|
316
|
-
state = '
|
317
|
-
elif state == '
|
482
|
+
state = 'select_from_x_left_outer_'
|
483
|
+
elif state == 'select_from_x_left_outer_':
|
318
484
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
319
|
-
state = '
|
485
|
+
state = 'select_join_'
|
320
486
|
|
321
|
-
elif state == '
|
487
|
+
elif state == 'select_from_x_right':
|
322
488
|
if token.ttype == T.Text.Whitespace:
|
323
|
-
state = '
|
324
|
-
elif state == '
|
489
|
+
state = 'select_from_x_right_'
|
490
|
+
elif state == 'select_from_x_right_':
|
325
491
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
326
|
-
state = '
|
492
|
+
state = 'select_join'
|
327
493
|
elif token.ttype == T.Keyword and token.value.lower() == 'outer':
|
328
|
-
state = '
|
329
|
-
elif state == '
|
494
|
+
state = 'select_from_x_right_outer'
|
495
|
+
elif state == 'select_from_x_right_outer':
|
330
496
|
if token.ttype == T.Text.Whitespace:
|
331
|
-
state = '
|
332
|
-
elif state == '
|
497
|
+
state = 'select_from_x_right_outer_'
|
498
|
+
elif state == 'select_from_x_right_outer_':
|
333
499
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
334
|
-
state = '
|
500
|
+
state = 'select_join_'
|
335
501
|
|
336
|
-
elif state == '
|
502
|
+
elif state == 'select_from_x_full':
|
337
503
|
if token.ttype == T.Text.Whitespace:
|
338
|
-
state = '
|
339
|
-
elif state == '
|
504
|
+
state = 'select_from_x_full_'
|
505
|
+
elif state == 'select_from_x_full_':
|
340
506
|
if token.ttype == T.Keyword and token.value.lower() == 'outer':
|
341
|
-
state = '
|
342
|
-
elif state == '
|
507
|
+
state = 'select_from_x_full_outer'
|
508
|
+
elif state == 'select_from_x_full_outer':
|
343
509
|
if token.ttype == T.Text.Whitespace:
|
344
|
-
state = '
|
345
|
-
elif state == '
|
510
|
+
state = 'select_from_x_full_outer_'
|
511
|
+
elif state == 'select_from_x_full_outer_':
|
346
512
|
if token.ttype == T.Keyword and token.value.lower() == 'join':
|
347
|
-
state = '
|
513
|
+
state = 'select_join_'
|
348
514
|
|
349
|
-
elif state == '
|
515
|
+
elif state == 'select_x_join_y':
|
350
516
|
if token.ttype == T.Punctuation and token.value == ',':
|
351
|
-
state = '
|
517
|
+
state = 'select_x_join_y,'
|
352
518
|
elif token.ttype == T.Text.Whitespace:
|
353
|
-
state = '
|
354
|
-
elif state == '
|
519
|
+
state = 'select_x_join_y_'
|
520
|
+
elif state == 'select_x_join_y,':
|
355
521
|
if token.ttype == T.Name:
|
356
|
-
state = '
|
357
|
-
elif state == '
|
522
|
+
state = 'select_x_join_y'
|
523
|
+
elif state == 'select_x_join_y_':
|
358
524
|
if token.ttype == T.Keyword and token.value.lower() == 'on':
|
359
|
-
state = '
|
360
|
-
elif state == '
|
525
|
+
state = 'select_x_join_y_on'
|
526
|
+
elif state == 'select_x_join_y_on':
|
361
527
|
if token.ttype == T.Text.Whitespace:
|
362
|
-
state = '
|
363
|
-
elif state == '
|
528
|
+
state = 'select_x_join_y_on_'
|
529
|
+
elif state == 'select_x_join_y_on_':
|
364
530
|
if token.ttype == T.Name:
|
365
|
-
state = '
|
366
|
-
elif state == '
|
531
|
+
state = 'select_x_join_y_on_a'
|
532
|
+
elif state == 'select_x_join_y_on_a':
|
367
533
|
if token.ttype == T.Operator.Comparison:
|
368
|
-
state = '
|
369
|
-
elif state == '
|
534
|
+
state = 'select_x_join_y_on_a_op'
|
535
|
+
elif state == 'select_x_join_y_on_a_op':
|
370
536
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
371
|
-
state = '
|
372
|
-
elif state == '
|
537
|
+
state = 'select_x_join_y_on_a_opb'
|
538
|
+
elif state == 'select_x_join_y_on_a_opb':
|
373
539
|
if token.ttype == T.Text.Whitespace:
|
374
|
-
state = '
|
540
|
+
state = 'select_x_join_y_on_a_opb_'
|
375
541
|
elif token.ttype == T.Punctuation and token.value == ',':
|
376
|
-
state = '
|
377
|
-
elif state == '
|
542
|
+
state = 'select_x_join_y_on_'
|
543
|
+
elif state == 'select_x_join_y_on_a_opb_':
|
378
544
|
if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
|
379
|
-
state = '
|
545
|
+
state = 'select_join'
|
380
546
|
elif token.ttype == T.Keyword and token.value.lower() == 'where':
|
381
|
-
state = '
|
547
|
+
state = 'select_where'
|
382
548
|
elif token.ttype == T.Keyword and token.value.lower() == 'group':
|
383
|
-
state = '
|
549
|
+
state = 'select_from_x_group'
|
384
550
|
elif token.ttype == T.Keyword and token.value.lower() == 'group by':
|
385
|
-
state = '
|
551
|
+
state = 'select_from_x_group_by'
|
386
552
|
elif token.ttype == T.Keyword and token.value.lower() == 'limit':
|
387
|
-
state = '
|
553
|
+
state = 'select_where_sc_limit'
|
388
554
|
|
389
555
|
elif state == 'insert':
|
390
556
|
if token.ttype == T.Text.Whitespace:
|
@@ -402,43 +568,43 @@ class SqlCompleter(Completer):
|
|
402
568
|
if token.ttype == T.Text.Whitespace:
|
403
569
|
state = 'insert_into_x_'
|
404
570
|
elif token.ttype == T.Punctuation and token.value == '(':
|
405
|
-
state = '
|
571
|
+
state = 'insert_into_x_lp_'
|
406
572
|
elif state == 'insert_into_x_':
|
407
573
|
if token.ttype == T.Punctuation and token.value == '(':
|
408
|
-
state = '
|
574
|
+
state = 'insert_into_x_lp_'
|
409
575
|
elif token.ttype == T.Keyword and token.value.lower() == 'values':
|
410
|
-
state = '
|
411
|
-
elif state == '
|
576
|
+
state = 'insert_values'
|
577
|
+
elif state == 'insert_into_x_lp_':
|
412
578
|
if token.ttype == T.Name:
|
413
|
-
state = '
|
414
|
-
elif state == '
|
579
|
+
state = 'insert_into_x_lp_a'
|
580
|
+
elif state == 'insert_into_x_lp_a':
|
415
581
|
if token.ttype == T.Punctuation and token.value == ',':
|
416
|
-
state = '
|
582
|
+
state = 'insert_into_x_lp_a,'
|
417
583
|
elif token.ttype == T.Punctuation and token.value == ')':
|
418
|
-
state = '
|
419
|
-
elif state == '
|
584
|
+
state = 'insert_into_x_lp_a_rp'
|
585
|
+
elif state == 'insert_into_x_lp_a,':
|
420
586
|
if token.ttype == T.Name:
|
421
|
-
state = '
|
422
|
-
elif state == '
|
587
|
+
state = 'insert_into_x_lp_a'
|
588
|
+
elif state == 'insert_into_x_lp_a_rp':
|
423
589
|
if token.ttype == T.Text.Whitespace:
|
424
|
-
state = '
|
425
|
-
elif state == '
|
590
|
+
state = 'insert_into_x_lp_a_rp_'
|
591
|
+
elif state == 'insert_into_x_lp_a_rp_':
|
426
592
|
if token.ttype == T.Keyword and token.value.lower() == 'values':
|
427
|
-
state = '
|
428
|
-
|
593
|
+
state = 'insert_values'
|
594
|
+
elif token.ttype == T.Keyword.DML and token.value.lower() == 'select':
|
595
|
+
state = 'select_'
|
596
|
+
elif state == 'insert_values':
|
429
597
|
if token.ttype == T.Punctuation and token.value == '(':
|
430
|
-
state = '
|
431
|
-
elif state == '
|
598
|
+
state = 'insert_values_lp_'
|
599
|
+
elif state == 'insert_values_lp_':
|
432
600
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
433
|
-
state = '
|
434
|
-
elif state == '
|
601
|
+
state = 'insert_values_lp_v'
|
602
|
+
elif state == 'insert_values_lp_v':
|
435
603
|
if token.ttype == T.Punctuation and token.value == ',':
|
436
|
-
state = '
|
437
|
-
|
438
|
-
state = 'insert_into_x_values(v)'
|
439
|
-
elif state == 'insert_into_x_values(v,':
|
604
|
+
state = 'insert_values_lp_v,'
|
605
|
+
elif state == 'insert_values_lp_v,':
|
440
606
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
441
|
-
state = '
|
607
|
+
state = 'insert_values_lp_v'
|
442
608
|
|
443
609
|
elif state == 'update':
|
444
610
|
if token.ttype == T.Text.Whitespace:
|
@@ -460,41 +626,41 @@ class SqlCompleter(Completer):
|
|
460
626
|
state = 'update_x_set_a'
|
461
627
|
elif state == 'update_x_set_a':
|
462
628
|
if token.ttype == T.Operator.Comparison:
|
463
|
-
state = '
|
464
|
-
elif state == '
|
629
|
+
state = 'update_x_set_a_op'
|
630
|
+
elif state == 'update_x_set_a_op':
|
465
631
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
466
|
-
state = '
|
467
|
-
elif state == '
|
632
|
+
state = 'update_x_set_sc'
|
633
|
+
elif state == 'update_x_set_sc':
|
468
634
|
if token.ttype == T.Punctuation and token.value == ',':
|
469
|
-
state = '
|
635
|
+
state = 'update_x_set_sc,'
|
470
636
|
elif token.ttype == T.Text.Whitespace:
|
471
|
-
state = '
|
472
|
-
elif state == '
|
637
|
+
state = 'update_x_set_sc_'
|
638
|
+
elif state == 'update_x_set_sc,':
|
473
639
|
if token.ttype == T.Name:
|
474
640
|
state = 'update_x_set_a'
|
475
|
-
elif state == '
|
641
|
+
elif state == 'update_x_set_sc_':
|
476
642
|
if token.ttype == T.Punctuation and token.value == ',':
|
477
|
-
state = '
|
643
|
+
state = 'update_x_set_sc,'
|
478
644
|
elif token.ttype == T.Keyword and token.value.lower() == 'where':
|
479
|
-
state = '
|
480
|
-
elif state == '
|
645
|
+
state = 'update_where'
|
646
|
+
elif state == 'update_where':
|
481
647
|
if token.ttype == T.Text.Whitespace:
|
482
|
-
state = '
|
483
|
-
elif state == '
|
648
|
+
state = 'update_where_'
|
649
|
+
elif state == 'update_where_':
|
484
650
|
if token.ttype == T.Name:
|
485
|
-
state = '
|
486
|
-
elif state == '
|
651
|
+
state = 'update_where_a'
|
652
|
+
elif state == 'update_where_a':
|
487
653
|
if token.ttype == T.Operator.Comparison:
|
488
|
-
state = '
|
489
|
-
elif state == '
|
654
|
+
state = 'update_where_a_op'
|
655
|
+
elif state == 'update_where_a_op':
|
490
656
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
491
|
-
state = '
|
492
|
-
elif state == '
|
657
|
+
state = 'update_where_sc'
|
658
|
+
elif state == 'update_where_sc':
|
493
659
|
if token.ttype == T.Text.Whitespace:
|
494
|
-
state = '
|
495
|
-
elif state == '
|
660
|
+
state = 'update_where_sc_'
|
661
|
+
elif state == 'update_where_sc_':
|
496
662
|
if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
|
497
|
-
state = '
|
663
|
+
state = 'update_where'
|
498
664
|
|
499
665
|
elif state == 'delete':
|
500
666
|
if token.ttype == T.Text.Whitespace:
|
@@ -513,25 +679,25 @@ class SqlCompleter(Completer):
|
|
513
679
|
state = 'delete_from_x_'
|
514
680
|
elif state == 'delete_from_x_':
|
515
681
|
if token.ttype == T.Keyword and token.value.lower() == 'where':
|
516
|
-
state = '
|
517
|
-
elif state == '
|
682
|
+
state = 'delete_where'
|
683
|
+
elif state == 'delete_where':
|
518
684
|
if token.ttype == T.Text.Whitespace:
|
519
|
-
state = '
|
520
|
-
elif state == '
|
685
|
+
state = 'delete_where_'
|
686
|
+
elif state == 'delete_where_':
|
521
687
|
if token.ttype == T.Name:
|
522
|
-
state = '
|
523
|
-
elif state == '
|
688
|
+
state = 'delete_where_a'
|
689
|
+
elif state == 'delete_where_a':
|
524
690
|
if token.ttype == T.Operator.Comparison:
|
525
|
-
state = '
|
526
|
-
elif state == '
|
691
|
+
state = 'delete_where_a_op'
|
692
|
+
elif state == 'delete_where_a_op':
|
527
693
|
if token.ttype in [T.Literal.String.Single, T.Name]:
|
528
|
-
state = '
|
529
|
-
elif state == '
|
694
|
+
state = 'delete_where_sc'
|
695
|
+
elif state == 'delete_where_sc':
|
530
696
|
if token.ttype == T.Text.Whitespace:
|
531
|
-
state = '
|
532
|
-
elif state == '
|
697
|
+
state = 'delete_where_sc_'
|
698
|
+
elif state == 'delete_where_sc_':
|
533
699
|
if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
|
534
|
-
state = '
|
700
|
+
state = 'delete_where'
|
535
701
|
|
536
702
|
return state
|
537
703
|
|
adam/sql/term_completer.py
CHANGED
@@ -46,15 +46,22 @@ class TermCompleter(WordCompleter):
|
|
46
46
|
if self.ignore_case:
|
47
47
|
word = word.lower()
|
48
48
|
|
49
|
-
if word_before_cursor in ['(', ',', '=']:
|
50
|
-
return True
|
51
|
-
|
52
49
|
if self.match_middle:
|
53
50
|
return word_before_cursor in word
|
54
51
|
else:
|
55
52
|
return word.startswith(word_before_cursor)
|
56
53
|
|
57
54
|
for a in words:
|
55
|
+
if word_before_cursor in ['(', ',', '=']:
|
56
|
+
display = self.display_dict.get(a, a)
|
57
|
+
display_meta = self.meta_dict.get(a, "")
|
58
|
+
yield Completion(
|
59
|
+
a,
|
60
|
+
0,
|
61
|
+
display=display,
|
62
|
+
display_meta=display_meta,
|
63
|
+
)
|
64
|
+
|
58
65
|
if word_matches(a):
|
59
66
|
display = self.display_dict.get(a, a)
|
60
67
|
display_meta = self.meta_dict.get(a, "")
|
adam/version.py
CHANGED
@@ -14,7 +14,7 @@ adam/repl_commands.py,sha256=WA90Rl27Juctzr3U3kfCDk5N-oYMKlfWbZeafUgk7k0,4723
|
|
14
14
|
adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
|
15
15
|
adam/repl_state.py,sha256=591d7gV6uQSFtm7IWdlIYAHjfAzs9bdvIkwlIAeKddE,7540
|
16
16
|
adam/utils.py,sha256=2DoWsrcaioFFH0-RjT30qelVRPUJqCGTfz_ucfE7F8g,7406
|
17
|
-
adam/version.py,sha256=
|
17
|
+
adam/version.py,sha256=kXINOe-uvId2Kbv9pAAleFVyJC-tHoAx6EmOAUzCUjY,139
|
18
18
|
adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
|
20
20
|
adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
|
@@ -164,9 +164,8 @@ adam/k8s_utils/services.py,sha256=EOJJGACVbbRvu5T3rMKqIJqgYic1_MSJ17EA0TJ6UOk,31
|
|
164
164
|
adam/k8s_utils/statefulsets.py,sha256=hiBOmJZ3KTI6_naAFzNoW1NoYnnBG35BZ7RMdPhNC6o,4664
|
165
165
|
adam/k8s_utils/volumes.py,sha256=RIBmlOSWM3V3QVXLCFT0owVOyh4rGG1ETp521a-6ndo,1137
|
166
166
|
adam/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
167
|
-
adam/sql/sql_completer.py,sha256=
|
168
|
-
adam/sql/
|
169
|
-
adam/sql/term_completer.py,sha256=O-sUxFVc1DJmPQCdT-XPK2SSkUe4AL1dw8ZPXXicATY,2273
|
167
|
+
adam/sql/sql_completer.py,sha256=BAg1Ogn_q1JSjpQhN-2jVzIuMoH1FpFzn_xpMRvB-TQ,35882
|
168
|
+
adam/sql/term_completer.py,sha256=VCCMPUzvh_9lwIOwqQmeijM0V2JPADkBbNV4HQIqDCw,2538
|
170
169
|
adam/sso/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
171
170
|
adam/sso/authenticator.py,sha256=BCm16L9zf5aLU47-sTCnudn2zLPwd8M2wwRminJfsqw,615
|
172
171
|
adam/sso/authn_ad.py,sha256=fDW8UR3WWykny5Awa5dQjjBUSFzIDz4aMn-lwXoABl8,5857
|
@@ -177,8 +176,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
|
|
177
176
|
adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
|
178
177
|
adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
|
179
178
|
adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
|
180
|
-
kaqing-2.0.
|
181
|
-
kaqing-2.0.
|
182
|
-
kaqing-2.0.
|
183
|
-
kaqing-2.0.
|
184
|
-
kaqing-2.0.
|
179
|
+
kaqing-2.0.57.dist-info/METADATA,sha256=AJUgGbSTZ4aZy5vdBdNW076Iv-L5SKzR00IFzWOtDUk,132
|
180
|
+
kaqing-2.0.57.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
181
|
+
kaqing-2.0.57.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
|
182
|
+
kaqing-2.0.57.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
|
183
|
+
kaqing-2.0.57.dist-info/RECORD,,
|
adam/sql/sql_utils.py
DELETED
File without changes
|
File without changes
|
File without changes
|