Documentation ¶
Overview ¶
Package quote augments SQL strings by quoting identifiers according to four common variants:
- back-ticks used by MySQL,
- double-quotes used in ANSI SQL (PostgreSQL etc),
- square brackets used by SQLServer, or
- no quotes at all.
For prefixed identifiers containing a dot ('.'), the quote marks are applied separately to the prefix(es) and the identifier itself.
Quoting is only applied where a column name is clear (as in the 'where' package). There isn't a general syntax analyser that somehow fixes up arbitrary SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // None leaves identifiers unchanged. None = none // ANSI wraps identifiers in double-quote marks. For PostgreSQL etc. ANSI = quoter{/* contains filtered or unexported fields */} // Backticks wraps identifies in back-ticks. For MySql etc. Backticks = quoter{/* contains filtered or unexported fields */} // SquareBrackets wraps identifies in '[' and ']'. For MS SQL/SQL-Server. SquareBrackets = quoter{/* contains filtered or unexported fields */} )
View Source
var ( // DefaultQuoter does not change identifiers and is used by default. // Change this to affect the default setting for every SQL construction function. DefaultQuoter = none )
Functions ¶
This section is empty.
Types ¶
type Quoter ¶
type Quoter interface { // Quote renders an identifier within quote marks. If the identifier consists of both a // prefix and a name, each part is quoted separately. Any i/o errors are silently dropped. Quote(identifier string) string // QuoteW renders an identifier within quote marks. If the identifier consists of one or more // prefixes and a name, each part is quoted separately. This may give better performance // than Quote. QuoteW(w io.StringWriter, identifier string) }
Quoter wraps identifiers in quote marks. Compound identifiers, i.e. those with an alias prefix such as "excluded"."created_at", are handled according to SQL grammar.
Click to show internal directories.
Click to hide internal directories.