Documentation ¶
Index ¶
- Variables
- type Dialect
- type Driver
- type QuotePolicy
- type Quoter
- func (q Quoter) IsEmpty() bool
- func (q Quoter) Join(a []string, sep string) string
- func (q Quoter) JoinWrite(b *strings.Builder, a []string, sep string) error
- func (q Quoter) Quote(s string) string
- func (q Quoter) QuoteTo(buf *strings.Builder, value string) error
- func (q Quoter) Replace(sql string) string
- func (q Quoter) Strings(s []string) []string
- func (q Quoter) Trim(s string) string
- type Regitser
- type SQL
- type SQLParam
- type URI
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // AlwaysFalseReverse always think it's not a reverse word AlwaysNoReserve = func(string) bool { return false } // AlwaysReverse always reverse the word AlwaysReserve = func(string) bool { return true } // CommanQuoteMark represnets the common quote mark CommanQuoteMark byte = '`' // CommonQuoter represetns a common quoter CommonQuoter = Quoter{CommanQuoteMark, CommanQuoteMark, AlwaysReserve} )
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect interface { Init(*URI) error URI() *URI // 给字符串中的双引号转义 QuoteExpr(str string) string // ToSQLType 转为 sql 类型 ToSQLType(typ reflect.Type) *types.SQLType // DataTypeOf 转为 sql 类型 DataTypeOf(val reflect.Value) *types.SQLType // SQLType 转换为 SQL 数据类型 SQLType(col *schema.Column) string // AutoIncrStr 自增字段标志字符串 AutoIncrStr() string Quoter() Quoter TableNameWithSchema(tableName string) string // 从数据库中查询所有表结构 GetTables(ex exec.SQLExecutor, ctx context.Context) ([]*schema.Table, error) // SQLTableExists 判断表是否存在SQL SQLTableExists(tableName string) (sql string, args []interface{}) // SQLCreateTable 生成创建表结构的 SQL SQLCreateTable(table *schema.Table, tableName string) ([]string, error) // SQLDropTable 生成删除表的 SQL SQLDropTable(tableName string) (string, error) GetColumns(ex exec.SQLExecutor, ctx context.Context, tableName string) ([]string, map[string]*schema.Column, error) // SQLColumn 生成列相关的 SQL 定义 SQLColumn(col *schema.Column, inlinePrimaryKey bool) (string, error) SQLAddColumn(tableName string, col *schema.Column) string SQLModifyColumn(tableName string, col *schema.Column) string GetIndexes(ex exec.SQLExecutor, ctx context.Context, tableName string) (map[string]*schema.Index, error) SQLCreateIndex(tableName string, index *schema.Index) string SQLDropIndex(tableName string, index *schema.Index) string }
type QuotePolicy ¶
type QuotePolicy int
QuotePolicy describes quote handle policy
const ( QuotePolicyAlways QuotePolicy = iota QuotePolicyNone QuotePolicyReserved )
All QuotePolicies
type Quoter ¶
Quoter represents a quoter to the SQL table name and column name
func (Quoter) QuoteTo ¶
QuoteTo quotes the table or column names. i.e. if the quotes are [ and ]
name -> [name] `name` -> [name] [name] -> [name] schema.name -> [schema].[name] `schema`.`name` -> [schema].[name] `schema`.name -> [schema].[name] schema.`name` -> [schema].[name] [schema].name -> [schema].[name] schema.[name] -> [schema].[name] name AS a -> [name] AS a schema.name AS a -> [schema].[name] AS a
type URI ¶
type URI struct { DRIVER constants.DRIVER Proto string Host string Port string DBName string User string Passwd string Charset string Laddr string Raddr string Timeout time.Duration Schema string }
URI represents an uri to visit database
func (*URI) SupportColumnVarchar2Text ¶
SupportColumnVarchar2Text 是否支持把现有列的数据类型从 varchar 扩展为 text
func (*URI) SupportColumnVarcharIncLength ¶
SupportColumnVarcharIncLength 是否支持把现有列的数据类型从 varchar 增加长度
Click to show internal directories.
Click to hide internal directories.