quote

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: BSD-2-Clause Imports: 2 Imported by: 17

Documentation

Overview

Package quote augments SQL strings by quoting identifiers according to three common variants: back-ticks used by MySQL, double-quotes used in ANSI SQL (PostgreSQL etc), or no quotes at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Quoter

type Quoter interface {
	Quote(identifier string) string
	QuoteN(identifiers []string) []string
	QuoteW(w io.StringWriter, identifier string) (n int, err error)
}

Quoter wraps identifiers in quote marks. Compound identifiers (i.e. those with an alias prefix) are handled according to SQL grammar.

var (
	// AnsiQuoter wraps identifiers in double quotes.
	AnsiQuoter Quoter = ansiQuoter

	// MySqlQuoter wraps identifiers in back-ticks.
	MySqlQuoter Quoter = mySqlQuoter

	// NoQuoter leaves identifiers unquoted.
	NoQuoter Quoter = noQuoter

	// DefaultQuoter is used by default.
	//
	// Change this to affect the default setting for every SQL construction function.
	DefaultQuoter = AnsiQuoter
)

func NewQuoter

func NewQuoter(mark string) Quoter

NewQuoter gets a quoter using arbitrary quote marks.

func PickQuoter added in v0.8.0

func PickQuoter(name string) Quoter

PickQuoter picks a quoter based on the names "ansi", "mysql" or "none". If none match, then nil is returned.

Jump to

Keyboard shortcuts

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