You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pasting an SQL query containing open parentheses into the interactive shell, csvq automatically closes these parentheses, causing syntax errors.
For example, when pasting the following query into the interactive shell, csvq appends a trailing closing parenthesis.
WITH RECURSIVE t (n)
AS (
SELECT 1
UNION ALL
SELECT n + 1
FROM t
WHERE n < 5
)
SELECT n FROM t;
After pasting into interactive shell:
/home/derek > WITH RECURSIVE t (n))
[L:1 C:21] syntax error: unexpected token ")"
/home/derek > AS ()
[L:1 C:3] syntax error: unexpected token "AS"
/home/derek > SELECT 1
+---+
| 1 |
+---+
| 1 |
+---+
/home/derek > UNION ALL
[L:1 C:5] syntax error: unexpected token "UNION"
/home/derek > SELECT n + 1
[L:1 C:12] field n does not exist
/home/derek > FROM t
[L:1 C:7] syntax error: unexpected token "FROM"
/home/derek > WHERE n < 5
[L:1 C:6] syntax error: unexpected token "WHERE"
/home/derek > )
[L:1 C:3] syntax error: unexpected token ")"
/home/derek > SELECT n FROM t;
[L:1 C:15] file t does not exist
As a minimal example, notice that after pasting the string "()" into the interactive shell, csvq expands this string into "())":
/home/derek > ())
The text was updated successfully, but these errors were encountered:
derekmahar
changed the title
When pasting SQL query containing an open parenthesis into interactive shell, automatic closing of parentheses causes syntax error.
When pasting SQL query containing open parentheses into interactive shell, csvq automatically closes these parentheses, causing syntax errors.
Oct 30, 2019
Thanks.
The behavior of enclosures completion when pasting has been fixed.
However, even though the behavior has been fixed, pasting the code above will not execute correctly.
On the interactive shell, you must add a backslash at the end of the line for a line break.
In order to paste and execute, the code needs to be as follows.
WITH RECURSIVE t (n) \
AS ( \
SELECT1 \
UNION ALL \
SELECT n +1 \
FROM t \
WHERE n <5 \
) \
SELECT n FROM t;
This describing method depends on the external package github.com/chzyer/readline, and many console applications have similar limitations.
When executing a query that extends over multiple lines, I recommend to execute by writing the query in a file and loading it.
$ cat query.sql
WITH RECURSIVE t (n)
AS (
SELECT 1
UNION ALL
SELECT n + 1
FROM t
WHERE n < 5
)
SELECT n FROM t;
$ csvq -s query.sql
+---+
| n |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+---+
$ csvq
/home/mithrandie > SOURCE `query.sql`;
+---+
| n |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+---+
/home/mithrandie >
When pasting an SQL query containing open parentheses into the interactive shell,
csvq
automatically closes these parentheses, causing syntax errors.For example, when pasting the following query into the interactive shell,
csvq
appends a trailing closing parenthesis.After pasting into interactive shell:
As a minimal example, notice that after pasting the string "()" into the interactive shell,
csvq
expands this string into "())":The text was updated successfully, but these errors were encountered: