package parse

import "github.com/vertica/vertica-sql-go/parse"

Index

Functions

func Lex

func Lex(query string, options ...LexOption) string

Lex through a given query, optionally substituting some values in the string

Types

type LexOption

type LexOption func(*Lexer)

LexOption is a function that sets a preference on the lexer

func LexOptions

func LexOptions(opts ...LexOption) LexOption

LexOptions converts an aritrary number of options into one function for easier handling

func WithNamedCallback

func WithNamedCallback(cb OnNamedParam) LexOption

WithNamedCallback sets the optional named parameter callback

func WithPositionalSubstitution

func WithPositionalSubstitution(cb SubstitutePosParam) LexOption

WithPositionalSubstitution sets the optional positional substitution callback

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer loosely breaks a SQL query down into chunks that the Vertica package cares about, offering opportunities for substitution.

type OnNamedParam

type OnNamedParam func(name string)

OnNamedParam is called when a value such as @queryParam is encountered. This can be used to associate a placeholder in the SQL to an index. The placeholders are encountered in the order they appear in the string.

type SubstitutePosParam

type SubstitutePosParam func() string

SubstitutePosParam is called by the lexer when a '?' rune is encountered outside a string. The return value is substituted for the placeholder. This can be used to emulate server side binding but should be done with extreme caution due to the risk of SQL injection.

Source Files

queryLex.go

Version
v1.1.0
Published
May 2, 2020
Platform
windows/amd64
Imports
3 packages
Last checked
3 hours ago

Tools for package owners.