ValidateSQLForEditor validates that every statement in the SQL is a read-only SELECT (no SELECT INTO). Returns (valid, allAlike, err). For MSSQL the two booleans move together — we reject on the first non-SELECT.
(statement string)
| 15 | // SELECT (no SELECT INTO). Returns (valid, allAlike, err). For MSSQL the two |
| 16 | // booleans move together — we reject on the first non-SELECT. |
| 17 | func ValidateSQLForEditor(statement string) (bool, bool, error) { |
| 18 | stmts, err := ParseTSQLOmni(statement) |
| 19 | if err != nil { |
| 20 | return false, false, err |
| 21 | } |
| 22 | if len(stmts) == 0 { |
| 23 | return false, false, nil |
| 24 | } |
| 25 | |
| 26 | for _, s := range stmts { |
| 27 | if s.Empty() { |
| 28 | continue |
| 29 | } |
| 30 | if !isReadOnlySelect(s.AST) { |
| 31 | return false, false, nil |
| 32 | } |
| 33 | } |
| 34 | return true, true, nil |
| 35 | } |
| 36 | |
| 37 | // isReadOnlySelect returns true for SELECT statements without an INTO target. |
| 38 | // Non-SELECT nodes and SELECT ... INTO are rejected — INTO materialises a new |
nothing calls this directly
no test coverage detected