commontypes

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CSharpTypeMap = map[string]string{

	"integer":     "int",
	"int":         "int",
	"int4":        "int",
	"smallint":    "short",
	"int2":        "short",
	"bigint":      "long",
	"int8":        "long",
	"serial":      "int",
	"bigserial":   "long",
	"smallserial": "short",

	"text":      "string",
	"varchar":   "string",
	"char":      "string",
	"character": "string",
	"citext":    "string",
	"bpchar":    "string",
	"uuid":      "Guid",

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

	"real":             "float",
	"float4":           "float",
	"double precision": "double",
	"float8":           "double",
	"numeric":          "decimal",
	"decimal":          "decimal",

	"timestamp":                   "DateTime",
	"timestamp without time zone": "DateTime",
	"timestamp with time zone":    "DateTimeOffset",
	"timestamptz":                 "DateTimeOffset",
	"date":                        "DateTime",
	"time":                        "TimeSpan",
	"time without time zone":      "TimeSpan",
	"time with time zone":         "DateTimeOffset",
	"timetz":                      "DateTimeOffset",

	"bytea": "byte[]",

	"json":  "string",
	"jsonb": "string",
}

CSharpTypeMap maps PostgreSQL types to C# types

View Source
var GoTypeMap = map[string]string{

	"integer":     "int32",
	"int":         "int32",
	"int4":        "int32",
	"smallint":    "int16",
	"int2":        "int16",
	"bigint":      "int64",
	"int8":        "int64",
	"serial":      "int32",
	"bigserial":   "int64",
	"smallserial": "int16",

	"text":      "string",
	"varchar":   "string",
	"char":      "string",
	"character": "string",
	"citext":    "string",
	"bpchar":    "string",

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

	"real":             "float32",
	"float4":           "float32",
	"double precision": "float64",
	"float8":           "float64",
	"numeric":          "float64",
	"decimal":          "float64",

	"timestamp":                   "time.Time",
	"timestamp without time zone": "time.Time",
	"timestamp with time zone":    "time.Time",
	"timestamptz":                 "time.Time",
	"date":                        "time.Time",
	"time":                        "time.Time",
	"time without time zone":      "time.Time",
	"time with time zone":         "time.Time",
	"timetz":                      "time.Time",

	"bytea": "[]byte",

	"uuid": "string",

	"json":  "string",
	"jsonb": "string",

	"array": "[]string",
}

GoTypeMap maps PostgreSQL types to Go types

View Source
var JavaTypeMap = map[string]string{

	"integer":     "Integer",
	"int":         "Integer",
	"int4":        "Integer",
	"smallint":    "Short",
	"int2":        "Short",
	"bigint":      "Long",
	"int8":        "Long",
	"serial":      "Integer",
	"bigserial":   "Long",
	"smallserial": "Short",

	"text":      "String",
	"varchar":   "String",
	"char":      "String",
	"character": "String",
	"citext":    "String",
	"bpchar":    "String",
	"uuid":      "UUID",

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

	"real":             "Float",
	"float4":           "Float",
	"double precision": "Double",
	"float8":           "Double",
	"numeric":          "BigDecimal",
	"decimal":          "BigDecimal",

	"timestamp":                   "Timestamp",
	"timestamp without time zone": "Timestamp",
	"timestamp with time zone":    "Timestamp",
	"timestamptz":                 "Timestamp",
	"date":                        "Date",
	"time":                        "Time",
	"time without time zone":      "Time",
	"time with time zone":         "Time",
	"timetz":                      "Time",

	"bytea": "byte[]",

	"json":  "String",
	"jsonb": "String",
}

JavaTypeMap maps PostgreSQL types to Java types

View Source
var PHPTypeMap = map[string]string{

	"integer":     "int",
	"int":         "int",
	"int4":        "int",
	"smallint":    "int",
	"int2":        "int",
	"bigint":      "int",
	"int8":        "int",
	"serial":      "int",
	"bigserial":   "int",
	"smallserial": "int",

	"text":      "string",
	"varchar":   "string",
	"char":      "string",
	"character": "string",
	"citext":    "string",
	"bpchar":    "string",
	"uuid":      "string",

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

	"real":             "float",
	"float4":           "float",
	"double precision": "float",
	"float8":           "float",
	"numeric":          "float",
	"decimal":          "float",

	"timestamp":                   "\\DateTime",
	"timestamp without time zone": "\\DateTime",
	"timestamp with time zone":    "\\DateTime",
	"timestamptz":                 "\\DateTime",
	"date":                        "\\DateTime",
	"time":                        "\\DateTime",
	"time without time zone":      "\\DateTime",
	"time with time zone":         "\\DateTime",
	"timetz":                      "\\DateTime",

	"bytea": "string",

	"json":  "array",
	"jsonb": "array",
}

PHPTypeMap maps PostgreSQL types to PHP types

