rules

package
v0.0.1-0...-4535bed Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: PostgreSQL Imports: 5 Imported by: 0

Documentation

Overview

Package rules holds common rewrite rules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMissingArgument

type AddMissingArgument struct {
	Function string
	Position int // 0-based position of argument in call args list
	Value    ast.Node
}

func (AddMissingArgument) Match

func (r AddMissingArgument) Match(n ast.Node) bool

func (AddMissingArgument) Rewrite

func (r AddMissingArgument) Rewrite(n ast.Node) (ast.Node, error)

func (AddMissingArgument) String

func (r AddMissingArgument) String() string

type CallKeyword

type CallKeyword struct{}

CallKeyword protects call on keywords from identifier quoting.

Postgres parses some builtin functions as Keyword like COALESCE, CAST, etc. This rules protect these call from token rules. You should put this rule at end of the rule set.

func (CallKeyword) Match

func (CallKeyword) Match(n ast.Node) bool

func (CallKeyword) Rewrite

func (CallKeyword) Rewrite(n ast.Node) (ast.Node, error)

func (CallKeyword) String

func (CallKeyword) String() string

type QuoteBuiltins

type QuoteBuiltins struct{}

QuoteBuiltins protects Postgres builtin functions case.

func (QuoteBuiltins) Match

func (QuoteBuiltins) Match(n ast.Node) bool

func (QuoteBuiltins) Rewrite

func (QuoteBuiltins) Rewrite(n ast.Node) (ast.Node, error)

func (QuoteBuiltins) String

func (QuoteBuiltins) String() string

type RemoveLastArgument

type RemoveLastArgument struct {
	Function string
	Position int // 0-based position of argument in call args list
}

func (RemoveLastArgument) Match

func (r RemoveLastArgument) Match(n ast.Node) bool

func (RemoveLastArgument) Rewrite

func (r RemoveLastArgument) Rewrite(n ast.Node) (ast.Node, error)

func (RemoveLastArgument) String

func (r RemoveLastArgument) String() string

type RenameConstant

type RenameConstant struct {
	From, To string
}

func (RenameConstant) Match

func (r RenameConstant) Match(n ast.Node) bool

func (RenameConstant) Rewrite

func (r RenameConstant) Rewrite(n ast.Node) (ast.Node, error)

func (RenameConstant) String

func (r RenameConstant) String() string

type RenameFunction

type RenameFunction struct {
	// From must be lower cased as lexer.Token.Normalize() lowers identifier.
	From, To string
}

func (RenameFunction) Match

func (r RenameFunction) Match(n ast.Node) bool

func (RenameFunction) Rewrite

func (r RenameFunction) Rewrite(n ast.Node) (ast.Node, error)

func (RenameFunction) String

func (r RenameFunction) String() string

type ReplaceOperator

type ReplaceOperator struct {
	// From must be UPPER cased as lexer.Token.Normalize() uppers keywords.
	From, To []string
}

func (ReplaceOperator) Match

func (r ReplaceOperator) Match(n ast.Node) bool

func (ReplaceOperator) Rewrite

func (r ReplaceOperator) Rewrite(n ast.Node) (ast.Node, error)

func (ReplaceOperator) String

func (r ReplaceOperator) String() string

Jump to

Keyboard shortcuts

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