MCPcopy Create free account
hub / github.com/sipcapture/homer / shouldUseSQLQuery

Function shouldUseSQLQuery

src/node/node.go:285–306  ·  view source on GitHub ↗

shouldUseSQLQuery returns true for statements that return row sets and must use QueryContext. INSERT/UPDATE/DELETE without RETURNING should use ExecContext so DuckDB applies mutations reliably (Query-only INSERTs could be invisible to subsequent SELECTs on some paths).

(sql string)

Source from the content-addressed store, hash-verified

283// so DuckDB applies mutations reliably (Query-only INSERTs could be invisible
284// to subsequent SELECTs on some paths).
285func shouldUseSQLQuery(sql string) bool {
286 u := strings.TrimSpace(strings.ToUpper(sql))
287 if strings.Contains(u, "RETURNING") {
288 return true
289 }
290 switch {
291 case strings.HasPrefix(u, "SELECT"):
292 return true
293 case strings.HasPrefix(u, "WITH"):
294 return true
295 case strings.HasPrefix(u, "SHOW"):
296 return true
297 case strings.HasPrefix(u, "DESCRIBE"):
298 return true
299 case strings.HasPrefix(u, "PRAGMA"):
300 return true
301 case strings.HasPrefix(u, "EXPLAIN"):
302 return true
303 default:
304 return false
305 }
306}
307
308func sqlStringLiteral(value string) string {
309 escaped := strings.ReplaceAll(value, "'", "''")

Callers 1

handleQueryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected