sqlitetype

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeMap = map[string]func(gorm.ColumnType) string{

	"BOOLEAN": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "bool")
	},
	"BOOL": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "bool")
	},
	"TINYINT": func(ct gorm.ColumnType) string {

		col, _ := ct.ColumnType()
		n, _ := ct.Nullable()
		if strings.HasPrefix(strings.ToUpper(col), "TINYINT(1)") {
			return nullablePtr(n, "bool")
		}
		return nullablePtr(n, "int8")
	},

	"SMALLINT":         func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int16") },
	"INTEGER":          func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int64") },
	"INT":              func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int64") },
	"INT2":             func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int16") },
	"INT8":             func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int64") },
	"MEDIUMINT":        func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int32") },
	"UNSIGNED BIG INT": func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "uint64") },
	"BIGINT":           func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "int64") },

	"REAL":   func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "float64") },
	"DOUBLE": func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "float64") },
	"FLOAT":  func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "float32") },

	"TEXT":    func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "string") },
	"VARCHAR": func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "string") },
	"CHAR":    func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "string") },
	"CLOB":    func(ct gorm.ColumnType) string { n, _ := ct.Nullable(); return nullablePtr(n, "string") },
	"UUID":    func(ct gorm.ColumnType) string { return "datatypes.UUID" },
	"JSON":    func(ct gorm.ColumnType) string { return "datatypes.JSONMap" },
	"JSONB":   func(ct gorm.ColumnType) string { return "datatypes.JSONMap" },

	"BLOB": func(gorm.ColumnType) string { return "[]byte" },

	"DATE": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "time.Time")
	},
	"DATETIME": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "time.Time")
	},
	"TIMESTAMP": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "time.Time")
	},

	"DURATION": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "time.Duration")
	},
	"INTERVAL": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "time.Duration")
	},

	"NUMERIC": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "float64")
	},
	"DECIMAL": func(ct gorm.ColumnType) string {
		n, _ := ct.Nullable()
		return nullablePtr(n, "float64")
	},
}

TypeMap exposes the SQLite data type mapping used by the generator.

Functions

func TableNames

func TableNames(db *gorm.DB) (tableNames []string)

TableNames returns user-defined (non-internal) tables for SQLite.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL