Documentation
¶
Index ¶
- Constants
- func OutputFormat(s string) string
- type CVSDBDialect
- func (d *CVSDBDialect) ConvertCastTypeToString(asType byte, flen int, decimal int, flag uint) (keyword string, plainWord string, err error)
- func (d *CVSDBDialect) GetOperator(originName string) string
- func (d *CVSDBDialect) GetSpecialFuncName(originName string) string
- func (d *CVSDBDialect) SkipSchemaInColName() bool
- type Dialect
- type Formatter
- type MySQLDialect
- func (d *MySQLDialect) ConvertCastTypeToString(asType byte, flen int, decimal int, flag uint) (keyword string, plainWord string, err error)
- func (d *MySQLDialect) GetOperator(op string) string
- func (d *MySQLDialect) GetSpecialFuncName(originName string) string
- func (d *MySQLDialect) NeedParenthesesForCmpOperand() bool
- func (d *MySQLDialect) SkipSchemaInColName() bool
- type OdpsDialect
- func (d *OdpsDialect) ConvertCastTypeToString(asType byte, flen int, decimal int, flag uint) (keyword string, plainWord string, err error)
- func (d *OdpsDialect) GetSpecialFuncName(originName string) string
- func (d *OdpsDialect) NeedParenthesesForCmpOperand() bool
- func (d *OdpsDialect) SkipSchemaInColName() bool
- type PostgresDialect
- func (d *PostgresDialect) ConvertCastTypeToString(asType byte, flen int, decimal int, flag uint) (keyword string, plainWord string, err error)
- func (d *PostgresDialect) GetSpecialFuncName(originName string) string
- func (d *PostgresDialect) NeedParenthesesForCmpOperand() bool
- func (d *PostgresDialect) SkipSchemaInColName() bool
- type RestoreCtx
- type RestoreFlags
- func (rf RestoreFlags) HasKeyWordLowercaseFlag() bool
- func (rf RestoreFlags) HasKeyWordUppercaseFlag() bool
- func (rf RestoreFlags) HasNameBackQuotesFlag() bool
- func (rf RestoreFlags) HasNameDoubleQuotesFlag() bool
- func (rf RestoreFlags) HasNameLowercaseFlag() bool
- func (rf RestoreFlags) HasNameUppercaseFlag() bool
- func (rf RestoreFlags) HasSpacesAroundBinaryOperationFlag() bool
- func (rf RestoreFlags) HasStringDoubleQuotesFlag() bool
- func (rf RestoreFlags) HasStringEscapeBackslashFlag() bool
- func (rf RestoreFlags) HasStringSingleQuotesFlag() bool
- type TiDBDialect
Constants ¶
const (
DefaultRestoreFlags = RestoreStringSingleQuotes | RestoreKeyWordUppercase | RestoreNameBackQuotes
)
Variables ¶
This section is empty.
Functions ¶
func OutputFormat ¶
OutputFormat output escape character with backslash.
Types ¶
type CVSDBDialect ¶
type CVSDBDialect struct { PostgresDialect // contains filtered or unexported fields }
func (*CVSDBDialect) ConvertCastTypeToString ¶
func (*CVSDBDialect) GetOperator ¶
func (d *CVSDBDialect) GetOperator(originName string) string
func (*CVSDBDialect) GetSpecialFuncName ¶
func (d *CVSDBDialect) GetSpecialFuncName(originName string) string
func (*CVSDBDialect) SkipSchemaInColName ¶
func (d *CVSDBDialect) SkipSchemaInColName() bool
type Dialect ¶
type Dialect interface { ConvertCastTypeToString(asType byte, flen int, decimal int, flag uint) (keyword string, plainWord string, err error) SkipSchemaInColName() bool // special means functions which have different function names in different backends // If the function has been renamed inside the function, return the renamed name; otherwise, // return the original name. If you are sure that the function name is the same in all backends, // please use the original name directly; otherwise, please call this function. // Of course, you can also override the differences in function names of different backend databases within this function. GetSpecialFuncName(string) string GetOperator(string) string // need parentheses or not for continuous comparison operator // such as: a = b = c // for mysql a = b = c // for pg (a = b) = c NeedParenthesesForCmpOperand() bool }
func NewCVSDBDialect ¶
func NewCVSDBDialect() Dialect
func NewMySQLDialect ¶
func NewMySQLDialect() Dialect
func NewOdpsDialect ¶
func NewOdpsDialect() Dialect
func NewPostgresDialect ¶
func NewPostgresDialect() Dialect
func NewTiDBDialect ¶
func NewTiDBDialect() Dialect
type Formatter ¶
type Formatter interface { io.Writer Format(format string, args ...interface{}) (n int, errno error) }
Formatter is an io.Writer extended formatter by a fmt.Printf like function Format.
func FlatFormatter ¶
FlatFormatter returns a newly created Formatter with the same functionality as the one returned by IndentFormatter except it allows a newline in the 'format' string argument of Format to pass through if the indent level is current zero.
If the indent level is non-zero then such new lines are changed to a space character. There is no indent string, the %i and %u format verbs are used solely to determine the indent level.
The FlatFormatter is intended for flattening of normally nested structure textual representation to a one top level structure per line form.
FlatFormatter(os.Stdout, " ").Format("abc%d%%e%i\nx\ny\n%uz\n", 3)
output in the form of a Go quoted string literal:
"abc3%%e x y z\n"
func IndentFormatter ¶
IndentFormatter returns a new Formatter which interprets %i and %u in the Format() formats string as indent and unindent commands. The commands can nest. The Formatter writes to io.Writer 'w' and inserts one 'indent' string per current indent level value. Behaviour of commands reaching negative indent levels is undefined.
IndentFormatter(os.Stdout, "\t").Format("abc%d%%e%i\nx\ny\n%uz\n", 3)
output:
abc3%e x y z
The Go quoted string literal form of the above is:
"abc%%e\n\tx\n\tx\nz\n"
The commands can be scattered between separate invocations of Format(), i.e. the formatter keeps track of the indent level and knows if it is positioned on start of a line and should emit indentation(s). The same output as above can be produced by e.g.:
f := IndentFormatter(os.Stdout, " ") f.Format("abc%d%%e%i\nx\n", 3) f.Format("y\n%uz\n")
type MySQLDialect ¶
type MySQLDialect struct { }
func (*MySQLDialect) ConvertCastTypeToString ¶
func (*MySQLDialect) GetOperator ¶
func (d *MySQLDialect) GetOperator(op string) string
func (*MySQLDialect) GetSpecialFuncName ¶
func (d *MySQLDialect) GetSpecialFuncName(originName string) string
func (*MySQLDialect) NeedParenthesesForCmpOperand ¶
func (d *MySQLDialect) NeedParenthesesForCmpOperand() bool
func (*MySQLDialect) SkipSchemaInColName ¶
func (d *MySQLDialect) SkipSchemaInColName() bool
type OdpsDialect ¶
type OdpsDialect struct { MySQLDialect // contains filtered or unexported fields }
func (*OdpsDialect) ConvertCastTypeToString ¶
func (*OdpsDialect) GetSpecialFuncName ¶
func (d *OdpsDialect) GetSpecialFuncName(originName string) string
func (*OdpsDialect) NeedParenthesesForCmpOperand ¶
func (d *OdpsDialect) NeedParenthesesForCmpOperand() bool
func (*OdpsDialect) SkipSchemaInColName ¶
func (d *OdpsDialect) SkipSchemaInColName() bool
type PostgresDialect ¶
type PostgresDialect struct { MySQLDialect // contains filtered or unexported fields }
func (*PostgresDialect) ConvertCastTypeToString ¶
func (*PostgresDialect) GetSpecialFuncName ¶
func (d *PostgresDialect) GetSpecialFuncName(originName string) string
func (*PostgresDialect) NeedParenthesesForCmpOperand ¶
func (d *PostgresDialect) NeedParenthesesForCmpOperand() bool
func (*PostgresDialect) SkipSchemaInColName ¶
func (d *PostgresDialect) SkipSchemaInColName() bool
type RestoreCtx ¶
type RestoreCtx struct { Flags RestoreFlags In io.Writer JoinLevel int Dialect Dialect }
RestoreCtx is `Restore` context to hold flags and writer.
func NewRestoreCtx ¶
func NewRestoreCtx(flags RestoreFlags, in io.Writer) *RestoreCtx
NewRestoreCtx returns a new `RestoreCtx`.
func NewRestoreCtxWithDialect ¶
func NewRestoreCtxWithDialect(flags RestoreFlags, in io.Writer, d Dialect) *RestoreCtx
NewRestoreCtx returns a new `RestoreCtx`.
func (*RestoreCtx) WriteKeyWord ¶
func (ctx *RestoreCtx) WriteKeyWord(keyWord string)
WriteKeyWord writes the `keyWord` into writer. `keyWord` will be converted format(uppercase and lowercase for now) according to `RestoreFlags`.
func (*RestoreCtx) WriteName ¶
func (ctx *RestoreCtx) WriteName(name string)
WriteName writes the name into writer `name` maybe wrapped in quotes and escaped according to RestoreFlags.
func (*RestoreCtx) WritePlain ¶
func (ctx *RestoreCtx) WritePlain(plainText string)
WritePlain writes the plain text into writer without any handling.
func (*RestoreCtx) WritePlainf ¶
func (ctx *RestoreCtx) WritePlainf(format string, a ...interface{})
WritePlainf write the plain text into writer without any handling.
func (*RestoreCtx) WriteString ¶
func (ctx *RestoreCtx) WriteString(str string)
WriteString writes the string into writer `str` may be wrapped in quotes and escaped according to RestoreFlags.
type RestoreFlags ¶
type RestoreFlags uint64
RestoreFlag mark the Restore format
const ( RestoreStringSingleQuotes RestoreFlags = 1 << iota RestoreStringDoubleQuotes RestoreStringEscapeBackslash RestoreKeyWordUppercase RestoreKeyWordLowercase RestoreNameUppercase RestoreNameLowercase RestoreNameDoubleQuotes RestoreNameBackQuotes RestoreSpacesAroundBinaryOperation )
Mutually exclusive group of `RestoreFlags`: [RestoreStringSingleQuotes, RestoreStringDoubleQuotes] [RestoreKeyWordUppercase, RestoreKeyWordLowercase] [RestoreNameUppercase, RestoreNameLowercase] [RestoreNameDoubleQuotes, RestoreNameBackQuotes] The flag with the left position in each group has a higher priority.
func (RestoreFlags) HasKeyWordLowercaseFlag ¶
func (rf RestoreFlags) HasKeyWordLowercaseFlag() bool
HasKeyWordLowercaseFlag returns a boolean indicating whether `rf` has `RestoreKeyWordLowercase` flag.
func (RestoreFlags) HasKeyWordUppercaseFlag ¶
func (rf RestoreFlags) HasKeyWordUppercaseFlag() bool
HasKeyWordUppercaseFlag returns a boolean indicating whether `rf` has `RestoreKeyWordUppercase` flag.
func (RestoreFlags) HasNameBackQuotesFlag ¶
func (rf RestoreFlags) HasNameBackQuotesFlag() bool
HasNameBackQuotesFlag returns a boolean indicating whether `rf` has `RestoreNameBackQuotes` flag.
func (RestoreFlags) HasNameDoubleQuotesFlag ¶
func (rf RestoreFlags) HasNameDoubleQuotesFlag() bool
HasNameDoubleQuotesFlag returns a boolean indicating whether `rf` has `RestoreNameDoubleQuotes` flag.
func (RestoreFlags) HasNameLowercaseFlag ¶
func (rf RestoreFlags) HasNameLowercaseFlag() bool
HasNameLowercaseFlag returns a boolean indicating whether `rf` has `RestoreNameLowercase` flag.
func (RestoreFlags) HasNameUppercaseFlag ¶
func (rf RestoreFlags) HasNameUppercaseFlag() bool
HasNameUppercaseFlag returns a boolean indicating whether `rf` has `RestoreNameUppercase` flag.
func (RestoreFlags) HasSpacesAroundBinaryOperationFlag ¶
func (rf RestoreFlags) HasSpacesAroundBinaryOperationFlag() bool
HasSpacesAroundBinaryOperationFlag returns a boolean indicating whether `rf` has `RestoreSpacesAroundBinaryOperation` flag.
func (RestoreFlags) HasStringDoubleQuotesFlag ¶
func (rf RestoreFlags) HasStringDoubleQuotesFlag() bool
HasStringDoubleQuotesFlag returns a boolean indicating whether `rf` has `RestoreStringDoubleQuotes` flag.
func (RestoreFlags) HasStringEscapeBackslashFlag ¶
func (rf RestoreFlags) HasStringEscapeBackslashFlag() bool
HasStringEscapeBackslashFlag returns a boolean indicating whether `rf` has `RestoreStringEscapeBackslash` flag.
func (RestoreFlags) HasStringSingleQuotesFlag ¶
func (rf RestoreFlags) HasStringSingleQuotesFlag() bool
HasStringSingleQuotesFlag returns a boolean indicating when `rf` has `RestoreStringSingleQuotes` flag.
type TiDBDialect ¶
type TiDBDialect struct {
MySQLDialect
}
func (*TiDBDialect) ConvertCastTypeToString ¶
func (*TiDBDialect) GetCastFieldType ¶
func (d *TiDBDialect) GetCastFieldType(dtype string) string
func (*TiDBDialect) SkipSchemaInColName ¶
func (d *TiDBDialect) SkipSchemaInColName() bool