@@ -28,32 +28,28 @@ def suggest_type(full_text, text_before_cursor):
2828
2929 identifier = None
3030
31- # This is a temporary hack; the exception handling
32- # here should be removed once sqlparse has been fixed
33- try :
34- # If we've partially typed a word then word_before_cursor won't be an empty
35- # string. In that case we want to remove the partially typed string before
36- # sending it to the sqlparser. Otherwise the last token will always be the
37- # partially typed string which renders the smart completion useless because
38- # it will always return the list of keywords as completion.
39- if word_before_cursor :
40- if word_before_cursor [- 1 ] == '(' or word_before_cursor [0 ] == '\\ ' :
41- parsed = sqlparse .parse (text_before_cursor )
42- else :
43- parsed = sqlparse .parse (
44- text_before_cursor [:- len (word_before_cursor )])
31+ # If we've partially typed a word then word_before_cursor won't be an empty
32+ # string. In that case we want to remove the partially typed string before
33+ # sending it to the sqlparser. Otherwise the last token will always be the
34+ # partially typed string which renders the smart completion useless because
35+ # it will always return the list of keywords as completion.
36+ if word_before_cursor :
37+ if word_before_cursor .endswith (
38+ '(' ) or word_before_cursor .startswith ('\\ ' ):
39+ parsed = sqlparse .parse (text_before_cursor )
40+ else :
41+ parsed = sqlparse .parse (
42+ text_before_cursor [:- len (word_before_cursor )])
4543
46- # word_before_cursor may include a schema qualification, like
47- # "schema_name.partial_name" or "schema_name.", so parse it
48- # separately
49- p = sqlparse .parse (word_before_cursor )[0 ]
44+ # word_before_cursor may include a schema qualification, like
45+ # "schema_name.partial_name" or "schema_name.", so parse it
46+ # separately
47+ p = sqlparse .parse (word_before_cursor )[0 ]
5048
51- if p .tokens and isinstance (p .tokens [0 ], Identifier ):
52- identifier = p .tokens [0 ]
53- else :
54- parsed = sqlparse .parse (text_before_cursor )
55- except (TypeError , AttributeError ):
56- return []
49+ if p .tokens and isinstance (p .tokens [0 ], Identifier ):
50+ identifier = p .tokens [0 ]
51+ else :
52+ parsed = sqlparse .parse (text_before_cursor )
5753
5854 if len (parsed ) > 1 :
5955 # Multiple statements being edited -- isolate the current one by
0 commit comments