Documentation
¶
Index ¶
Constants ¶
const DefaultMaxRows = 1000
DefaultMaxRows caps query results unless overridden by WithMaxRows.
const Name = "sql"
Name is the library identifier and the global binding installed into the runtime.
Variables ¶
var ( // ErrExecuteDisabled is thrown into the script when sql.execute is called on a // library built without WithExecute. ErrExecuteDisabled = errors.New("jssql: execute disabled") // ErrQueryNotReadOnly is thrown into the script when sql.queryList receives a // statement the read-only guard rejects: a non-read statement, a // data-modifying CTE, a dialect-specific side-effecting function, or SQL // the parser cannot understand (the guard fails closed). ErrQueryNotReadOnly = errors.New("jssql: statement is not read-only") // ErrTooManyRows is thrown into the script when a query yields more rows // than the configured limit. ErrTooManyRows = errors.New("jssql: result exceeds row limit") )
Functions ¶
func New ¶
New builds the sql library over db. The caller picks the data source — typically the primary orm.DB, or a specific one taken from datasource.Registry — and thereby decides what the scripts can reach. kind is the dialect of db, used by the read-only guard to select the dialect's side-effecting-function denylist.
Types ¶
type Option ¶
type Option func(*libConfig)
Option customizes the sql library.
func WithExecute ¶
func WithExecute() Option
WithExecute enables sql.execute for mutating statements. Without it the library is read-only and execute throws ErrExecuteDisabled.
func WithMaxRows ¶
WithMaxRows caps the number of rows a query may return; exceeding the cap fails the query instead of silently truncating the result.