sqlscan

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sqlscan tokenizes raw SQL fragments into verbatim text and placeholders. It knows string literals, quoted identifiers, comments and PostgreSQL dollar quotes per dialect, and imports nothing from the momo root package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind uint8

Kind classifies a Tok.

const (
	Text   Kind = iota // copied verbatim
	Param              // a positional '?'
	Named              // an @name; Text is the name
	Dollar             // a native $n; Text is the digits
)

type Tok

type Tok struct {
	Kind Kind
	Text string
}

Tok is one token of a scanned fragment.

func Scan

func Scan(sql string, d *dialect.Dialect) (toks []Tok, err error)

Scan splits sql into verbatim text and placeholders. A '?' or '@name' inside a string literal, quoted identifier, comment or PostgreSQL dollar-quoted string is text, as are the PostgreSQL operators ?| ?& @? @@ and @>. "??" yields a literal '?'. A native $n outside those is a Dollar token on every dialect, so the caller can bind it on PostgreSQL and reject it elsewhere.

Jump to

Keyboard shortcuts

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