tursodatabase / libsql-shell-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Line comments are not fully ignored, causes errors (incompatible with sqlite3)

CodingDoug opened this issue · comments

Interactively

This works interactively, because the last line ends with a statement:

→  -- foo
... select 1;
1
1

If you enter only a comment, you can see above that it continues to try to get input as if it were a continuation of an incomplete statement. It should just ignore the comment line entirely as if it were an empty line. sqlite3 handles it this way.

If a statement ends with a line comment on the same line, it continues to ask for input until it sees another statement ending with a semi (here I just force terminate the statement with a lone semi):

→  select 1; --asdf
... ;
1
1
Error: failed to execute statement

Instead, it should ignore the trailing comment entirely and just execute the prior statement with no further input. The same problem occurs if the same input comes from stdin.

stdin

In a script from stdin, leading comments have no effect, and everything is OK only if the input ends with a statement:

echo "\
-- foo
select 1;
" | turso db shell http://127.0.0.1:8080
1
1

However, a trailing comment causes an (unhelpful) error:

echo "\
select 1;
-- foo
"  | turso db shell http://127.0.0.1:8080
1
1
Error: failed to execute statement

Again, I think lines with only comments should be ignored entirely and not affect the processing of the input, no matter where they occur. Comment lines interleaved between statements are OK, it's just trailing comments that don't work. sqlite3 doesn't have this problem.

See also #133