View Source
var PythonTypeMap = map[string]string{

	"integer":     "int",
	"int":         "int",
	"int4":        "int",
	"smallint":    "int",
	"int2":        "int",
	"bigint":      "int",
	"int8":        "int",
	"serial":      "int",
	"bigserial":   "int",
	"smallserial": "int",

	"text":      "str",
	"varchar":   "str",
	"char":      "str",
	"character": "str",
	"citext":    "str",
	"bpchar":    "str",
	"uuid":      "UUID",

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

	"real":             "float",
	"float4":           "float",
	"double precision": "float",
	"float8":           "float",
	"numeric":          "Decimal",
	"decimal":          "Decimal",

	"timestamp":                   "datetime",
	"timestamp without time zone": "datetime",
	"timestamp with time zone":    "datetime",
	"timestamptz":                 "datetime",
	"date":                        "date",
	"time":                        "time",
	"time without time zone":      "time",
	"time with time zone":         "time",
	"timetz":                      "time",

	"bytea": "bytes",

	"json":  "dict",
	"jsonb": "dict",

	"array": "list",
}

PythonTypeMap maps PostgreSQL types to Python types

View Source
var RustTypeMap = map[string]string{

	"integer":     "i32",
	"int":         "i32",
	"int4":        "i32",
	"smallint":    "i16",
	"int2":        "i16",
	"bigint":      "i64",
	"int8":        "i64",
	"serial":      "i32",
	"bigserial":   "i64",
	"smallserial": "i16",

	"text":      "String",
	"varchar":   "String",
	"char":      "String",
	"character": "String",
	"citext":    "String",
	"bpchar":    "String",
	"uuid":      "String",

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

	"real":             "f32",
	"float4":           "f32",
	"double precision": "f64",
	"float8":           "f64",
	"numeric":          "f64",
	"decimal":          "f64",

	"timestamp":                   "NaiveDateTime",
	"timestamp without time zone": "NaiveDateTime",
	"timestamp with time zone":    "DateTime<Utc>",
	"timestamptz":                 "DateTime<Utc>",
	"date":                        "NaiveDate",
	"time":                        "NaiveTime",
	"time without time zone":      "NaiveTime",
	"time with time zone":         "DateTime<Utc>",
	"timetz":                      "DateTime<Utc>",

	"bytea": "Vec<u8>",

	"json":  "serde_json::Value",
	"jsonb": "serde_json::Value",
}

RustTypeMap maps PostgreSQL types to Rust types

View Source
var TypeScriptTypeMap = map[string]string{

	"integer":     "number",
	"int":         "number",
	"int4":        "number",
	"smallint":    "number",
	"int2":        "number",
	"bigint":      "number",
	"int8":        "number",
	"serial":      "number",
	"bigserial":   "number",
	"smallserial": "number",

	"text":      "string",
	"varchar":   "string",
	"char":      "string",
	"character": "string",
	"citext":    "string",
	"bpchar":    "string",
	"uuid":      "string",

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

	"real":             "number",
	"float4":           "number",
	"double precision": "number",
	"float8":           "number",
	"numeric":          "number",
	"decimal":          "number",

	"timestamp":                   "Date",
	"timestamp without time zone": "Date",
	"timestamp with time zone":    "Date",
	"timestamptz":                 "Date",
	"date":                        "Date",
	"time":                        "Date",
	"time without time zone":      "Date",
	"time with time zone":         "Date",
	"timetz":                      "Date",

	"bytea": "Buffer",

	"json":  "any",
	"jsonb": "any",

	"array": "any[]",
}

TypeScriptTypeMap maps PostgreSQL types to TypeScript types

Functions

func ExtractBaseType

func ExtractBaseType(sqlType string) string

ExtractBaseType extracts the base type from a SQL type string Examples: varchar(100) → varchar, numeric(10,2) → numeric

func NeedsTimeImport

func NeedsTimeImport(goType string) bool

NeedsTimeImport checks if a Go type requires the time package

func NormalizeType

func NormalizeType(sqlType string) string

NormalizeType normalizes a SQL type to its base form Alias for ExtractBaseType for backwards compatibility

func SQLToCSharp

func SQLToCSharp(sqlType string, nullable bool) string

SQLToCSharp converts SQL types to C# types

func SQLToGo

func SQLToGo(sqlType string, nullable bool) string

SQLToGo converts SQL types to Go types

func SQLToJava

func SQLToJava(sqlType string, nullable bool) string

SQLToJava converts SQL types to Java types

func SQLToPhp

func SQLToPhp(sqlType string, nullable bool) string

SQLToPhp converts SQL types to PHP types

func SQLToPython

func SQLToPython(sqlType string) string

SQLToPython converts SQL types to Python types

func SQLToRust

func SQLToRust(sqlType string, nullable bool) string

SQLToRust converts SQL types to Rust types

func SQLToTypeScript

func SQLToTypeScript(sqlType string, nullable bool) string

SQLToTypeScript converts SQL types to TypeScript types

Types

This section is empty.

Jump to

Keyboard shortcuts

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