mariadb

package
v1.0.59 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CanonicalToMariaDBTypes = map[string]string{
	"bool":        "TINYINT(1)",
	"int8":        "TINYINT",
	"int16":       "SMALLINT",
	"int":         "INT",
	"int32":       "INT",
	"int64":       "BIGINT",
	"uint":        "INT UNSIGNED",
	"uint8":       "TINYINT UNSIGNED",
	"uint16":      "SMALLINT UNSIGNED",
	"uint32":      "INT UNSIGNED",
	"uint64":      "BIGINT UNSIGNED",
	"float32":     "FLOAT",
	"float64":     "DOUBLE",
	"decimal":     "DECIMAL",
	"string":      "VARCHAR(255)",
	"text":        "TEXT",
	"date":        "DATE",
	"time":        "TIME",
	"timestamp":   "DATETIME",
	"timestamptz": "DATETIME",
	"uuid":        "CHAR(36)",
	"json":        "JSON",
	"jsonb":       "JSON",
	"bytea":       "BLOB",
}

CanonicalToMariaDBTypes maps canonical types to MariaDB/MySQL types.

View Source
var MariaDBToCanonicalTypes = map[string]string{

	"tinyint":   "int8",
	"smallint":  "int16",
	"mediumint": "int",
	"int":       "int",
	"integer":   "int",
	"int2":      "int16",
	"int4":      "int",
	"int8":      "int64",
	"bigint":    "int64",

	"boolean": "bool",
	"bool":    "bool",
	"bit":     "bool",

	"float":            "float32",
	"double":           "float64",
	"real":             "float64",
	"double precision": "float64",

	"decimal": "decimal",
	"numeric": "decimal",
	"dec":     "decimal",
	"fixed":   "decimal",

	"char":       "string",
	"character":  "string",
	"varchar":    "string",
	"nchar":      "string",
	"nvarchar":   "string",
	"tinytext":   "text",
	"text":       "text",
	"mediumtext": "text",
	"longtext":   "text",

	"binary":     "bytea",
	"varbinary":  "bytea",
	"tinyblob":   "bytea",
	"blob":       "bytea",
	"mediumblob": "bytea",
	"longblob":   "bytea",

	"date":      "date",
	"time":      "time",
	"datetime":  "timestamp",
	"timestamp": "timestamp",
	"year":      "int",

	"json": "json",
	"enum": "string",
	"set":  "string",
	"uuid": "uuid",
}

MariaDBToCanonicalTypes maps MariaDB/MySQL type names to canonical types.

View Source
var MariaDBTypeSynonyms = map[string]string{
	"integer":          "int",
	"int2":             "smallint",
	"int4":             "int",
	"int8":             "bigint",
	"double precision": "double",
	"character":        "char",
	"dec":              "decimal",
	"fixed":            "decimal",
	"numeric":          "decimal",
	"boolean":          "tinyint",
	"bool":             "tinyint",
}

MariaDBTypeSynonyms maps MariaDB/MySQL type aliases to their canonical MariaDB name.

Functions

func ConvertCanonicalToMariaDB

func ConvertCanonicalToMariaDB(canonicalType string) string

ConvertCanonicalToMariaDB converts a canonical type to a MariaDB/MySQL type. Defaults to VARCHAR(255) for unrecognised types.

func ConvertMariaDBToCanonical

func ConvertMariaDBToCanonical(mariadbType string) string

ConvertMariaDBToCanonical converts a MariaDB/MySQL type name to the canonical type. Strips dimension parameters and normalizes aliases. Defaults to "string".

func NormalizeMariaDBType

func NormalizeMariaDBType(baseType string) string

NormalizeMariaDBType maps a MariaDB/MySQL base type (no dimension parameters) to its canonical MariaDB form. Unknown types are returned as-is (lowercased).

Types

This section is empty.

Jump to

Keyboard shortcuts

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