kaqing 2.0.56__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 CHANGED
@@ -10,7 +10,128 @@ from adam.sql.term_completer import TermCompleter
10
10
  columns = TermCompleter(['id', 'x.', 'y.', 'z.'])
11
11
 
12
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>]
13
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> }...
14
135
  def __init__(self, tables: Callable[[], list[str]], dml: str = None, debug = False):
15
136
  super().__init__()
16
137
  self.dml = dml
@@ -45,65 +166,67 @@ class SqlCompleter(Completer):
45
166
  completer = TermCompleter(['*'])
46
167
  elif state == 'select_a_':
47
168
  completer = TermCompleter(['from'])
48
- elif state == "select_a_from_":
169
+ elif state == "select_from_":
49
170
  completer = TermCompleter(self.tables())
50
- elif state == "select_a_from_x_":
171
+ elif state == "select_from_x_":
51
172
  completer = TermCompleter(['as', 'where', 'inner', 'left', 'right', 'full', 'group', 'limit'])
52
- elif state == "select_a_from_x_as_x_":
173
+ elif state == "select_from_x_as_x_":
53
174
  completer = TermCompleter(['where', 'inner', 'left', 'right', 'full', 'group', 'limit'])
54
- elif state == "select_a_from_x,":
175
+ elif state == "select_from_x,":
55
176
  completer = TermCompleter(self.tables())
56
- elif state == "select_a_from_x_as_":
177
+ elif state == "select_from_x_as_":
57
178
  completer = TermCompleter(['x', 'y', 'z'])
58
- elif state == "select_a_from_x_as_x,":
179
+ elif state == "select_from_x_as_x,":
59
180
  completer = TermCompleter(self.tables())
60
- elif state == "select_a_from_x_where_":
181
+ elif state == "select_where_":
61
182
  completer = columns
62
- elif state == "select_a_from_x_where_id":
63
- completer = TermCompleter(['=', '<', '<=', '>', '>=', '<>', 'like'])
64
- elif state == "select_a_from_x_where_id=":
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":
65
188
  completer = TermCompleter(["'"])
66
- elif state == "select_a_from_x_where_id=v_":
189
+ elif state == "select_where_sc_":
67
190
  completer = TermCompleter(['and', 'or', 'group', 'limit'])
68
- elif state == "select_a_from_x_where_id=v_limit_":
191
+ elif state == "select_where_sc_limit_":
69
192
  completer = TermCompleter(['1'])
70
- elif state == "select_a_from_x_group_":
193
+ elif state == "select_from_x_group_":
71
194
  completer = TermCompleter(['by'])
72
- elif state == "select_a_from_x_group_by_":
195
+ elif state == "select_from_x_group_by_":
73
196
  completer = columns
74
- elif state == "select_a_from_x_group_by_a,":
197
+ elif state == "select_from_x_group_by_a,":
75
198
  completer = columns
76
- elif state == "select_a_from_x_group_by_a_":
199
+ elif state == "select_from_x_group_by_a_":
77
200
  completer = TermCompleter(['limit'])
78
- elif state == "select_a_from_x_group_by_a_limit_":
201
+ elif state == "select_from_x_group_by_a_limit_":
79
202
  completer = TermCompleter(['1'])
80
- elif state == "select_a_from_x_inner_":
203
+ elif state == "select_from_x_inner_":
81
204
  completer = TermCompleter(['join'])
82
- elif state in ["select_a_from_x_inner_join_", "select_a_from_x_left_join_"]:
205
+ elif state in ["select_join_", "select_from_x_left_join_"]:
83
206
  completer = TermCompleter(self.tables())
84
- elif state == "select_a_from_x_inner_join_y,":
207
+ elif state == "select_x_join_y,":
85
208
  completer = TermCompleter(self.tables())
86
- elif state == "select_a_from_x_inner_join_y_":
209
+ elif state == "select_x_join_y_":
87
210
  completer = TermCompleter(['on'])
88
- elif state == "select_a_from_x_inner_join_y_on_":
211
+ elif state == "select_x_join_y_on_":
89
212
  completer = columns
90
- elif state == "select_a_from_x_inner_join_y_on_a":
213
+ elif state == "select_x_join_y_on_a":
91
214
  completer = TermCompleter(['='])
92
- elif state == "select_a_from_x_inner_join_y_on_a=":
215
+ elif state == "select_x_join_y_on_a_op":
93
216
  completer = columns
94
- elif state == "select_a_from_x_inner_join_y_on_a=b_":
217
+ elif state == "select_x_join_y_on_a_opb_":
95
218
  completer = TermCompleter(['where', 'group', 'limit'])
