Closed derekmahar closed 4 years ago
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 ( \
SELECT 1 \
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 >
Thank you for fixing this issue!
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 "())":