Documentation ¶
Index ¶
- Constants
- Variables
- func New(config Config) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- type Config
- type Dialector
- func (dialector Dialector) Apply(config *gorm.Config) error
- func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
- func (dialector Dialector) DataTypeOf(field *schema.Field) string
- func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (dialector Dialector) Explain(sql string, vars ...interface{}) string
- func (dialector Dialector) Initialize(db *gorm.DB) (err error)
- func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (dialector Dialector) Name() string
- func (dialector Dialector) NowFunc(n int) func() time.Time
- func (dialector Dialector) QuoteTo(writer clause.Writer, str string)
- func (dialector Dialector) RollbackTo(tx *gorm.DB, name string) error
- func (dialector Dialector) SavePoint(tx *gorm.DB, name string) error
- func (dialector Dialector) Translate(err error) error
- type Index
- type Migrator
- func (m Migrator) AddColumn(value interface{}, name string) error
- func (m Migrator) AlterColumn(value interface{}, field string) error
- func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
- func (m Migrator) CurrentDatabase() (name string)
- func (m Migrator) CurrentSchema(stmt *gorm.Statement, table string) (string, string)
- func (m Migrator) DropConstraint(value interface{}, name string) error
- func (m Migrator) DropTable(values ...interface{}) error
- func (m Migrator) FullDataTypeOf(field *schema.Field) clause.Expr
- func (m Migrator) GetIndexes(value interface{}) ([]gorm.Index, error)
- func (m Migrator) GetTables() (tableList []string, err error)
- func (m Migrator) GetTypeAliases(databaseTypeName string) []string
- func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, columnType gorm.ColumnType) error
- func (m Migrator) RenameColumn(value interface{}, oldName, newName string) error
- func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error
- func (m Migrator) TableType(value interface{}) (tableType gorm.TableType, err error)
- func (m Migrator) TiDBVersion() (isTiDB bool, major, minor, patch int, err error)
Constants ¶
View Source
const ( // ClauseOnConflict for clause.ClauseBuilder ON CONFLICT key ClauseOnConflict = "ON CONFLICT" // ClauseValues for clause.ClauseBuilder VALUES key ClauseValues = "VALUES" // ClauseFor for clause.ClauseBuilder FOR key ClauseFor = "FOR" )
View Source
const (
AutoRandomTag = "auto_random()" // Treated as an auto_random field for tidb
)
Variables ¶
View Source
var ( // CreateClauses create clauses CreateClauses = []string{"INSERT", "VALUES", "ON CONFLICT"} // QueryClauses query clauses QueryClauses = []string{} // UpdateClauses update clauses UpdateClauses = []string{"UPDATE", "SET", "WHERE", "ORDER BY", "LIMIT"} // DeleteClauses delete clauses DeleteClauses = []string{"DELETE", "FROM", "WHERE", "ORDER BY", "LIMIT"} )
Functions ¶
Types ¶
type Config ¶
type Config struct { DriverName string ServerVersion string DSN string DSNConfig *dbDriver.Config Conn gorm.ConnPool SkipInitializeWithVersion bool DefaultStringSize uint DefaultDatetimePrecision *int DisableWithReturning bool DisableDatetimePrecision bool DontSupportRenameIndex bool DontSupportRenameColumn bool DontSupportNullAsDefaultValue bool DontSupportRenameColumnUnique bool // As of MySQL 8.0.19, ALTER TABLE permits more general (and SQL standard) syntax // for dropping and altering existing constraints of any type. // see https://dev.mysql.com/doc/refman/8.0/en/alter-table.html DontSupportDropConstraint bool }
type Dialector ¶
type Dialector struct {
*Config
}
func (Dialector) ClauseBuilders ¶
func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
func (Dialector) DefaultValueOf ¶
func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
type Index ¶
type Index struct { TableName string `gorm:"column:TABLE_NAME"` ColumnName string `gorm:"column:COLUMN_NAME"` IndexName string `gorm:"column:INDEX_NAME"` NonUnique int32 `gorm:"column:NON_UNIQUE"` }
Index table index info
type Migrator ¶
func (Migrator) AlterColumn ¶
func (Migrator) ColumnTypes ¶
func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
ColumnTypes column types return columnTypes,error
func (Migrator) CurrentDatabase ¶
func (Migrator) CurrentSchema ¶
func (Migrator) DropConstraint ¶
func (Migrator) GetTypeAliases ¶
func (Migrator) MigrateColumnUnique ¶
func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, columnType gorm.ColumnType) error
MigrateColumnUnique migrate column's UNIQUE constraint. In MySQL, ColumnType's Unique is affected by UniqueIndex, so we have to take care of the UniqueIndex.
func (Migrator) RenameColumn ¶
func (Migrator) RenameIndex ¶
Click to show internal directories.
Click to hide internal directories.