96
- elif state == "select_a_from_x_left_":
219
+ elif state == "select_from_x_left_":
97
220
  completer = TermCompleter(['outer', 'join'])
98
- elif state == "select_a_from_x_left_outer_":
221
+ elif state == "select_from_x_left_outer_":
99
222
  completer = TermCompleter(['join'])
100
- elif state == "select_a_from_x_right_":
223
+ elif state == "select_from_x_right_":
101
224
  completer = TermCompleter(['outer', 'join'])
102
- elif state == "select_a_from_x_right_outer_":
225
+ elif state == "select_from_x_right_outer_":
103
226
  completer = TermCompleter(['join'])
104
- elif state == "select_a_from_x_full_":
227
+ elif state == "select_from_x_full_":
105
228
  completer = TermCompleter(['outer'])
106
- elif state == "select_a_from_x_full_outer_":
229
+ elif state == "select_from_x_full_outer_":
107
230
  completer = TermCompleter(['join'])
108
231
 
109
232
  elif state == "insert_":
@@ -111,35 +234,35 @@ class SqlCompleter(Completer):
111
234
  elif state == "insert_into_":
112
235
  completer = TermCompleter(self.tables())
113
236
  elif state == "insert_into_x_":
114
- completer = TermCompleter(['values'])
115
- elif state == "insert_into_x(":
237
+ completer = TermCompleter(['values(', 'select'])
238
+ elif state == "insert_into_x_lp_":
116
239
  completer = columns
117
- elif state == "insert_into_x(a,":
240
+ elif state == "insert_into_x_lp_a,":
118
241
  completer = columns
119
- elif state == "insert_into_x(a)_":
120
- completer = TermCompleter(['values('])
121
- elif state == "insert_into_x_values":
242
+ elif state == "insert_into_x_lp_a_rp_":
243
+ completer = TermCompleter(['values(', 'select'])
244
+ elif state == "insert_values":
122
245
  completer = TermCompleter(['('])
123
- elif state == "insert_into_x_values(":
246
+ elif state == "insert_values_lp_":
124
247
  completer = TermCompleter(["'"])
125
248
 
126
249
  elif state == "update_":
127
250
  completer = TermCompleter(self.tables())
128
251
  elif state == "update_x_":
129
252
  completer = TermCompleter(['set'])
130
- elif state in ["update_x_set_", "update_x_set_a=v,"]:
253
+ elif state in ["update_x_set_", "update_x_set_sc,"]:
131
254
  completer = columns
132
255
  elif state == "update_x_set_a":
133
256
  completer = TermCompleter(['='])
134
- elif state == "update_x_set_a=":
257
+ elif state == "update_x_set_a_op":
135
258
  completer = TermCompleter(["'"])
136
- elif state == "update_x_set_a=v_":
259
+ elif state == "update_x_set_sc_":
137
260
  completer = TermCompleter(['where'])
138
- elif state == "update_x_set_a=v_where_":
261
+ elif state == "update_where_":
139
262
  completer = columns
140
- elif state == "update_x_set_a=v_where_id":
263
+ elif state == "update_where_a":
141
264
  completer = TermCompleter(['='])
142
- elif state == "update_x_set_a=v_where_id=v_":
265
+ elif state == "update_where_sc_":
143
266
  completer = TermCompleter(['and', 'or'])
144
267
 
145
268
  elif state == "delete_":
@@ -148,13 +271,13 @@ class SqlCompleter(Completer):
148
271
  completer = TermCompleter(self.tables())
149
272
  elif state == "delete_from_x_":
150
273
  completer = TermCompleter(['where'])
151
- elif state == "delete_from_x_where_":
274
+ elif state == "delete_where_":
152
275
  completer = columns
153
- elif state == "delete_from_x_where_id":
276
+ elif state == "delete_where_a":
154
277
  completer = TermCompleter(['='])
155
- elif state == "delete_from_x_where_id=":
278
+ elif state == "delete_where_a_op":
156
279
  completer = TermCompleter(["'"])
157
- elif state == "delete_from_x_where_id=v_":
280
+ elif state == "delete_where_sc_":
158
281
  completer = TermCompleter(['and', 'or'])
159
282
 
160
283
  if completer:
@@ -209,209 +332,225 @@ class SqlCompleter(Completer):
209
332
  state = 'select_a'
210
333
  elif state == 'select_a_':
211
334
  if token.ttype == T.Keyword and token.value.lower() == 'from':
212
- state = 'select_a_from'
213
- elif state == 'select_a_from':
335
+ state = 'select_from'
336
+ elif state == 'select_from':
214
337
  if token.ttype == T.Text.Whitespace:
