Documentation
¶
Index ¶
- func New(config Config) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- type Config
- type Dialector
- func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- 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) 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 ErrMessage
- type Index
- type Migrator
- func (m Migrator) AddColumn(value interface{}, field string) error
- func (m Migrator) AlterColumn(value interface{}, field string) error
- func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})
- func (m Migrator) ColumnTypes(value interface{}) (columnTypes []gorm.ColumnType, err error)
- func (m Migrator) CreateIndex(value interface{}, name string) error
- func (m Migrator) CreateSequence(tx *gorm.DB, stmt *gorm.Statement, field *schema.Field, ...) (err error)
- func (m Migrator) CreateTable(values ...interface{}) (err error)
- func (m Migrator) CurrentDatabase() (name string)
- func (m Migrator) CurrentSchema(stmt *gorm.Statement, table string) (interface{}, interface{})
- func (m Migrator) DeleteSequence(tx *gorm.DB, stmt *gorm.Statement, field *schema.Field, fileType clause.Expr) (err error)
- func (m Migrator) DropColumn(dst interface{}, field string) error
- func (m Migrator) DropIndex(value interface{}, name string) error
- func (m Migrator) DropTable(values ...interface{}) error
- func (m Migrator) GetIndexes(value interface{}) ([]gorm.Index, error)
- func (m Migrator) GetRows(currentSchema interface{}, table interface{}) (*sql.Rows, error)
- func (m Migrator) GetTables() (tableList []string, err error)
- func (m Migrator) GetTypeAliases(databaseTypeName string) []string
- func (m Migrator) HasColumn(value interface{}, field string) bool
- func (m Migrator) HasConstraint(value interface{}, name string) bool
- func (m Migrator) HasIndex(value interface{}, name string) bool
- func (m Migrator) HasTable(value interface{}) bool
- func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnType gorm.ColumnType) error
- func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, columnType gorm.ColumnType) error
- func (m Migrator) RenameColumn(dst interface{}, oldName, field string) error
- func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error
- func (m Migrator) UpdateSequence(tx *gorm.DB, stmt *gorm.Statement, field *schema.Field, ...) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dialector ¶
type Dialector struct {
*Config
}
func (Dialector) DefaultValueOf ¶
func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
type ErrMessage ¶
type Index ¶
type Index struct {
TableName string `gorm:"column:table_name"`
ColumnName string `gorm:"column:column_name"`
IndexName string `gorm:"column:index_name"`
NonUnique bool `gorm:"column:non_unique"`
Primary bool `gorm:"column:primary"`
}
Index table index info
type Migrator ¶
func (Migrator) AlterColumn ¶
AlterColumn alter value's `field` column' type based on schema definition
func (Migrator) BuildIndexOptions ¶
func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})
func (Migrator) ColumnTypes ¶
func (m Migrator) ColumnTypes(value interface{}) (columnTypes []gorm.ColumnType, err error)
func (Migrator) CreateIndex ¶
func (Migrator) CreateSequence ¶
func (Migrator) CreateTable ¶
func (Migrator) CurrentDatabase ¶
func (Migrator) CurrentSchema ¶
func (Migrator) DeleteSequence ¶
func (Migrator) DropColumn ¶
func (Migrator) GetTypeAliases ¶
func (Migrator) HasConstraint ¶
func (Migrator) MigrateColumn ¶
func (Migrator) MigrateColumnUnique ¶
func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, columnType gorm.ColumnType) error
MigrateColumnUnique skips the unique-constraint step for a column that has no unique tag and is the only column of a plain unique index in the model (no WHERE predicate, no expression): that index already enforces the column's uniqueness.
Up to v1.25.6, gorm treated a field that is the only column of a unique index as Unique, so migrations run on those versions could leave UNIQUE constraints on such columns, named other than the "uni_<Table>_<Column>" later gorm versions look for: a column added to an existing table got "<Table>_<Column>_key" from "ADD ... UNIQUE", and AlterColumn above added "idx_<Table>_<Column>" when the column's unique index has a custom name or was added to an existing column. From v1.25.7 the field is no longer Unique, and the base method drops "uni_<Table>_<Column>", which does not exist on those tables: AutoMigrate fails with SQLSTATE 42704. The index enforces the same uniqueness, so the legacy constraint is kept, and this method issues no DDL for the column (MigrateColumn can still change its type, nullability or default). field.Schema is the schema the field was parsed into (the parent schema for an embedded field), so a table-name value is covered too.
Every other column keeps the base behavior: one whose unique index is partial, uses an expression or spans several columns, and one with no unique index in the model. The model cannot show that a legacy constraint on such a column is redundant, so the base drop of "uni_<Table>_<Column>" fails with 42704 under any other name, and the mismatch needs a reviewed migration rather than being kept silently.