sqlite

package
v1.0.58 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CanonicalToSQLiteAffinity = map[string]string{

	"int":    "INTEGER",
	"int8":   "INTEGER",
	"int16":  "INTEGER",
	"int32":  "INTEGER",
	"int64":  "INTEGER",
	"uint":   "INTEGER",
	"uint8":  "INTEGER",
	"uint16": "INTEGER",
	"uint32": "INTEGER",
	"uint64": "INTEGER",
	"bool":   "INTEGER",

	"integer":     "INTEGER",
	"smallint":    "INTEGER",
	"bigint":      "INTEGER",
	"serial":      "INTEGER",
	"smallserial": "INTEGER",
	"bigserial":   "INTEGER",
	"boolean":     "INTEGER",
	"tinyint":     "INTEGER",
	"mediumint":   "INTEGER",

	"float32": "REAL",
	"float64": "REAL",

	"real":             "REAL",
	"float":            "REAL",
	"double":           "REAL",
	"double precision": "REAL",

	"decimal":    "NUMERIC",
	"numeric":    "NUMERIC",
	"money":      "NUMERIC",
	"smallmoney": "NUMERIC",

	"bytea": "BLOB",
	"blob":  "BLOB",

	"string": "TEXT",
	"text":   "TEXT",

	"varchar":     "TEXT",
	"char":        "TEXT",
	"nvarchar":    "TEXT",
	"nchar":       "TEXT",
	"citext":      "TEXT",
	"date":        "TEXT",
	"time":        "TEXT",
	"timetz":      "TEXT",
	"timestamp":   "TEXT",
	"timestamptz": "TEXT",
	"datetime":    "TEXT",
	"uuid":        "TEXT",
	"json":        "TEXT",
	"jsonb":       "TEXT",
	"xml":         "TEXT",
	"inet":        "TEXT",
	"cidr":        "TEXT",
	"macaddr":     "TEXT",
}

CanonicalToSQLiteAffinity maps type names to SQLite type affinity names. Accepts both Go canonical names ("int", "string") and SQL canonical names ("integer", "varchar") so the writer handles input from any reader. The five SQLite type affinities are TEXT, INTEGER, REAL, NUMERIC, BLOB.

View Source
var SQLiteToCanonicalTypes = map[string]string{

	"integer":          "int",
	"int":              "int",
	"tinyint":          "int8",
	"smallint":         "int16",
	"mediumint":        "int",
	"bigint":           "int64",
	"unsigned big int": "uint64",
	"int2":             "int16",
	"int8":             "int64",

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

	"numeric": "decimal",
	"decimal": "decimal",

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

	"date":      "date",
	"datetime":  "timestamp",
	"timestamp": "timestamp",

	"text":              "string",
	"varchar":           "string",
	"char":              "string",
	"character":         "string",
	"varying character": "string",
	"nchar":             "string",
	"nvarchar":          "string",
	"clob":              "text",

	"blob": "bytea",
}

SQLiteToCanonicalTypes maps SQLite type names to canonical types. SQLite has type affinity rules; this maps common type names including MySQL/PostgreSQL types that users write in SQLite schemas.

Functions

func ConvertCanonicalToSQLite

func ConvertCanonicalToSQLite(canonicalType string) string

ConvertCanonicalToSQLite converts a canonical type (or any SQL type) to its SQLite type affinity. Defaults to TEXT for unrecognised types.

func ConvertSQLiteToCanonical

func ConvertSQLiteToCanonical(sqliteType string) string

ConvertSQLiteToCanonical converts a SQLite type name to the canonical type. Strips dimension parameters (e.g. VARCHAR(255) → string) and handles SQLite's flexible affinity rules. Defaults to "string" for unknown types.

Types

This section is empty.

Jump to

Keyboard shortcuts

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