215
- state = 'select_a_from_'
216
- elif state == 'select_a_from_':
338
+ state = 'select_from_'
339
+ elif state == 'select_from_':
217
340
  if token.ttype == T.Name:
218
- state = 'select_a_from_x'
219
- elif state == 'select_a_from_x':
341
+ state = 'select_from_x'
342
+ elif state == 'select_from_x':
220
343
  if token.ttype == T.Text.Whitespace:
221
- state = 'select_a_from_x_'
344
+ state = 'select_from_x_'
222
345
  elif token.ttype == T.Punctuation and token.value == ',':
223
- state = 'select_a_from_x,'
224
- elif state == 'select_a_from_x,':
346
+ state = 'select_from_x,'
347
+ elif state == 'select_from_x,':
225
348
  if token.ttype == T.Name:
226
- state = 'select_a_from_x'
227
- elif state in ['select_a_from_x_', 'select_a_from_x_as_x_']:
349
+ state = 'select_from_x'
350
+ elif state in ['select_from_x_', 'select_from_x_as_x_']:
228
351
  if token.ttype == T.Punctuation and token.value == ',':
229
- state = 'select_a_from_x,'
352
+ state = 'select_from_x,'
230
353
  elif token.ttype == T.Keyword and token.value.lower() == 'as':
231
- state = 'select_a_from_x_as'
354
+ state = 'select_from_x_as'
232
355
  elif token.ttype == T.Keyword and token.value.lower() == 'where':
233
- state = 'select_a_from_x_where'
356
+ state = 'select_where'
234
357
  elif token.ttype == T.Keyword and token.value.lower() == 'limit':
235
- state = 'select_a_from_x_where_id=v_limit'
358
+ state = 'select_where_sc_limit'
236
359
  elif token.ttype == T.Keyword and token.value.lower() == 'group':
237
- state = 'select_a_from_x_group'
360
+ state = 'select_from_x_group'
238
361
  elif token.ttype == T.Keyword and token.value.lower() == 'group by':
239
- state = 'select_a_from_x_group_by'
362
+ state = 'select_from_x_group_by'
240
363
  elif token.ttype == T.Keyword and token.value.lower() == 'inner':
241
- state = 'select_a_from_x_inner'
364
+ state = 'select_from_x_inner'
242
365
  elif token.ttype == T.Keyword and token.value.lower() == 'inner join':
243
- state = 'select_a_from_x_inner_join'
366
+ state = 'select_join'
244
367
  elif token.ttype == T.Keyword and token.value.lower() == 'left':
245
- state = 'select_a_from_x_left'
368
+ state = 'select_from_x_left'
246
369
  elif token.ttype == T.Keyword and token.value.lower() in ['left join', 'left outer join']:
247
- state = 'select_a_from_x_inner_join'
370
+ state = 'select_join'
248
371
  elif token.ttype == T.Keyword and token.value.lower() == 'right':
249
- state = 'select_a_from_x_right'
372
+ state = 'select_from_x_right'
250
373
  elif token.ttype == T.Keyword and token.value.lower() in ['right join', 'right outer join']:
251
- state = 'select_a_from_x_inner_join'
374
+ state = 'select_join'
252
375
  elif token.ttype == T.Keyword and token.value.lower() == 'full':
253
- state = 'select_a_from_x_full'
376
+ state = 'select_from_x_full'
254
377
  elif token.ttype == T.Keyword and token.value.lower() == 'full outer join':
255
- state = 'select_a_from_x_inner_join'
256
- elif state == 'select_a_from_x_as':
378
+ state = 'select_join'
379
+ elif state == 'select_from_x_as':
257
380
  if token.ttype == T.Text.Whitespace:
258
- state = 'select_a_from_x_as_'
259
- elif state == 'select_a_from_x_as_':
381
+ state = 'select_from_x_as_'
382
+ elif state == 'select_from_x_as_':
260
383
  if token.ttype == T.Name:
261
- state = 'select_a_from_x_as_x'
262
- elif state == 'select_a_from_x_as_x':
384
+ state = 'select_from_x_as_x'
385
+ elif state == 'select_from_x_as_x':
263
386
  if token.ttype == T.Text.Whitespace:
264
- state = 'select_a_from_x_as_x_'
387
+ state = 'select_from_x_as_x_'
265
388
  elif token.ttype == T.Punctuation and token.value == ',':
266
- state = 'select_a_from_x_as_x,'
267
- elif state == 'select_a_from_x_as_x,':
389
+ state = 'select_from_x_as_x,'
390
+ elif state == 'select_from_x_as_x,':
268
391
  if token.ttype == T.Name:
