mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
add test
fix fix fix
This commit is contained in:
parent
1438fd20cb
commit
d208013161
@ -155,9 +155,26 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
|
||||
std::cout << "\n;\n";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/// skip spaces to avoid throw exception after last query
|
||||
while (pos != end && std::isspace(*pos))
|
||||
++pos;
|
||||
|
||||
/// for skip comment after the last query and to not throw exception
|
||||
if (end - pos > 2 && *pos == '-' && *(pos + 1) == '-')
|
||||
{
|
||||
pos += 2;
|
||||
/// skip until the end of the line
|
||||
while (pos != end && *pos != '\n')
|
||||
++pos;
|
||||
}
|
||||
/// need to parse next sql
|
||||
else
|
||||
break;
|
||||
} while (pos != end);
|
||||
|
||||
} while (multiple && pos != end);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
SELECT 1
|
||||
;
|
||||
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
(
|
||||
SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
)
|
||||
;
|
||||
|
||||
SELECT 1
|
||||
;
|
||||
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
(
|
||||
SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
)
|
||||
;
|
||||
|
||||
OK
|
11
tests/queries/0_stateless/01753_fix_clickhouse_format.sh
Executable file
11
tests/queries/0_stateless/01753_fix_clickhouse_format.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
echo "select 1; select 1 union all (select 1 union distinct select 1); " | $CLICKHOUSE_FORMAT -n;
|
||||
|
||||
echo "select 1; select 1 union all (select 1 union distinct select 1); -- comment " | $CLICKHOUSE_FORMAT -n;
|
||||
|
||||
echo "insert into t values (1); " | $CLICKHOUSE_FORMAT -n 2>&1 \ | grep -F -q "Code: 1004" && echo 'OK' || echo 'FAIL'
|
Loading…
Reference in New Issue
Block a user