parse

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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.

Jump to

Keyboard shortcuts

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