269
- state = 'select_a_from_x'
270
- elif state == 'select_a_from_x_where':
392
+ state = 'select_from_x'
393
+ elif state == 'select_where':
271
394
  if token.ttype == T.Text.Whitespace:
272
- state = 'select_a_from_x_where_'
273
- elif state == 'select_a_from_x_where_':
395
+ state = 'select_where_'
396
+ elif state == 'select_where_':
274
397
  if token.ttype == T.Name:
275
- state = 'select_a_from_x_where_id'
276
- elif state == 'select_a_from_x_where_id':
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_':
277
405
  if token.ttype == T.Operator.Comparison:
278
- state = 'select_a_from_x_where_id='
279
- elif state == 'select_a_from_x_where_id=':
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':
280
419
  if token.ttype in [T.Literal.String.Single, T.Name]:
281
- state = 'select_a_from_x_where_id=v'
282
- elif state == 'select_a_from_x_where_id=v':
420
+ state = 'select_where_sc'
421
+ elif state == 'select_where_sc':
283
422
  if token.ttype == T.Text.Whitespace:
284
- state = 'select_a_from_x_where_id=v_'
285
- elif state == 'select_a_from_x_where_id=v_':
423
+ state = 'select_where_sc_'
424
+ elif state == 'select_where_sc_':
286
425
  if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
287
- state = 'select_a_from_x_where'
426
+ state = 'select_where'
288
427
  elif token.ttype == T.Keyword and token.value.lower() == 'group':
289
- state = 'select_a_from_x_group'
428
+ state = 'select_from_x_group'
290
429
  elif token.ttype == T.Keyword and token.value.lower() == 'group by':
291
- state = 'select_a_from_x_group_by'
430
+ state = 'select_from_x_group_by'
292
431
  elif token.ttype == T.Keyword and token.value.lower() == 'limit':
293
- state = 'select_a_from_x_where_id=v_limit'
294
- elif state == 'select_a_from_x_group':
432
+ state = 'select_where_sc_limit'
433
+ elif state == 'select_from_x_group':
295
434
  if token.ttype == T.Text.Whitespace:
296
- state = 'select_a_from_x_group_'
297
- elif state == 'select_a_from_x_group_':
435
+ state = 'select_from_x_group_'
436
+ elif state == 'select_from_x_group_':
298
437
  if token.ttype == T.Keyword and token.value.lower() == 'by':
299
- state = 'select_a_from_x_group_by'
300
- elif state == 'select_a_from_x_group_by':
438
+ state = 'select_from_x_group_by'
439
+ elif state == 'select_from_x_group_by':
301
440
  if token.ttype == T.Text.Whitespace:
302
- state = 'select_a_from_x_group_by_'
303
- elif state == 'select_a_from_x_group_by_':
441
+ state = 'select_from_x_group_by_'
442
+ elif state == 'select_from_x_group_by_':
304
443
  if token.ttype == T.Name:
305
- state = 'select_a_from_x_group_by_a'
306
- elif state == 'select_a_from_x_group_by_a':
444
+ state = 'select_from_x_group_by_a'
445
+ elif state == 'select_from_x_group_by_a':
307
446
  if token.ttype == T.Text.Whitespace:
308
- state = 'select_a_from_x_group_by_a_'
447
+ state = 'select_from_x_group_by_a_'
309
448
  elif token.ttype == T.Punctuation and token.value == ',':
310
- state = 'select_a_from_x_group_by_a,'
311
- elif state == 'select_a_from_x_group_by_a,':
449
+ state = 'select_from_x_group_by_a,'
450
+ elif state == 'select_from_x_group_by_a,':
312
451
  if token.ttype == T.Name:
313
- state = 'select_a_from_x_group_by_a'
314
- elif state == 'select_a_from_x_group_by_a_':
452
+ state = 'select_from_x_group_by_a'
453
+ elif state == 'select_from_x_group_by_a_':
315
454
  if token.ttype == T.Keyword and token.value.lower() == 'limit':
316
- state = 'select_a_from_x_where_id=v_limit'
317
- elif state == 'select_a_from_x_where_id=v_limit':
455
+ state = 'select_where_sc_limit'
456
+ elif state == 'select_where_sc_limit':
318
457
  if token.ttype == T.Text.Whitespace:
319
- state = 'select_a_from_x_where_id=v_limit_'
320
- elif state == 'select_a_from_x_inner':
458
+ state = 'select_where_sc_limit_'
459
+ elif state == 'select_from_x_inner':
321
460
  if token.ttype == T.Text.Whitespace:
322
- state = 'select_a_from_x_inner_'
323
- elif state == 'select_a_from_x_inner_':
461
+ state = 'select_from_x_inner_'
462
+ elif state == 'select_from_x_inner_':
324
463
  if token.ttype == T.Keyword and token.value.lower() == 'join':
