1
0
Fork 0

Fix a crash caused by leading space.

This commit is contained in:
Amjith Ramanujam 2014-11-28 22:27:18 -08:00
parent e20c6b487e
commit 60585c8856
3 changed files with 6 additions and 4 deletions

6
TODO
View File

@ -1,7 +1,7 @@
* [X] Add borders around the table.
* [] Investigate why having a space in the beginning of the line breaks everything.
* [ ] Investigate why having a space in the beginning of the line breaks everything.
* [ ] Add more complex slash commands such as \d <table_name>.
* [] Update README.
* [ ] Update README.
* [] Upload rev 2 to PyPI.
* [ ] Add a new trigger for M-/ that does dumb completion.
* [ ] Find a way to add documentation to sql commands. This could get tricky.
@ -16,7 +16,7 @@
* [] Create a better framework for adding special commands.
* A dict with special commands as keys.
* The value can either be a string or a callable.
* [] Test if the special comands are autocompleted correctly.
* [X] Test if the special comands are autocompleted correctly.
* [x] Control smart completion via config file.
* [x] Figure out how to deal with transactions.
* [X] Add a config file.

View File

@ -69,7 +69,8 @@ class PGCompleter(Completer):
last_token = ''
if parsed:
last_token = parsed[0].token_prev(len(parsed[0].tokens)).value
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'):

View File

@ -16,6 +16,7 @@ class PGExecute(object):
self.conn.autocommit = True
def run(self, sql):
sql = sql.strip()
with self.conn.cursor() as cur:
if sql in self.special_commands:
cur.execute(self.special_commands[sql])