dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.12k stars 68 forks source link

Remove the double-quote escaping from the INSERT statement in .import… #80

Closed amjith closed 4 years ago

amjith commented 4 years ago

… special command.

Description

While testing the PR #79 I ran into an edge case where if I escaped the table name such as

:memory:> create table temp (name text, id integer);
:memory:> .import ./import_data.csv `temp`

It would throw an error saying that table not found. This change fixes that edge case.

amjith commented 4 years ago

I've also discovered another edge case. When I start to type .import ". As soon as I open a double-quote the CLI throws an exception.


Unhandled exception in event loop:
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/eventloop
/coroutine.py", line 92, in step_next
    new_f = coroutine.throw(exc)
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/buffer.py
", line 1654, in new_coroutine
    yield From(coroutine(*a, **kw))
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/eventloop
/coroutine.py", line 92, in step_next
    new_f = coroutine.throw(exc)
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/buffer.py
", line 1506, in async_completer
    cancel=lambda: not proceed()))
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/eventloop
/coroutine.py", line 88, in step_next
    new_f = coroutine.send(None)
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/eventloop
/async_generator.py", line 117, in consume_async_generator
    item = iterator.send(send)
  File "/home/amjith/.virtualenvs/litecli/lib/python3.7/site-packages/prompt_toolkit/completio
n/base.py", line 176, in get_completions_async
    for item in self.get_completions(document, complete_event):
  File "/home/amjith/Dropbox/code/python/litecli/litecli/sqlcompleter.py", line 446, in get_co
mpletions
    suggestions = suggest_type(document.text, document.text_before_cursor)
  File "/home/amjith/Dropbox/code/python/litecli/litecli/packages/completion_engine.py", line
86, in suggest_type
    return suggest_special(text_before_cursor)
  File "/home/amjith/Dropbox/code/python/litecli/litecli/packages/completion_engine.py", line
126, in suggest_special
    if _expecting_arg_idx(arg, text) == 1:
  File "/home/amjith/Dropbox/code/python/litecli/litecli/packages/completion_engine.py", line
146, in _expecting_arg_idx
    args = shlex.split(arg)
  File "/usr/lib/python3.7/shlex.py", line 309, in split
    return list(lex)
  File "/usr/lib/python3.7/shlex.py", line 299, in __next__
    token = self.get_token()
  File "/usr/lib/python3.7/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.7/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")

Exception No closing quotation
zzl0 commented 4 years ago

Yes, I also noticed that when I was testing "keyword" and `keyword`, I had a fix, I will published it tonight.