eval

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package eval adds an eval() scalar function that runs dynamic SQL on the calling connection and returns the result as text — sqlean's distinctive "SQL from SQL" capability, which no other pure-Go SQLite driver exposes.

eval(sql)         -- run sql, return its result values concatenated
eval(sql, sep)    -- ...joined by sep (default '')

Example:

SELECT eval('SELECT 6 * 7');                 -- '42'
SELECT eval('SELECT name FROM t', ', ');     -- 'alice, bob, carol'
SELECT eval('CREATE TABLE log(msg)');        -- '' (no output, side effect applied)

The SQL runs on the same connection (a re-entrant prepared statement, the proven pattern ext/statement uses), so it sees the same tables, pragmas, and transaction. One statement per call.

Trust boundary

eval() executes arbitrary SQL. Never pass untrusted input to it — treat it exactly like building a query by string concatenation. It is not registered by default for that reason; opt in explicitly per connection or via the auto sub-package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(c *sqlite.Conn) error

Register installs eval() on c, closing over c so the dynamic SQL runs on this connection.

Per-connection registration. For pool-wide install, blank-import the auto sub-package:

import _ "gosqlite.org/ext/eval/auto"

Types

This section is empty.

Directories

Path Synopsis
Package auto wires the eval() function via a sqlite.Driver.ConnectHook so every new connection registers it.
Package auto wires the eval() function via a sqlite.Driver.ConnectHook so every new connection registers it.

Jump to

Keyboard shortcuts

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