Documentation
¶
Overview ¶
Package sqlguard classifies SQL statements so callers can enforce read-only access. It is intentionally small and dependency-free: the root filesql package owns the public database/sql wrappers, and this package holds only the statement-inspection logic they rely on, keeping that concern out of the already-large root package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWrite ¶
IsWrite reports whether the SQL statement performs a write.
It is intentionally conservative: a statement is rejected if a write keyword appears anywhere at the top level, so writes cannot be smuggled past a read-only API through SQL comments, common table expressions (WITH ... DELETE) or a RETURNING clause executed via Query/QueryRow. Keywords inside string literals, quoted identifiers, comments or parenthesized subqueries are ignored to avoid rejecting legitimate SELECTs.
An assigning PRAGMA (e.g. "PRAGMA foreign_keys = ON") is also treated as a write because it changes connection/database state, while a reading PRAGMA such as "PRAGMA table_info(users)" or "PRAGMA foreign_keys" is allowed.
Types ¶
This section is empty.