Documentation ¶
Index ¶
- Variables
- func ColumnString(dialect Dialect, col *schemas.Column, includePrimaryKey bool) (string, error)
- func FormatColumnTime(dialect Dialect, defaultTimeZone *time.Location, col *schemas.Column, ...) (v interface{})
- func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{})
- func FullTableName(dialect Dialect, mapper names.Mapper, bean interface{}, includeSchema ...bool) string
- func QueryDefaultKingbaseSchema(ctx context.Context, queryer core.Queryer) (string, error)
- func QueryDefaultPostgresSchema(ctx context.Context, queryer core.Queryer) (string, error)
- func RegisterDialect(dbName schemas.DBType, dialectFunc func() Dialect)
- func RegisterDriver(driverName string, driver Driver)
- func RegisteredDriverSize() int
- func TableNameNoSchema(dialect Dialect, mapper names.Mapper, tableName interface{}) string
- func TableNameWithSchema(dialect Dialect, tableName string) string
- type Base
- func (db *Base) AddColumnSQL(tableName string, col *schemas.Column) string
- func (db *Base) CreateIndexSQL(tableName string, index *schemas.Index) string
- func (b *Base) DBType() schemas.DBType
- func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string
- func (db *Base) DropTableSQL(tableName string) (string, bool)
- func (b *Base) ForUpdateSQL(query string) string
- func (b *Base) FormatBytes(bs []byte) string
- func (db *Base) HasRecords(queryer core.Queryer, ctx context.Context, query string, args ...interface{}) (bool, error)
- func (b *Base) Init(dialect Dialect, uri *URI) error
- func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error)
- func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string
- func (b *Base) Quoter() schemas.Quoter
- func (b *Base) SetParams(params map[string]string)
- func (b *Base) URI() *URI
- type Dialect
- type Driver
- type Filter
- type QuotePolicy
- type SeqFilter
- type URI
Constants ¶
This section is empty.
Variables ¶
var (
// DefaultPostgresSchema default postgres schema
DefaultKingbaseSchema = "public"
)
var (
// DefaultPostgresSchema default postgres schema
DefaultPostgresSchema = "public"
)
Functions ¶
func ColumnString ¶
ColumnString generate column description string according dialect
func FormatColumnTime ¶
func FormatTime ¶
FormatTime format time as column type
func FullTableName ¶
func FullTableName(dialect Dialect, mapper names.Mapper, bean interface{}, includeSchema ...bool) string
FullTableName returns table name with quote and schema according parameter
func QueryDefaultKingbaseSchema ¶
QueryDefaultKingbaseSchema returns the default kingbase schema
func QueryDefaultPostgresSchema ¶
QueryDefaultPostgresSchema returns the default postgres schema
func RegisterDialect ¶
RegisterDialect register database dialect
func RegisterDriver ¶
func RegisteredDriverSize ¶
func RegisteredDriverSize() int
func TableNameNoSchema ¶
TableNameNoSchema returns table name with given tableName
func TableNameWithSchema ¶
TableNameWithSchema will add schema prefix on table name if possible
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base represents a basic dialect and all real dialects could embed this struct
func (*Base) AddColumnSQL ¶
func (*Base) CreateIndexSQL ¶
func (*Base) DropIndexSQL ¶
func (*Base) ForUpdateSQL ¶
func (*Base) FormatBytes ¶
func (*Base) HasRecords ¶
func (*Base) IsColumnExist ¶
func (*Base) ModifyColumnSQL ¶
type Dialect ¶
type Dialect interface { Init(*URI) error URI() *URI SQLType(*schemas.Column) string FormatBytes(b []byte) string IsReserved(string) bool Quoter() schemas.Quoter SetQuotePolicy(quotePolicy QuotePolicy) AutoIncrStr() string GetIndexes(queryer core.Queryer, ctx context.Context, tableName string) (map[string]*schemas.Index, error) IndexCheckSQL(tableName, idxName string) (string, []interface{}) CreateIndexSQL(tableName string, index *schemas.Index) string DropIndexSQL(tableName string, index *schemas.Index) string GetTables(queryer core.Queryer, ctx context.Context) ([]*schemas.Table, error) IsTableExist(queryer core.Queryer, ctx context.Context, tableName string) (bool, error) CreateTableSQL(table *schemas.Table, tableName string) ([]string, bool) DropTableSQL(tableName string) (string, bool) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName string, colName string) (bool, error) AddColumnSQL(tableName string, col *schemas.Column) string ModifyColumnSQL(tableName string, col *schemas.Column) string ForUpdateSQL(query string) string Filters() []Filter SetParams(params map[string]string) }
Dialect represents a kind of database
func OpenDialect ¶
OpenDialect opens a dialect via driver name and connection string
func QueryDialect ¶
QueryDialect query if registered database dialect
type Driver ¶
func QueryDriver ¶
type QuotePolicy ¶
type QuotePolicy int
QuotePolicy describes quote handle policy
const ( QuotePolicyAlways QuotePolicy = iota QuotePolicyNone QuotePolicyReserved )
All QuotePolicies