sqlbind

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sqlbind writes one query with numbered placeholders ($1, $2, …) for every dialect, so tanGO's own raw SQL (migrations, tests) does not have to be duplicated per placeholder style.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rebind

func Rebind(query string, numbered bool) string

Rebind returns query ready for a dialect whose placeholders are numbered (numbered true: the query is returned unchanged) or positional ("?"). Outside quoted string literals and identifiers each $N becomes "?", which is only meaningful when the placeholders appear once each, in order 1, 2, 3, …: anything else panics, since silently rebinding would change which argument goes where. RebindArgs handles a query that reuses or reorders them.

func RebindArgs

func RebindArgs(query string) (rewritten string, order []int)

RebindArgs rewrites query for a positional dialect like Rebind and also returns which numbered argument each "?" takes, 1-indexed, in order: a query that uses $1 twice returns order [1 …, 1]. A query with no numbered placeholders returns a nil order, meaning the arguments are used as given.

Types

This section is empty.

Jump to

Keyboard shortcuts

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