325
- state = 'select_a_from_x_inner_join'
326
- elif state == 'select_a_from_x_inner_join':
464
+ state = 'select_join'
465
+ elif state == 'select_join':
327
466
  if token.ttype == T.Text.Whitespace:
328
- state = 'select_a_from_x_inner_join_'
329
- elif state == 'select_a_from_x_inner_join_':
467
+ state = 'select_join_'
468
+ elif state == 'select_join_':
330
469
  if token.ttype == T.Name:
331
- state = 'select_a_from_x_inner_join_y'
470
+ state = 'select_x_join_y'
332
471
 
333
- elif state == 'select_a_from_x_left':
472
+ elif state == 'select_from_x_left':
334
473
  if token.ttype == T.Text.Whitespace:
335
- state = 'select_a_from_x_left_'
336
- elif state == 'select_a_from_x_left_':
474
+ state = 'select_from_x_left_'
475
+ elif state == 'select_from_x_left_':
337
476
  if token.ttype == T.Keyword and token.value.lower() == 'join':
338
- state = 'select_a_from_x_inner_join'
477
+ state = 'select_join'
339
478
  elif token.ttype == T.Keyword and token.value.lower() == 'outer':
340
- state = 'select_a_from_x_left_outer'
341
- elif state == 'select_a_from_x_left_outer':
479
+ state = 'select_from_x_left_outer'
480
+ elif state == 'select_from_x_left_outer':
342
481
  if token.ttype == T.Text.Whitespace:
343
- state = 'select_a_from_x_left_outer_'
344
- elif state == 'select_a_from_x_left_outer_':
482
+ state = 'select_from_x_left_outer_'
483
+ elif state == 'select_from_x_left_outer_':
345
484
  if token.ttype == T.Keyword and token.value.lower() == 'join':
346
- state = 'select_a_from_x_inner_join_'
485
+ state = 'select_join_'
347
486
 
348
- elif state == 'select_a_from_x_right':
487
+ elif state == 'select_from_x_right':
349
488
  if token.ttype == T.Text.Whitespace:
350
- state = 'select_a_from_x_right_'
351
- elif state == 'select_a_from_x_right_':
489
+ state = 'select_from_x_right_'
490
+ elif state == 'select_from_x_right_':
352
491
  if token.ttype == T.Keyword and token.value.lower() == 'join':
353
- state = 'select_a_from_x_inner_join'
492
+ state = 'select_join'
354
493
  elif token.ttype == T.Keyword and token.value.lower() == 'outer':
355
- state = 'select_a_from_x_right_outer'
356
- elif state == 'select_a_from_x_right_outer':
494
+ state = 'select_from_x_right_outer'
495
+ elif state == 'select_from_x_right_outer':
357
496
  if token.ttype == T.Text.Whitespace:
358
- state = 'select_a_from_x_right_outer_'
359
- elif state == 'select_a_from_x_right_outer_':
497
+ state = 'select_from_x_right_outer_'
498
+ elif state == 'select_from_x_right_outer_':
360
499
  if token.ttype == T.Keyword and token.value.lower() == 'join':
361
- state = 'select_a_from_x_inner_join_'
500
+ state = 'select_join_'
362
501
 
363
- elif state == 'select_a_from_x_full':
502
+ elif state == 'select_from_x_full':
364
503
  if token.ttype == T.Text.Whitespace:
365
- state = 'select_a_from_x_full_'
366
- elif state == 'select_a_from_x_full_':
504
+ state = 'select_from_x_full_'
505
+ elif state == 'select_from_x_full_':
367
506
  if token.ttype == T.Keyword and token.value.lower() == 'outer':
368
- state = 'select_a_from_x_full_outer'
369
- elif state == 'select_a_from_x_full_outer':
507
+ state = 'select_from_x_full_outer'
508
+ elif state == 'select_from_x_full_outer':
370
509
  if token.ttype == T.Text.Whitespace:
371
- state = 'select_a_from_x_full_outer_'
372
- elif state == 'select_a_from_x_full_outer_':
510
+ state = 'select_from_x_full_outer_'
511
+ elif state == 'select_from_x_full_outer_':
373
512
  if token.ttype == T.Keyword and token.value.lower() == 'join':
374
- state = 'select_a_from_x_inner_join_'
513
+ state = 'select_join_'
375
514
 
376
- elif state == 'select_a_from_x_inner_join_y':
515
+ elif state == 'select_x_join_y':
377
516
  if token.ttype == T.Punctuation and token.value == ',':
378
- state = 'select_a_from_x_inner_join_y,'
517
+ state = 'select_x_join_y,'
379
518
  elif token.ttype == T.Text.Whitespace:
