Skip to content

Commit

Permalink
sling_conns.go: unlock insert into select * from. previous this que…
Browse files Browse the repository at this point in the history
…ry did not work well in clickhouse/protondb, because grammer.

```
./sling conns exec CLICKHOUSE "insert into his_v select * from v"
fatal:
~ SQL Error for:
select * from (
  insert into his_v select * from v
) as t limit 100
code: 62, message: Syntax error: failed at position 19 ('insert') (line 2, col 3): insert into his_v select * from v
) as t limit 100. Expected one of: SELECT query, possibly with UNION, list of union elements, SELECT query, subquery, possibly with UNION, SELECT subquery, SELECT query, WITH, FROM, SELECT, EXPLAIN, EXPLAIN

```
  • Loading branch information
yokofly committed Sep 25, 2024
1 parent 4dd615f commit 99c5c1d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/sling/sling_conns.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func processConns(c *g.CliSC) (ok bool, err error) {
return ok, g.Error(err, "cannot parse query")
}

if len(database.ParseSQLMultiStatements(query)) == 1 && (!sQuery.IsQuery() || strings.Contains(strings.ToLower(query), "select") || g.In(conn.Connection.Type, dbio.TypeDbPrometheus, dbio.TypeDbMongoDB)) {
if len(database.ParseSQLMultiStatements(query)) == 1 && (!sQuery.IsQuery() || (strings.Contains(strings.ToLower(query), "select") && !strings.Contains(strings.ToLower(query), "insert")) || g.In(conn.Connection.Type, dbio.TypeDbPrometheus, dbio.TypeDbMongoDB)) {

data, err := dbConn.Query(sQuery.Select(100, 0))
if err != nil {
Expand Down

0 comments on commit 99c5c1d

Please sign in to comment.