Documentation
¶
Index ¶
- Variables
- func ExtractBaseType(sqlType string) string
- func NeedsTimeImport(goType string) bool
- func NormalizeType(sqlType string) string
- func SQLToCSharp(sqlType string, nullable bool) string
- func SQLToGo(sqlType string, nullable bool) string
- func SQLToJava(sqlType string, nullable bool) string
- func SQLToPhp(sqlType string, nullable bool) string
- func SQLToPython(sqlType string) string
- func SQLToRust(sqlType string, nullable bool) string
- func SQLToTypeScript(sqlType string, nullable bool) string
Constants ¶
This section is empty.
Variables ¶
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
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
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
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
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
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
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 ¶
ExtractBaseType extracts the base type from a SQL type string Examples: varchar(100) → varchar, numeric(10,2) → numeric
func NeedsTimeImport ¶
NeedsTimeImport checks if a Go type requires the time package
func NormalizeType ¶
NormalizeType normalizes a SQL type to its base form Alias for ExtractBaseType for backwards compatibility
func SQLToCSharp ¶
SQLToCSharp converts SQL types to C# types
func SQLToPython ¶
SQLToPython converts SQL types to Python types
func SQLToTypeScript ¶
SQLToTypeScript converts SQL types to TypeScript types
Types ¶
This section is empty.