380
- state = 'select_a_from_x_inner_join_y_'
381
- elif state == 'select_a_from_x_inner_join_y,':
519
+ state = 'select_x_join_y_'
520
+ elif state == 'select_x_join_y,':
382
521
  if token.ttype == T.Name:
383
- state = 'select_a_from_x_inner_join_y'
384
- elif state == 'select_a_from_x_inner_join_y_':
522
+ state = 'select_x_join_y'
523
+ elif state == 'select_x_join_y_':
385
524
  if token.ttype == T.Keyword and token.value.lower() == 'on':
386
- state = 'select_a_from_x_inner_join_y_on'
387
- elif state == 'select_a_from_x_inner_join_y_on':
525
+ state = 'select_x_join_y_on'
526
+ elif state == 'select_x_join_y_on':
388
527
  if token.ttype == T.Text.Whitespace:
389
- state = 'select_a_from_x_inner_join_y_on_'
390
- elif state == 'select_a_from_x_inner_join_y_on_':
528
+ state = 'select_x_join_y_on_'
529
+ elif state == 'select_x_join_y_on_':
391
530
  if token.ttype == T.Name:
392
- state = 'select_a_from_x_inner_join_y_on_a'
393
- elif state == 'select_a_from_x_inner_join_y_on_a':
531
+ state = 'select_x_join_y_on_a'
532
+ elif state == 'select_x_join_y_on_a':
394
533
  if token.ttype == T.Operator.Comparison:
395
- state = 'select_a_from_x_inner_join_y_on_a='
396
- elif state == 'select_a_from_x_inner_join_y_on_a=':
534
+ state = 'select_x_join_y_on_a_op'
535
+ elif state == 'select_x_join_y_on_a_op':
397
536
  if token.ttype in [T.Literal.String.Single, T.Name]:
398
- state = 'select_a_from_x_inner_join_y_on_a=b'
399
- elif state == 'select_a_from_x_inner_join_y_on_a=b':
537
+ state = 'select_x_join_y_on_a_opb'
538
+ elif state == 'select_x_join_y_on_a_opb':
400
539
  if token.ttype == T.Text.Whitespace:
401
- state = 'select_a_from_x_inner_join_y_on_a=b_'
540
+ state = 'select_x_join_y_on_a_opb_'
402
541
  elif token.ttype == T.Punctuation and token.value == ',':
403
- state = 'select_a_from_x_inner_join_y_on_'
404
- elif state == 'select_a_from_x_inner_join_y_on_a=b_':
542
+ state = 'select_x_join_y_on_'
543
+ elif state == 'select_x_join_y_on_a_opb_':
405
544
  if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
406
- state = 'select_a_from_x_inner_join'
545
+ state = 'select_join'
407
546
  elif token.ttype == T.Keyword and token.value.lower() == 'where':
408
- state = 'select_a_from_x_where'
547
+ state = 'select_where'
409
548
  elif token.ttype == T.Keyword and token.value.lower() == 'group':
410
- state = 'select_a_from_x_group'
549
+ state = 'select_from_x_group'
411
550
  elif token.ttype == T.Keyword and token.value.lower() == 'group by':
412
- state = 'select_a_from_x_group_by'
551
+ state = 'select_from_x_group_by'
413
552
  elif token.ttype == T.Keyword and token.value.lower() == 'limit':
414
- state = 'select_a_from_x_where_id=v_limit'
553
+ state = 'select_where_sc_limit'
415
554
 
416
555
  elif state == 'insert':
417
556
  if token.ttype == T.Text.Whitespace:
@@ -429,43 +568,43 @@ class SqlCompleter(Completer):
429
568
  if token.ttype == T.Text.Whitespace:
430
569
  state = 'insert_into_x_'
431
570
  elif token.ttype == T.Punctuation and token.value == '(':
432
- state = 'insert_into_x('
571
+ state = 'insert_into_x_lp_'
433
572
  elif state == 'insert_into_x_':
434
573
  if token.ttype == T.Punctuation and token.value == '(':
435
- state = 'insert_into_x('
574
+ state = 'insert_into_x_lp_'
436
575
  elif token.ttype == T.Keyword and token.value.lower() == 'values':
437
- state = 'insert_into_x_values'
438
- elif state == 'insert_into_x(':
576
+ state = 'insert_values'
577
+ elif state == 'insert_into_x_lp_':
439
578
  if token.ttype == T.Name:
440
- state = 'insert_into_x(a'
441
- elif state == 'insert_into_x(a':
579
+ state = 'insert_into_x_lp_a'
580
+ elif state == 'insert_into_x_lp_a':
442
581
  if token.ttype == T.Punctuation and token.value == ',':
