Documentation
¶
Index ¶
- func Dialect() core.Option
- func NewCatalog() *catalog.Catalog
- type Parser
- func (p *Parser) Cast(arg, typeName string) string
- func (p *Parser) CommentSyntax() source.CommentSyntax
- func (p *Parser) Fingerprint(sql string) (string, error)
- func (p *Parser) IsReservedKeyword(s string) bool
- func (p *Parser) Param(n int, numbered bool) string
- func (p *Parser) Parse(r io.Reader) ([]ast.Statement, error)
- func (p *Parser) ParseFile(r io.Reader) (*ast.File, error)
- func (p *Parser) QuoteIdent(s string) string
- func (p *Parser) TypeName(ns, name string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCatalog ¶
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewFormatParser ¶
func NewFormatParser() *Parser
NewFormatParser returns the parser sqlc fmt uses. It differs from the compiler's parser in one way: identifiers keep the case the author wrote. The compiler lowercases them so catalog lookups are case-insensitive, but a formatter that prints `Event` as `event` renames a table on the many servers where table names are case-sensitive.
func (*Parser) CommentSyntax ¶
func (p *Parser) CommentSyntax() source.CommentSyntax
func (*Parser) Fingerprint ¶
Fingerprint reduces a statement to a canonical form that survives changes in whitespace, keyword case, quoting style and redundant parentheses — and nothing else. Identifier case is preserved: MySQL table names are case-sensitive on most servers, so a formatting pass that changes one is a semantic change and must not fingerprint equal. fmt uses this as its proof that a formatted statement still means what the author wrote; a statement whose fingerprint it cannot match is left exactly as written.
func (*Parser) IsReservedKeyword ¶
func (*Parser) Param ¶
Param returns the parameter placeholder for the given number. MySQL uses ? for all parameters (positional).
func (*Parser) ParseFile ¶
ParseFile parses like Parse and also carries the file's comments, which marino's lexer records as it scans.
func (*Parser) QuoteIdent ¶
QuoteIdent returns a quoted identifier if it needs quoting. MySQL uses backticks for quoting identifiers.