Documentation
¶
Index ¶
- Constants
- func DefaultDSN(dsn string) string
- func New(config Config) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- type Config
- type Dialector
- func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v any)
- func (d Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
- func (d Dialector) ConfiguresForeignKeys() bool
- func (d Dialector) DataTypeOf(field *schema.Field) string
- func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (d Dialector) Explain(sql string, vars ...any) string
- func (d Dialector) Initialize(db *gorm.DB) (err error)
- func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (d Dialector) Name() string
- func (d Dialector) QuoteTo(writer clause.Writer, str string)
- func (d Dialector) RollbackTo(tx *gorm.DB, name string) error
- func (d Dialector) SavePoint(tx *gorm.DB, name string) error
- func (d Dialector) Translate(err error) error
- type Index
- type JSON
- type Migrator
- func (m *Migrator) AlterColumn(value any, name string) error
- func (m *Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []any)
- func (m *Migrator) ColumnTypes(value any) ([]gorm.ColumnType, error)
- func (m *Migrator) CreateConstraint(value any, name string) error
- func (m *Migrator) CreateIndex(value any, name string) error
- func (m *Migrator) CurrentDatabase() (name string)
- func (m *Migrator) DropColumn(value any, name string) error
- func (m *Migrator) DropConstraint(value any, name string) error
- func (m *Migrator) DropIndex(value any, name string) error
- func (m *Migrator) DropTable(values ...any) error
- func (m *Migrator) GetIndexes(value any) ([]gorm.Index, error)
- func (m *Migrator) GetTables() (tableList []string, err error)
- func (m *Migrator) HasColumn(value any, name string) bool
- func (m *Migrator) HasConstraint(value any, name string) bool
- func (m *Migrator) HasIndex(value any, name string) bool
- func (m *Migrator) HasTable(value any) bool
- func (m *Migrator) RenameIndex(value any, oldName, newName string) error
- func (m *Migrator) RunWithoutForeignKey(fc func() error) error
Constants ¶
const DriverName = "sqlite"
DriverName is the default driver name for SQLite.
Variables ¶
This section is empty.
Functions ¶
func DefaultDSN ¶
DefaultDSN preserves GORM's time.Time scan behavior with modernc and enables foreign keys on each new physical connection. Explicit DSN options take precedence. This can also be used when opening an external modernc pool.
Types ¶
type Dialector ¶
type Dialector struct {
DriverName string
DSN string
Conn gorm.ConnPool
// ForeignKeysPerConnection declares that a supplied Conn or custom driver
// enables foreign keys on every physical connection before use. The
// built-in driver applies this by default, subject to explicit DSN options.
ForeignKeysPerConnection bool
}
func (Dialector) ClauseBuilders ¶
func (d Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
func (Dialector) ConfiguresForeignKeys ¶
ConfiguresForeignKeys reports whether opening this dialector's pool applies the modernc defaults or the caller has explicitly opted into the external pool contract. The consumer must still check that foreign keys are enabled: modernc callers are allowed to override the default in the DSN.
func (Dialector) DefaultValueOf ¶
func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression
type JSON ¶
JSON uses a JSON declaration and standard JSON values, never binary JSONB. Objects/arrays are stored as text. SQLite's NUMERIC affinity can coerce numeric scalars; use gorm:"type:JSON TEXT" when exact numeric text must be preserved. A zero value represents SQL NULL; JSON("null") represents JSON null. Use json_valid in a CHECK constraint if writes outside this type must also be validated: SQLite's JSON declaration alone does not enforce validity.
func (JSON) GormDataType ¶
func (JSON) MarshalJSON ¶
func (*JSON) UnmarshalJSON ¶
type Migrator ¶
func (*Migrator) BuildIndexOptions ¶
func (*Migrator) ColumnTypes ¶
func (m *Migrator) ColumnTypes(value any) ([]gorm.ColumnType, error)
ColumnTypes returns metadata for the table’s columns.
func (*Migrator) CreateConstraint ¶
func (*Migrator) CurrentDatabase ¶
func (*Migrator) GetIndexes ¶
GetIndexes return Indexes []gorm.Index and execErr error, See the doc