443
- state = 'insert_into_x(a,'
582
+ state = 'insert_into_x_lp_a,'
444
583
  elif token.ttype == T.Punctuation and token.value == ')':
445
- state = 'insert_into_x(a)'
446
- elif state == 'insert_into_x(a,':
584
+ state = 'insert_into_x_lp_a_rp'
585
+ elif state == 'insert_into_x_lp_a,':
447
586
  if token.ttype == T.Name:
448
- state = 'insert_into_x(a'
449
- elif state == 'insert_into_x(a)':
587
+ state = 'insert_into_x_lp_a'
588
+ elif state == 'insert_into_x_lp_a_rp':
450
589
  if token.ttype == T.Text.Whitespace:
451
- state = 'insert_into_x(a)_'
452
- elif state == 'insert_into_x(a)_':
590
+ state = 'insert_into_x_lp_a_rp_'
591
+ elif state == 'insert_into_x_lp_a_rp_':
453
592
  if token.ttype == T.Keyword and token.value.lower() == 'values':
454
- state = 'insert_into_x_values'
455
- elif state == 'insert_into_x_values':
593
+ state = 'insert_values'
594
+ elif token.ttype == T.Keyword.DML and token.value.lower() == 'select':
595
+ state = 'select_'
596
+ elif state == 'insert_values':
456
597
  if token.ttype == T.Punctuation and token.value == '(':
457
- state = 'insert_into_x_values('
458
- elif state == 'insert_into_x_values(':
598
+ state = 'insert_values_lp_'
599
+ elif state == 'insert_values_lp_':
459
600
  if token.ttype in [T.Literal.String.Single, T.Name]:
460
- state = 'insert_into_x_values(v'
461
- elif state == 'insert_into_x_values(v':
601
+ state = 'insert_values_lp_v'
602
+ elif state == 'insert_values_lp_v':
462
603
  if token.ttype == T.Punctuation and token.value == ',':
463
- state = 'insert_into_x_values(v,'
464
- elif token.ttype == T.Punctuation and token.value == ')':
465
- state = 'insert_into_x_values(v)'
466
- elif state == 'insert_into_x_values(v,':
604
+ state = 'insert_values_lp_v,'
605
+ elif state == 'insert_values_lp_v,':
467
606
  if token.ttype in [T.Literal.String.Single, T.Name]:
468
- state = 'insert_into_x_values(v'
607
+ state = 'insert_values_lp_v'
469
608
 
470
609
  elif state == 'update':
471
610
  if token.ttype == T.Text.Whitespace:
@@ -487,41 +626,41 @@ class SqlCompleter(Completer):
487
626
  state = 'update_x_set_a'
488
627
  elif state == 'update_x_set_a':
489
628
  if token.ttype == T.Operator.Comparison:
490
- state = 'update_x_set_a='
491
- elif state == 'update_x_set_a=':
629
+ state = 'update_x_set_a_op'
630
+ elif state == 'update_x_set_a_op':
492
631
  if token.ttype in [T.Literal.String.Single, T.Name]:
493
- state = 'update_x_set_a=v'
494
- elif state == 'update_x_set_a=v':
632
+ state = 'update_x_set_sc'
633
+ elif state == 'update_x_set_sc':
495
634
  if token.ttype == T.Punctuation and token.value == ',':
496
- state = 'update_x_set_a=v,'
635
+ state = 'update_x_set_sc,'
497
636
  elif token.ttype == T.Text.Whitespace:
498
- state = 'update_x_set_a=v_'
499
- elif state == 'update_x_set_a=v,':
637
+ state = 'update_x_set_sc_'
638
+ elif state == 'update_x_set_sc,':
500
639
  if token.ttype == T.Name:
501
640
  state = 'update_x_set_a'
502
- elif state == 'update_x_set_a=v_':
641
+ elif state == 'update_x_set_sc_':
503
642
  if token.ttype == T.Punctuation and token.value == ',':
504
- state = 'update_x_set_a=v,'
643
+ state = 'update_x_set_sc,'
505
644
  elif token.ttype == T.Keyword and token.value.lower() == 'where':
506
- state = 'update_x_set_a=v_where'
507
- elif state == 'update_x_set_a=v_where':
645
+ state = 'update_where'
646
+ elif state == 'update_where':
508
647
  if token.ttype == T.Text.Whitespace:
509
- state = 'update_x_set_a=v_where_'
510
- elif state == 'update_x_set_a=v_where_':
648
+ state = 'update_where_'
649
+ elif state == 'update_where_':
511
650
  if token.ttype == T.Name:
