sqlguard

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func IsWrite(query string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL