mirror of https://github.com/dbcli/pgcli
Add completion for COPY command.
This commit is contained in:
parent
d159f0d474
commit
b6cf4cb855
|
@ -1,12 +1,16 @@
|
|||
Current
|
||||
=======
|
||||
|
||||
Features:
|
||||
---------
|
||||
* Add syntax color styles to config.
|
||||
* Add auto-completion for COPY statements.
|
||||
|
||||
Bug Fixes:
|
||||
----------
|
||||
* Treat boolean values as strings instead of ints.
|
||||
* Make \di, \dv and \dt to be schema aware. (Thanks: darikg_)
|
||||
|
||||
|
||||
0.14.0
|
||||
======
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ def extract_from_part(parsed, stop_at_punctuation=True):
|
|||
else:
|
||||
yield item
|
||||
elif ((item.ttype is Keyword or item.ttype is Keyword.DML) and
|
||||
item.value.upper() in ('FROM', 'INTO', 'UPDATE', 'TABLE', 'JOIN',)):
|
||||
item.value.upper() in ('COPY', 'FROM', 'INTO', 'UPDATE', 'TABLE', 'JOIN',)):
|
||||
tbl_prefix_seen = True
|
||||
# 'SELECT a, FROM abc' will detect FROM as part of the column list.
|
||||
# So this check here is necessary.
|
||||
|
|
|
@ -85,7 +85,8 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text):
|
|||
if p.token_first().value.lower() == 'select':
|
||||
# If the lparen is preceeded by a space chances are we're about to
|
||||
# do a sub-select.
|
||||
if last_word(text_before_cursor, 'all_punctuations').startswith('('):
|
||||
if last_word(text_before_cursor,
|
||||
'all_punctuations').startswith('('):
|
||||
return [{'type': 'keyword'}]
|
||||
|
||||
return [{'type': 'column', 'tables': extract_tables(full_text)}]
|
||||
|
@ -95,7 +96,8 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text):
|
|||
elif token_v.lower() in ('select', 'where', 'having'):
|
||||
return [{'type': 'column', 'tables': extract_tables(full_text)},
|
||||
{'type': 'function'}]
|
||||
elif token_v.lower() in ('from', 'update', 'into', 'describe', 'join', 'table'):
|
||||
elif token_v.lower() in ('copy', 'from', 'update', 'into', 'describe',
|
||||
'join', 'table'):
|
||||
return [{'type': 'schema'}, {'type': 'table', 'schema': []}]
|
||||
elif token_v.lower() == 'on':
|
||||
tables = extract_tables(full_text) # [(schema, table, alias), ...]
|
||||
|
|
|
@ -11,19 +11,19 @@ _logger = logging.getLogger(__name__)
|
|||
class PGCompleter(Completer):
|
||||
keywords = ['ACCESS', 'ADD', 'ALL', 'ALTER TABLE', 'AND', 'ANY', 'AS',
|
||||
'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', 'FULL', 'GRANT', 'GROUP BY',
|
||||
'HAVING', 'IDENTIFIED', 'IMMEDIATE', 'IN', 'INCREMENT', 'INDEX',
|
||||
'INITIAL', 'INSERT INTO', 'INTEGER', 'INTERSECT', 'INTO', 'IS',
|
||||
'JOIN', 'LEFT', 'LEVEL', 'LIKE', 'LIMIT', 'LOCK', 'LONG',
|
||||
'CLUSTER', 'COLUMN', 'COMMENT', 'COMPRESS', 'CONNECT', 'COPY',
|
||||
'CREATE', 'CURRENT', 'DATE', 'DECIMAL', 'DEFAULT', 'DELETE FROM',
|
||||
'DESC', 'DESCRIBE', 'DISTINCT', 'DROP', 'ELSE', 'EXCLUSIVE',
|
||||
'EXISTS', 'FILE', 'FLOAT', 'FOR', 'FROM', 'FULL', 'GRANT',
|
||||
'GROUP BY', 'HAVING', 'IDENTIFIED', 'IMMEDIATE', 'IN', 'INCREMENT',
|
||||
'INDEX', 'INITIAL', 'INSERT INTO', 'INTEGER', 'INTERSECT', 'INTO',
|
||||
'IS', 'JOIN', 'LEFT', 'LEVEL', 'LIKE', 'LIMIT', 'LOCK', 'LONG',
|
||||
'MAXEXTENTS', 'MINUS', 'MLSLABEL', 'MODE', 'MODIFY', 'NOAUDIT',
|
||||
'NOCOMPRESS', 'NOT', 'NOWAIT', 'NULL', 'NUMBER', 'OF', 'OFFLINE',
|
||||
'ON', 'ONLINE', 'OPTION', 'OR', 'ORDER BY', 'OUTER', 'PCTFREE',
|
||||
'PRIMARY', 'PRIOR', 'PRIVILEGES', 'RAW', 'RENAME',
|
||||
'RESOURCE', 'REVOKE', 'RIGHT', 'ROW', 'ROWID', 'ROWNUM', 'ROWS',
|
||||
'SELECT', 'SESSION', 'SET', 'SHARE', 'SIZE', 'SMALLINT', 'START',
|
||||
'PRIMARY', 'PRIOR', 'PRIVILEGES', 'RAW', 'RENAME', 'RESOURCE',
|
||||
'REVOKE', 'RIGHT', 'ROW', 'ROWID', 'ROWNUM', 'ROWS', 'SELECT',
|
||||
'SESSION', 'SET', 'SHARE', 'SIZE', 'SMALLINT', 'START',
|
||||
'SUCCESSFUL', 'SYNONYM', 'SYSDATE', 'TABLE', 'THEN', 'TO',
|
||||
'TRIGGER', 'UID', 'UNION', 'UNIQUE', 'UPDATE', 'USE', 'USER',
|
||||
'VALIDATE', 'VALUES', 'VARCHAR', 'VARCHAR2', 'VIEW', 'WHEN',
|
||||
|
|
Loading…
Reference in New Issue