512
- state = 'update_x_set_a=v_where_id'
513
- elif state == 'update_x_set_a=v_where_id':
651
+ state = 'update_where_a'
652
+ elif state == 'update_where_a':
514
653
  if token.ttype == T.Operator.Comparison:
515
- state = 'update_x_set_a=v_where_id='
516
- elif state == 'update_x_set_a=v_where_id=':
654
+ state = 'update_where_a_op'
655
+ elif state == 'update_where_a_op':
517
656
  if token.ttype in [T.Literal.String.Single, T.Name]:
518
- state = 'update_x_set_a=v_where_id=v'
519
- elif state == 'update_x_set_a=v_where_id=v':
657
+ state = 'update_where_sc'
658
+ elif state == 'update_where_sc':
520
659
  if token.ttype == T.Text.Whitespace:
521
- state = 'update_x_set_a=v_where_id=v_'
522
- elif state == 'update_x_set_a=v_where_id=v_':
660
+ state = 'update_where_sc_'
661
+ elif state == 'update_where_sc_':
523
662
  if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
524
- state = 'update_x_set_a=v_where'
663
+ state = 'update_where'
525
664
 
526
665
  elif state == 'delete':
527
666
  if token.ttype == T.Text.Whitespace:
@@ -540,25 +679,25 @@ class SqlCompleter(Completer):
540
679
  state = 'delete_from_x_'
541
680
  elif state == 'delete_from_x_':
542
681
  if token.ttype == T.Keyword and token.value.lower() == 'where':
543
- state = 'delete_from_x_where'
544
- elif state == 'delete_from_x_where':
682
+ state = 'delete_where'
683
+ elif state == 'delete_where':
545
684
  if token.ttype == T.Text.Whitespace:
546
- state = 'delete_from_x_where_'
547
- elif state == 'delete_from_x_where_':
685
+ state = 'delete_where_'
686
+ elif state == 'delete_where_':
548
687
  if token.ttype == T.Name:
549
- state = 'delete_from_x_where_id'
550
- elif state == 'delete_from_x_where_id':
688
+ state = 'delete_where_a'
689
+ elif state == 'delete_where_a':
551
690
  if token.ttype == T.Operator.Comparison:
552
- state = 'delete_from_x_where_id='
553
- elif state == 'delete_from_x_where_id=':
691
+ state = 'delete_where_a_op'
692
+ elif state == 'delete_where_a_op':
554
693
  if token.ttype in [T.Literal.String.Single, T.Name]:
555
- state = 'delete_from_x_where_id=v'
556
- elif state == 'delete_from_x_where_id=v':
694
+ state = 'delete_where_sc'
695
+ elif state == 'delete_where_sc':
557
696
  if token.ttype == T.Text.Whitespace:
558
- state = 'delete_from_x_where_id=v_'
559
- elif state == 'delete_from_x_where_id=v_':
697
+ state = 'delete_where_sc_'
698
+ elif state == 'delete_where_sc_':
560
699
  if token.ttype == T.Keyword and token.value.lower() in ['and', 'or']:
561
- state = 'delete_from_x_where'
700
+ state = 'delete_where'
562
701
 
563
702
  return state
564
703
 
adam/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- __version__ = "2.0.56" #: the working version
4
+ __version__ = "2.0.57" #: the working version
5
5
  __release__ = "1.0.0" #: the release version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaqing
3
- Version: 2.0.56
3
+ Version: 2.0.57
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -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=_cSpSCO9CTcCYlbRGHCj0bLXdSaXLCYsyqeNu1RWB_s,139
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,7 +164,7 @@ 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=VMMM29z6AnUCYIM6VThdggFkiz8elQEI96EM8FO6RLo,31170
167
+ adam/sql/sql_completer.py,sha256=BAg1Ogn_q1JSjpQhN-2jVzIuMoH1FpFzn_xpMRvB-TQ,35882
168
168
  adam/sql/term_completer.py,sha256=VCCMPUzvh_9lwIOwqQmeijM0V2JPADkBbNV4HQIqDCw,2538
169
169
  adam/sso/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
170
170
  adam/sso/authenticator.py,sha256=BCm16L9zf5aLU47-sTCnudn2zLPwd8M2wwRminJfsqw,615
@@ -176,8 +176,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
176
176
  adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
177
177
  adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
178
178
  adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
179
- kaqing-2.0.56.dist-info/METADATA,sha256=50Y7sPo_HmrQyt5xK0N5IrJHVr-bikpprnZsuWjsLyo,132
180
- kaqing-2.0.56.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
181
- kaqing-2.0.56.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
182
- kaqing-2.0.56.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
183
- kaqing-2.0.56.dist-info/RECORD,,
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,,