mirror of
https://github.com/dbcli/pgcli.git
synced 2024-08-17 01:30:30 +03:00
added support for ansi sql functions; added CASE, WHEN, FULL keywords; changed GROUP to GROUP BY
This commit is contained in:
parent
b3f4972e12
commit
2e73468148
3
.gitignore
vendored
3
.gitignore
vendored
@ -52,3 +52,6 @@ docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# PyCharm
|
||||
.idea/
|
@ -78,9 +78,10 @@ def suggest_type(full_text, text_before_cursor):
|
||||
last_token = parsed[0].token_prev(len(parsed[0].tokens))
|
||||
last_token = last_token.value if last_token else ''
|
||||
|
||||
if last_token.lower() in ('select', 'where', 'having', 'set',
|
||||
'order by', 'group by'):
|
||||
if last_token.lower() in ('set', 'order by', 'group by'):
|
||||
return ('columns', None)
|
||||
elif last_token.lower() in ('select', 'where', 'having'):
|
||||
return ('columns-and-functions', None)
|
||||
elif last_token.lower() in ('from', 'update', 'into', 'describe'):
|
||||
return ('tables', None)
|
||||
elif last_token in ('d',): # \d
|
||||
|
@ -4,11 +4,11 @@ from .packages.sqlcompletion import suggest_type
|
||||
|
||||
class PGCompleter(Completer):
|
||||
keywords = ['ACCESS', 'ADD', 'ALL', 'ALTER TABLE', 'AND', 'ANY', 'AS',
|
||||
'ASC', 'AUDIT', 'BETWEEN', 'BY', 'CHAR', 'CHECK', 'CLUSTER',
|
||||
'ASC', 'AUDIT', 'BETWEEN', 'BY', 'CASE', 'CHAR', 'CHECK', 'CLUSTER',
|
||||
'COLUMN', 'COMMENT', 'COMPRESS', 'CONNECT', 'CREATE', 'CURRENT',
|
||||
'DATE', 'DECIMAL', 'DEFAULT', 'DELETE FROM', 'DESC', 'DESCRIBE',
|
||||
'DISTINCT', 'DROP', 'ELSE', 'EXCLUSIVE', 'EXISTS', 'FILE', 'FLOAT',
|
||||
'FOR', 'FROM', 'GRANT', 'GROUP', 'HAVING', 'IDENTIFIED',
|
||||
'FOR', 'FROM', 'FULL', 'GRANT', 'GROUP BY', 'HAVING', 'IDENTIFIED',
|
||||
'IMMEDIATE', 'IN', 'INCREMENT', 'INDEX', 'INITIAL', 'INSERT INTO',
|
||||
'INTEGER', 'INTERSECT', 'INTO', 'IS', 'LEVEL', 'LIKE', 'LOCK',
|
||||
'LONG', 'MAXEXTENTS', 'MINUS', 'MLSLABEL', 'MODE', 'MODIFY',
|
||||
@ -19,7 +19,11 @@ class PGCompleter(Completer):
|
||||
'SET', 'SHARE', 'SIZE', 'SMALLINT', 'START', 'SUCCESSFUL',
|
||||
'SYNONYM', 'SYSDATE', 'TABLE', 'THEN', 'TO', 'TRIGGER', 'UID',
|
||||
'UNION', 'UNIQUE', 'UPDATE', 'USE', 'USER', 'VALIDATE', 'VALUES',
|
||||
'VARCHAR', 'VARCHAR2', 'VIEW', 'WHENEVER', 'WHERE', 'WITH', ]
|
||||
'VARCHAR', 'VARCHAR2', 'VIEW', 'WHEN', 'WHENEVER', 'WHERE', 'WITH', ]
|
||||
|
||||
functions = ['AVG', 'COUNT', 'DISTINCT', 'FIRST', 'FORMAT', 'LAST', 'LCASE',
|
||||
'LEN', 'MAX', 'MIN', 'MID', 'NOW', 'ROUND', 'SUM', 'TOP',
|
||||
'UCASE']
|
||||
|
||||
special_commands = []
|
||||
|
||||
@ -77,6 +81,9 @@ class PGCompleter(Completer):
|
||||
|
||||
if category == 'columns':
|
||||
return self.find_matches(word_before_cursor, self.columns)
|
||||
elif category == 'columns-and-functions':
|
||||
return self.find_matches(word_before_cursor, self.columns +
|
||||
self.functions)
|
||||
elif category == 'tables':
|
||||
return self.find_matches(word_before_cursor, self.tables)
|
||||
elif category == 'databases':
|
||||
|
Loading…
Reference in New Issue
Block a user