Repository: ariga/atlas
Pull request #375 (2022-01-05 18:25:06)

sql: export column types for external usage


Patch:
diff --git a/sql/postgres/convert.go b/sql/postgres/convert.go
index 38bcde2f..710958c1 100644
--- a/sql/postgres/convert.go
+++ b/sql/postgres/convert.go
@@ -23,7 +23,7 @@ func FormatType(t schema.Type) (string, error) {
 	case *BitType:
 		f = strings.ToLower(t.T)
 		// BIT without a length is equivalent to BIT(1).
-		if f == tBit && t.Len == 0 {
+		if f == TypeBit && t.Len == 0 {
 			f = fmt.Sprintf("%s(1)", f)
 		}
 	case *schema.BoolType:
@@ -39,31 +39,31 @@ func FormatType(t schema.Type) (string, error) {
 		f = t.T
 	case *schema.IntegerType:
 		switch f = strings.ToLower(t.T); f {
-		case tSmallInt, tInteger, tBigInt:
-		case tInt2:
-			f = tSmallInt
-		case tInt, tInt4:
-			f = tInteger
-		case tInt8:
-			f = tBigInt
+		case TypeSmallInt, TypeInteger, TypeBigInt:
+		case TypeInt2:
+			f = TypeSmallInt
+		case TypeInt, TypeInt4:
+			f = TypeInteger
+		case TypeInt8:
+			f = TypeBigInt
 		}
 	case *schema.StringType:
 		switch f = strings.ToLower(t.T); f {
-		case tText:
+		case TypeText:
 		// CHAR(n) is alias for CHARACTER(n). If not length was
 		// specified, the definition is equivalent to CHARACTER(1).
-		case tChar, tCharacter:
+		case TypeChar, TypeCharacter:
 			n := t.Size
 			if n == 0 {
 				n = 1
 			}
-			f = fmt.Sprintf("%s(%d)", tCharacter, n)
+			f = fmt.Sprintf("%s(%d)", TypeCharacter, n)
 		// VARCHAR(n) is alias for CHARACTER VARYING(n). If not length
 		// was specified, the type accepts strings of any size.
-		case tVarChar, tCharVar:
-			f = tCharVar
+		case TypeVarChar, TypeCharVar:
+			f = TypeCharVar
 			if t.Size != 0 {
-				f = fmt.Sprintf("%s(%d)", tCharVar, t.Size)
+				f = fmt.Sprintf("%s(%d)", TypeCharVar, t.Size)
 			}
 		default:
 			return "", fmt.Errorf("postgres: unexpected string type: %q", t.T)
@@ -71,28 +71,28 @@ func FormatType(t schema.Type) (string, error) {
 	case *schema.TimeType:
 		switch f = strings.ToLower(t.T); f {
 		// TIMESTAMPTZ is accepted as an abbreviation for TIMESTAMP WITH TIME ZONE.
-		case tTimestampTZ:
-			f = tTimestampWTZ
+		case TypeTimestampTZ:
+			f = TypeTimestampWTZ
 		// TIME be equivalent to TIME WITHOUT TIME ZONE.
-		case tTime:
-			f = tTimeWOTZ
+		case TypeTime:
+			f = TypeTimeWOTZ
 		// TIMESTAMP be equivalent to TIMESTAMP WITHOUT TIME ZONE.
-		case tTimestamp:
-			f = tTimestampWOTZ
+		case TypeTimestamp:
+			f = TypeTimestampWOTZ
 		}
 	case *schema.FloatType:
 		switch f = strings.ToLower(t.T); f {
-		case tFloat4:
-			f = tReal
-		case tFloat8:
-			f = tDouble
+		case TypeFloat4:
+			f = TypeReal
+		case TypeFloat8:
+			f = TypeDouble
 		}
 	case *schema.DecimalType:
 		switch f = strings.ToLower(t.T); f {
-		case tNumeric:
+		case TypeNumeric:
 		// The DECIMAL type is an alias for NUMERIC.
-		case tDecimal:
-			f = tNumeric
+		case TypeDecimal:
+			f = TypeNumeric
 		default:
 			return "", fmt.Errorf("postgres: unexpected decimal type: %q", t.T)
 		}
@@ -109,13 +109,13 @@ func FormatType(t schema.Type) (string, error) {
 		}
 	case *SerialType:
 		switch f = strings.ToLower(t.T); f {
-		case tSmallSerial, tSerial, tBigSerial:
-		case tSerial2:
-			f = tSmallSerial
-		case tSerial4:
-			f = tSerial
-		case tSerial8:
-			f = tBigSerial
+		case TypeSmallSerial, TypeSerial, TypeBigSerial:
+		case TypeSerial2:
+			f = TypeSmallSerial
+		case TypeSerial4:
+			f = TypeSerial
+		case TypeSerial8:
+			f = TypeBigSerial
 		default:
 			return "", fmt.Errorf("postgres: unexpected serial type: %q", t.T)
 		}
@@ -170,11 +170,11 @@ func parseColumn(s string) (*columnDesc, error) {
 		}
 	)
 	switch c.parts[0] {
-	case tVarChar, tCharVar, tChar, tCharacter:
+	case TypeVarChar, TypeCharVar, TypeChar, TypeCharacter:
 		if err := parseCharParts(c.parts, c); err != nil {
 			return nil, err
 		}
-	case tDecimal, tNumeric:
+	case TypeDecimal, TypeNumeric:
 		if len(parts) > 1 {
 			c.precision, err = strconv.ParseInt(parts[1], 10, 64)
 			if err != nil {
@@ -187,13 +187,13 @@ func parseColumn(s string) (*columnDesc, error) {
 				return nil, fmt.Errorf("postgres: parse scale %q: %w", parts[1], err)
 			}
 		}
-	case tBit:
+	case TypeBit:
 		if err := parseBitParts(parts, c); err != nil {
 			return nil, err
 		}
-	case tDouble, tFloat8:
+	case TypeDouble, TypeFloat8:
 		c.precision = 53
-	case tReal, tFloat4:
+	case TypeReal, TypeFloat4:
 		c.precision = 24
 	default:
 		c.typ = s
@@ -204,11 +204,11 @@ func parseColumn(s string) (*columnDesc, error) {
 func parseCharParts(parts []string, c *columnDesc) error {
 	j := strings.Join(parts, " ")
 	switch {
-	case strings.HasPrefix(j, tVarChar):
-		c.typ = tVarChar
+	case strings.HasPrefix(j, TypeVarChar):
+		c.typ = TypeVarChar
 		parts = parts[1:]
-	case strings.HasPrefix(j, tCharVar):
-		c.typ = tCharVar
+	case strings.HasPrefix(j, TypeCharVar):
+		c.typ = TypeCharVar
 		parts = parts[2:]
 	default:
 		parts = parts[1:]
@@ -231,7 +231,7 @@ func parseBitParts(parts []string, c *columnDesc) error {
 	}
 	parts = parts[1:]
 	if parts[0] == "varying" {
-		c.typ = tBitVar
+		c.typ = TypeBitVar
 		parts = parts[1:]
 	}
 	if len(parts) == 0 {
diff --git a/sql/postgres/diff.go b/sql/postgres/diff.go
index bd6de676..5a2d0b85 100644
--- a/sql/postgres/diff.go
+++ b/sql/postgres/diff.go
@@ -134,12 +134,12 @@ func (d *diff) typeChanged(from, to *schema.Column) (bool, error) {
 		}
 		var it string
 		switch s.T {
-		case tSmallSerial:
-			it = tSmallInt
-		case tSerial:
-			it = tInteger
-		case tBigSerial:
-			it = tBigInt
+		case TypeSmallSerial:
+			it = TypeSmallInt
+		case TypeSerial:
+			it = TypeInteger
+		case TypeBigSerial:
+			it = TypeBigInt
 		}
 		return i.T != it, nil
 	}
diff --git a/sql/postgres/driver.go b/sql/postgres/driver.go
index 1208ce5b..3b24fd1a 100644
--- a/sql/postgres/driver.go
+++ b/sql/postgres/driver.go
@@ -72,69 +72,69 @@ func Open(db schema.ExecQuerier) (*Driver, error) {
 // Standard column types (and their aliases) as defined in
 // PostgreSQL codebase/website.
 const (
-	tBit     = "bit"
-	tBitVar  = "bit varying"
-	tBoolean = "boolean"
-	tBool    = "bool" // boolean.
-	tBytea   = "bytea"
-
-	tCharacter = "character"
-	tChar      = "char" // character
-	tCharVar   = "character varying"
-	tVarChar   = "varchar" // character varying
-	tText      = "text"
-
-	tSmallInt = "smallint"
-	tInteger  = "integer"
-	tBigInt   = "bigint"
-	tInt      = "int"  // integer.
-	tInt2     = "int2" // smallint.
-	tInt4     = "int4" // integer.
-	tInt8     = "int8" // bigint.
-
-	tCIDR     = "cidr"
-	tInet     = "inet"
-	tMACAddr  = "macaddr"
-	tMACAddr8 = "macaddr8"
-
-	tCircle  = "circle"
-	tLine    = "line"
-	tLseg    = "lseg"
-	tBox     = "box"
-	tPath    = "path"
-	tPolygon = "polygon"
-	tPoint   = "point"
-
-	tDate          = "date"
-	tTime          = "time" // time without time zone
-	tTimeWTZ       = "time with time zone"
-	tTimeWOTZ      = "time without time zone"
-	tTimestamp     = "timestamp" // timestamp without time zone
-	tTimestampTZ   = "timestamptz"
-	tTimestampWTZ  = "timestamp with time zone"
-	tTimestampWOTZ = "timestamp without time zone"
-
-	tDouble = "double precision"
-	tReal   = "real"
-	tFloat8 = "float8" // double precision
-	tFloat4 = "float4" // real
-
-	tNumeric = "numeric"
-	tDecimal = "decimal" // numeric
-
-	tSmallSerial = "smallserial" // smallint with auto_increment.
-	tSerial      = "serial"      // integer with auto_increment.
-	tBigSerial   = "bigserial"   // bigint with auto_increment.
-	tSerial2     = "serial2"     // smallserial
-	tSerial4     = "serial4"     // serial
-	tSerial8     = "serial8"     // bigserial
-
-	tArray       = "array"
-	tXML         = "xml"
-	tJSON        = "json"
-	tJSONB       = "jsonb"
-	tUUID        = "uuid"
-	tMoney       = "money"
-	tInterval    = "interval"
-	tUserDefined = "user-defined"
+	TypeBit     = "bit"
+	TypeBitVar  = "bit varying"
+	TypeBoolean = "boolean"
+	TypeBool    = "bool" // boolean.
+	TypeBytea   = "bytea"
+
+	TypeCharacter = "character"
+	TypeChar      = "char" // character
+	TypeCharVar   = "character varying"
+	TypeVarChar   = "varchar" // character varying
+	TypeText      = "text"
+
+	TypeSmallInt = "smallint"
+	TypeInteger  = "integer"
+	TypeBigInt   = "bigint"
+	TypeInt      = "int"  // integer.
+	TypeInt2     = "int2" // smallint.
+	TypeInt4     = "int4" // integer.
+	TypeInt8     = "int8" // bigint.
+
+	TypeCIDR     = "cidr"
+	TypeInet     = "inet"
+	TypeMACAddr  = "macaddr"
+	TypeMACAddr8 = "macaddr8"
+
+	TypeCircle  = "circle"
+	TypeLine    = "line"
+	TypeLseg    = "lseg"
+	TypeBox     = "box"
+	TypePath    = "path"
+	TypePolygon = "polygon"
+	TypePoint   = "point"
+
+	TypeDate          = "date"
+	TypeTime          = "time" // time without time zone
+	TypeTimeWTZ       = "time with time zone"
+	TypeTimeWOTZ      = "time without time zone"
+	TypeTimestamp     = "timestamp" // timestamp without time zone
+	TypeTimestampTZ   = "timestamptz"
+	TypeTimestampWTZ  = "timestamp with time zone"
+	TypeTimestampWOTZ = "timestamp without time zone"
+
+	TypeDouble = "double precision"
+	TypeReal   = "real"
+	TypeFloat8 = "float8" // double precision
+	TypeFloat4 = "float4" // real
+
+	TypeNumeric = "numeric"
+	TypeDecimal = "decimal" // numeric
+
+	TypeSmallSerial = "smallserial" // smallint with auto_increment.
+	TypeSerial      = "serial"      // integer with auto_increment.
+	TypeBigSerial   = "bigserial"   // bigint with auto_increment.
+	TypeSerial2     = "serial2"     // smallserial
+	TypeSerial4     = "serial4"     // serial
+	TypeSerial8     = "serial8"     // bigserial
+
+	TypeArray       = "array"
+	TypeXML         = "xml"
+	TypeJSON        = "json"
+	TypeJSONB       = "jsonb"
+	TypeUUID        = "uuid"
+	TypeMoney       = "money"
+	TypeInterval    = "interval"
+	TypeUserDefined = "user-defined"
 )
diff --git a/sql/postgres/inspect.go b/sql/postgres/inspect.go
index d2557a3e..a8ab32d2 100644
--- a/sql/postgres/inspect.go
+++ b/sql/postgres/inspect.go
@@ -212,49 +212,49 @@ func (i *inspect) addColumn(t *schema.Table, rows *sql.Rows) error {
 func columnType(c *columnDesc) schema.Type {
 	var typ schema.Type
 	switch t := c.typ; strings.ToLower(t) {
-	case tBigInt, tInt8, tInt, tInteger, tInt4, tSmallInt, tInt2:
+	case TypeBigInt, TypeInt8, TypeInt, TypeInteger, TypeInt4, TypeSmallInt, TypeInt2:
 		typ = &schema.IntegerType{T: t}
-	case tBit, tBitVar:
+	case TypeBit, TypeBitVar:
 		typ = &BitType{T: t, Len: c.size}
-	case tBool, tBoolean:
+	case TypeBool, TypeBoolean:
 		typ = &schema.BoolType{T: t}
-	case tBytea:
+	case TypeBytea:
 		typ = &schema.BinaryType{T: t}
-	case tCharacter, tChar, tCharVar, tVarChar, tText:
+	case TypeCharacter, TypeChar, TypeCharVar, TypeVarChar, TypeText:
 		// A `character` column without length specifier is equivalent to `character(1)`,
 		// but `varchar` without length accepts strings of any size (same as `text`).
 		typ = &schema.StringType{T: t, Size: int(c.size)}
-	case tCIDR, tInet, tMACAddr, tMACAddr8:
+	case TypeCIDR, TypeInet, TypeMACAddr, TypeMACAddr8:
 		typ = &NetworkType{T: t}
-	case tCircle, tLine, tLseg, tBox, tPath, tPolygon, tPoint:
+	case TypeCircle, TypeLine, TypeLseg, TypeBox, TypePath, TypePolygon, TypePoint:
 		typ = &schema.SpatialType{T: t}
-	case tDate, tTime, tTimeWTZ, tTimeWOTZ,
-		tTimestamp, tTimestampTZ, tTimestampWTZ, tTimestampWOTZ:
+	case TypeDate, TypeTime, TypeTimeWTZ, TypeTimeWOTZ,
+		TypeTimestamp, TypeTimestampTZ, TypeTimestampWTZ, TypeTimestampWOTZ:
 		typ = &schema.TimeType{T: t}
-	case tInterval:
+	case TypeInterval:
 		// TODO: get 'interval_type' from query above before implementing.
 		typ = &schema.UnsupportedType{T: t}
-	case tReal, tDouble, tFloat4, tFloat8:
+	case TypeReal, TypeDouble, TypeFloat4, TypeFloat8:
 		typ = &schema.FloatType{T: t, Precision: int(c.precision)}
-	case tJSON, tJSONB:
+	case TypeJSON, TypeJSONB:
 		typ = &schema.JSONType{T: t}
-	case tMoney:
+	case TypeMoney:
 		typ = &CurrencyType{T: t}
-	case tDecimal, tNumeric:
+	case TypeDecimal, TypeNumeric:
 		typ = &schema.DecimalType{T: t, Precision: int(c.precision), Scale: int(c.scale)}
-	case tSmallSerial, tSerial, tBigSerial, tSerial2, tSerial4, tSerial8:
+	case TypeSmallSerial, TypeSerial, TypeBigSerial, TypeSerial2, TypeSerial4, TypeSerial8:
 		typ = &SerialType{T: t, Precision: int(c.precision)}
-	case tUUID:
+	case TypeUUID:
 		typ = &UUIDType{T: t}
-	case tXML:
+	case TypeXML:
 		typ = &XMLType{T: t}
-	case tArray:
+	case TypeArray:
 		// Note that for ARRAY types, the 'udt_name' column holds the array type
 		// prefixed with '_'. For example, for 'integer[]' the result is '_int',
 		// and for 'text[N][M]' the result is also '_text'. That's because, the
 		// database ignores any size or multi-dimensions constraints.
 		typ = &ArrayType{T: strings.TrimPrefix(c.udt, "_") + "[]"}
-	case tUserDefined:
+	case TypeUserDefined:
 		typ = &UserDefinedType{T: c.udt}
 		// The `typtype` column is set to 'e' for enum types, and the
 		// values are filled in batch after the rows above is closed.
diff --git a/sql/postgres/sqlspec.go b/sql/postgres/sqlspec.go
index 08dac5cc..ec67111f 100644
--- a/sql/postgres/sqlspec.go
+++ b/sql/postgres/sqlspec.go
@@ -79,7 +79,7 @@ func parseRawType(typ string) (schema.Type, error) {
 	// Normalize PostgreSQL array data types from "CREATE TABLE" format to
 	// "INFORMATION_SCHEMA" format (i.e. as it is inspected from the database).
 	if t, ok := arrayType(typ); ok {
-		d = &columnDesc{typ: tArray, udt: t}
+		d = &columnDesc{typ: TypeArray, udt: t}
 	}
 
 	t := columnType(d)
@@ -135,58 +135,58 @@ var TypeRegistry = specutil.NewRegistry(
 	specutil.WithFormatter(FormatType),
 	specutil.WithParser(parseRawType),
 	specutil.WithSpecs(
-		specutil.TypeSpec(tBit, &schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64}),
-		specutil.AliasTypeSpec("bit_varying", tBitVar, &schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64}),
-		specutil.TypeSpec(tVarChar, specutil.SizeTypeAttr(true)),
-		specutil.AliasTypeSpec("character_varying", tCharVar, &schemaspec.TypeAttr{Name: "size", Kind: reflect.Int}),
-		specutil.TypeSpec(tChar, specutil.SizeTypeAttr(true)),
-		specutil.TypeSpec(tCharacter, specutil.SizeTypeAttr(true)),
-		specutil.TypeSpec(tInt2),
-		specutil.TypeSpec(tInt4),
-		specutil.TypeSpec(tInt8),
-		specutil.TypeSpec(tInt),
-		specutil.TypeSpec(tInteger),
-		specutil.TypeSpec(tSmallInt),
-		specutil.TypeSpec(tBigInt),
-		specutil.TypeSpec(tText),
-		specutil.TypeSpec(tBoolean),
-		specutil.TypeSpec(tBool),
-		specutil.TypeSpec(tBytea),
-		specutil.TypeSpec(tCIDR),
-		specutil.TypeSpec(tInet),
-		specutil.TypeSpec(tMACAddr),
-		specutil.TypeSpec(tMACAddr8),
-		specutil.TypeSpec(tCircle),
-		specutil.TypeSpec(tLine),
-		specutil.TypeSpec(tLseg),
-		specutil.TypeSpec(tBox),
-		specutil.TypeSpec(tPath),
-		specutil.TypeSpec(tPoint),
-		specutil.TypeSpec(tDate),
-		specutil.TypeSpec(tTime),
-		specutil.AliasTypeSpec("time_with_time_zone", tTimeWTZ),
-		specutil.AliasTypeSpec("time_without_time_zone", tTimeWOTZ),
-		specutil.TypeSpec(tTimestamp),
-		specutil.AliasTypeSpec("timestamp_with_time_zone", tTimestampWTZ),
-		specutil.AliasTypeSpec("timestamp_without_time_zone", tTimestampWOTZ),
+		specutil.TypeSpec(TypeBit, &schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64}),
+		specutil.AliasTypeSpec("bit_varying", TypeBitVar, &schemaspec.TypeAttr{Name: "len", Kind: reflect.Int64}),
+		specutil.TypeSpec(TypeVarChar, specutil.SizeTypeAttr(true)),
+		specutil.AliasTypeSpec("character_varying", TypeCharVar, &schemaspec.TypeAttr{Name: "size", Kind: reflect.Int}),
+		specutil.TypeSpec(TypeChar, specutil.SizeTypeAttr(true)),
+		specutil.TypeSpec(TypeCharacter, specutil.SizeTypeAttr(true)),
+		specutil.TypeSpec(TypeInt2),
+		specutil.TypeSpec(TypeInt4),
+		specutil.TypeSpec(TypeInt8),
+		specutil.TypeSpec(TypeInt),
+		specutil.TypeSpec(TypeInteger),
+		specutil.TypeSpec(TypeSmallInt),
+		specutil.TypeSpec(TypeBigInt),
+		specutil.TypeSpec(TypeText),
+		specutil.TypeSpec(TypeBoolean),
+		specutil.TypeSpec(TypeBool),
+		specutil.TypeSpec(TypeBytea),
+		specutil.TypeSpec(TypeCIDR),
+		specutil.TypeSpec(TypeInet),
+		specutil.TypeSpec(TypeMACAddr),
+		specutil.TypeSpec(TypeMACAddr8),
+		specutil.TypeSpec(TypeCircle),
+		specutil.TypeSpec(TypeLine),
+		specutil.TypeSpec(TypeLseg),
+		specutil.TypeSpec(TypeBox),
+		specutil.TypeSpec(TypePath),
+		specutil.TypeSpec(TypePoint),
+		specutil.TypeSpec(TypeDate),
+		specutil.TypeSpec(TypeTime),
+		specutil.AliasTypeSpec("time_with_time_zone", TypeTimeWTZ),
+		specutil.AliasTypeSpec("time_without_time_zone", TypeTimeWOTZ),
+		specutil.TypeSpec(TypeTimestamp),
+		specutil.AliasTypeSpec("timestamp_with_time_zone", TypeTimestampWTZ),
+		specutil.AliasTypeSpec("timestamp_without_time_zone", TypeTimestampWOTZ),
 		specutil.TypeSpec("enum", &schemaspec.TypeAttr{Name: "values", Kind: reflect.Slice, Required: true}),
-		specutil.AliasTypeSpec("double_precision", tDouble),
-		specutil.TypeSpec(tReal),
-		specutil.TypeSpec(tFloat8),
-		specutil.TypeSpec(tFloat4),
-		specutil.TypeSpec(tNumeric),
-		specutil.TypeSpec(tDecimal),
-		specutil.TypeSpec(tSmallSerial),
-		specutil.TypeSpec(tSerial),
-		specutil.TypeSpec(tBigSerial),
-		specutil.TypeSpec(tSerial2),
-		specutil.TypeSpec(tSerial4),
-		specutil.TypeSpec(tSerial8),
-		specutil.TypeSpec(tXML),
-		specutil.TypeSpec(tJSON),
-		specutil.TypeSpec(tJSONB),
-		specutil.TypeSpec(tUUID),
-		specutil.TypeSpec(tMoney),
+		specutil.AliasTypeSpec("double_precision", TypeDouble),
+		specutil.TypeSpec(TypeReal),
+		specutil.TypeSpec(TypeFloat8),
+		specutil.TypeSpec(TypeFloat4),
+		specutil.TypeSpec(TypeNumeric),
+		specutil.TypeSpec(TypeDecimal),
+		specutil.TypeSpec(TypeSmallSerial),
+		specutil.TypeSpec(TypeSerial),
+		specutil.TypeSpec(TypeBigSerial),
+		specutil.TypeSpec(TypeSerial2),
+		specutil.TypeSpec(TypeSerial4),
+		specutil.TypeSpec(TypeSerial8),
+		specutil.TypeSpec(TypeXML),
+		specutil.TypeSpec(TypeJSON),
+		specutil.TypeSpec(TypeJSONB),
+		specutil.TypeSpec(TypeUUID),
+		specutil.TypeSpec(TypeMoney),
 		specutil.TypeSpec("hstore"),
 		specutil.TypeSpec("sql", &schemaspec.TypeAttr{Name: "def", Required: true, Kind: reflect.String}),
 	),
diff --git a/sql/sqlite/driver.go b/sql/sqlite/driver.go
index 3e77a897..2b43d507 100644
--- a/sql/sqlite/driver.go
+++ b/sql/sqlite/driver.go
@@ -60,8 +60,8 @@ func Open(db schema.ExecQuerier) (*Driver, error) {
 // https://www.sqlite.org/datatype3.html
 // https://github.com/sqlite/sqlite/blob/master/src/global.c
 const (
-	tInteger = "integer" // SQLITE_TYPE_INTEGER
-	tReal    = "real"    // SQLITE_TYPE_REAL
-	tText    = "text"    // SQLITE_TYPE_TEXT
-	tBlob    = "blob"    // SQLITE_TYPE_BLOB
+	TypeInteger = "integer" // SQLITE_TYPE_INTEGER
+	TypeReal    = "real"    // SQLITE_TYPE_REAL
+	TypeText    = "text"    // SQLITE_TYPE_TEXT
+	TypeBlob    = "blob"    // SQLITE_TYPE_BLOB
 )
diff --git a/sql/sqlite/sqlspec.go b/sql/sqlite/sqlspec.go
index 64121abb..4286c751 100644
--- a/sql/sqlite/sqlspec.go
+++ b/sql/sqlite/sqlspec.go
@@ -76,10 +76,10 @@ var TypeRegistry = specutil.NewRegistry(
 	specutil.WithFormatter(FormatType),
 	specutil.WithParser(parseRawType),
 	specutil.WithSpecs(
-		specutil.TypeSpec(tReal, &schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false}),
-		specutil.TypeSpec(tBlob, specutil.SizeTypeAttr(false)),
-		specutil.TypeSpec(tText, specutil.SizeTypeAttr(false)),
-		specutil.TypeSpec(tInteger, specutil.SizeTypeAttr(false)),
+		specutil.TypeSpec(TypeReal, &schemaspec.TypeAttr{Name: "precision", Kind: reflect.Int, Required: false}, &schemaspec.TypeAttr{Name: "scale", Kind: reflect.Int, Required: false}),
+		specutil.TypeSpec(TypeBlob, specutil.SizeTypeAttr(false)),
+		specutil.TypeSpec(TypeText, specutil.SizeTypeAttr(false)),
+		specutil.TypeSpec(TypeInteger, specutil.SizeTypeAttr(false)),
 		specutil.TypeSpec("int", specutil.SizeTypeAttr(false)),
 		specutil.TypeSpec("tinyint", specutil.SizeTypeAttr(false)),
 		specutil.TypeSpec("smallint", specutil.SizeTypeAttr(false)),


Test patch:
diff --git a/sql/postgres/sqlspec_test.go b/sql/postgres/sqlspec_test.go
index 45fefd29..dcc2d333 100644
--- a/sql/postgres/sqlspec_test.go
+++ b/sql/postgres/sqlspec_test.go
@@ -163,205 +163,205 @@ func TestTypes(t *testing.T) {
 	}{
 		{
 			typeExpr: "bit(10)",
-			expected: &BitType{T: tBit, Len: 10},
+			expected: &BitType{T: TypeBit, Len: 10},
 		},
 		{
 			typeExpr: "bit_varying(10)",
-			expected: &BitType{T: tBitVar, Len: 10},
+			expected: &BitType{T: TypeBitVar, Len: 10},
 		},
 		{
 			typeExpr: "boolean",
-			expected: &schema.BoolType{T: tBoolean},
+			expected: &schema.BoolType{T: TypeBoolean},
 		},
 		{
 			typeExpr: "bool",
-			expected: &schema.BoolType{T: tBool},
+			expected: &schema.BoolType{T: TypeBool},
 		},
 		{
 			typeExpr: "bytea",
-			expected: &schema.BinaryType{T: tBytea},
+			expected: &schema.BinaryType{T: TypeBytea},
 		},
 		{
 			typeExpr: "varchar(255)",
-			expected: &schema.StringType{T: tVarChar, Size: 255},
+			expected: &schema.StringType{T: TypeVarChar, Size: 255},
 		},
 		{
 			typeExpr: "char(255)",
-			expected: &schema.StringType{T: tChar, Size: 255},
+			expected: &schema.StringType{T: TypeChar, Size: 255},
 		},
 		{
 			typeExpr: "character(255)",
-			expected: &schema.StringType{T: tCharacter, Size: 255},
+			expected: &schema.StringType{T: TypeCharacter, Size: 255},
 		},
 		{
 			typeExpr: "text",
-			expected: &schema.StringType{T: tText},
+			expected: &schema.StringType{T: TypeText},
 		},
 		{
 			typeExpr: "smallint",
-			expected: &schema.IntegerType{T: tSmallInt},
+			expected: &schema.IntegerType{T: TypeSmallInt},
 		},
 		{
 			typeExpr: "integer",
-			expected: &schema.IntegerType{T: tInteger},
+			expected: &schema.IntegerType{T: TypeInteger},
 		},
 		{
 			typeExpr: "bigint",
-			expected: &schema.IntegerType{T: tBigInt},
+			expected: &schema.IntegerType{T: TypeBigInt},
 		},
 		{
 			typeExpr: "int",
-			expected: &schema.IntegerType{T: tInt},
+			expected: &schema.IntegerType{T: TypeInt},
 		},
 		{
 			typeExpr: "int2",
-			expected: &schema.IntegerType{T: tInt2},
+			expected: &schema.IntegerType{T: TypeInt2},
 		},
 		{
 			typeExpr: "int4",
-			expected: &schema.IntegerType{T: tInt4},
+			expected: &schema.IntegerType{T: TypeInt4},
 		},
 		{
 			typeExpr: "int8",
-			expected: &schema.IntegerType{T: tInt8},
+			expected: &schema.IntegerType{T: TypeInt8},
 		},
 		{
 			typeExpr: "cidr",
-			expected: &NetworkType{T: tCIDR},
+			expected: &NetworkType{T: TypeCIDR},
 		},
 		{
 			typeExpr: "inet",
-			expected: &NetworkType{T: tInet},
+			expected: &NetworkType{T: TypeInet},
 		},
 		{
 			typeExpr: "macaddr",
-			expected: &NetworkType{T: tMACAddr},
+			expected: &NetworkType{T: TypeMACAddr},
 		},
 		{
 			typeExpr: "macaddr8",
-			expected: &NetworkType{T: tMACAddr8},
+			expected: &NetworkType{T: TypeMACAddr8},
 		},
 		{
 			typeExpr: "circle",
-			expected: &schema.SpatialType{T: tCircle},
+			expected: &schema.SpatialType{T: TypeCircle},
 		},
 		{
 			typeExpr: "line",
-			expected: &schema.SpatialType{T: tLine},
+			expected: &schema.SpatialType{T: TypeLine},
 		},
 		{
 			typeExpr: "lseg",
-			expected: &schema.SpatialType{T: tLseg},
+			expected: &schema.SpatialType{T: TypeLseg},
 		},
 		{
 			typeExpr: "box",
-			expected: &schema.SpatialType{T: tBox},
+			expected: &schema.SpatialType{T: TypeBox},
 		},
 		{
 			typeExpr: "path",
-			expected: &schema.SpatialType{T: tPath},
+			expected: &schema.SpatialType{T: TypePath},
 		},
 		{
 			typeExpr: "point",
-			expected: &schema.SpatialType{T: tPoint},
+			expected: &schema.SpatialType{T: TypePoint},
 		},
 
 		{
 			typeExpr: "date",
-			expected: &schema.TimeType{T: tDate},
+			expected: &schema.TimeType{T: TypeDate},
 		},
 		{
 			typeExpr: "time",
-			expected: &schema.TimeType{T: tTime},
+			expected: &schema.TimeType{T: TypeTime},
 		},
 		{
 			typeExpr: "time_with_time_zone",
-			expected: &schema.TimeType{T: tTimeWTZ},
+			expected: &schema.TimeType{T: TypeTimeWTZ},
 		},
 		{
 			typeExpr: "time_without_time_zone",
-			expected: &schema.TimeType{T: tTimeWOTZ},
+			expected: &schema.TimeType{T: TypeTimeWOTZ},
 		},
 		{
 			typeExpr: "timestamp",
-			expected: &schema.TimeType{T: tTimestamp},
+			expected: &schema.TimeType{T: TypeTimestamp},
 		},
 		{
 			typeExpr: "timestamp_with_time_zone",
-			expected: &schema.TimeType{T: tTimestampWTZ},
+			expected: &schema.TimeType{T: TypeTimestampWTZ},
 		},
 		{
 			typeExpr: "timestamp_without_time_zone",
-			expected: &schema.TimeType{T: tTimestampWOTZ},
+			expected: &schema.TimeType{T: TypeTimestampWOTZ},
 		},
 		{
 			typeExpr: "time",
-			expected: &schema.TimeType{T: tTime},
+			expected: &schema.TimeType{T: TypeTime},
 		},
 		{
 			typeExpr: "real",
-			expected: &schema.FloatType{T: tReal, Precision: 24},
+			expected: &schema.FloatType{T: TypeReal, Precision: 24},
 		},
 		{
 			typeExpr: "float8",
-			expected: &schema.FloatType{T: tFloat8, Precision: 53},
+			expected: &schema.FloatType{T: TypeFloat8, Precision: 53},
 		},
 		{
 			typeExpr: "float4",
-			expected: &schema.FloatType{T: tFloat4, Precision: 24},
+			expected: &schema.FloatType{T: TypeFloat4, Precision: 24},
 		},
 		{
 			typeExpr: "numeric",
-			expected: &schema.DecimalType{T: tNumeric},
+			expected: &schema.DecimalType{T: TypeNumeric},
 		},
 		{
 			typeExpr: "decimal",
-			expected: &schema.DecimalType{T: tDecimal},
+			expected: &schema.DecimalType{T: TypeDecimal},
 		},
 		{
 			typeExpr: "smallserial",
-			expected: &SerialType{T: tSmallSerial},
+			expected: &SerialType{T: TypeSmallSerial},
 		},
 		{
 			typeExpr: "serial",
-			expected: &SerialType{T: tSerial},
+			expected: &SerialType{T: TypeSerial},
 		},
 		{
 			typeExpr: "bigserial",
-			expected: &SerialType{T: tBigSerial},
+			expected: &SerialType{T: TypeBigSerial},
 		},
 		{
 			typeExpr: "serial2",
-			expected: &SerialType{T: tSerial2},
+			expected: &SerialType{T: TypeSerial2},
 		},
 		{
 			typeExpr: "serial4",
-			expected: &SerialType{T: tSerial4},
+			expected: &SerialType{T: TypeSerial4},
 		},
 		{
 			typeExpr: "serial8",
-			expected: &SerialType{T: tSerial8},
+			expected: &SerialType{T: TypeSerial8},
 		},
 
 		{
 			typeExpr: "xml",
-			expected: &XMLType{T: tXML},
+			expected: &XMLType{T: TypeXML},
 		},
 		{
 			typeExpr: "json",
-			expected: &schema.JSONType{T: tJSON},
+			expected: &schema.JSONType{T: TypeJSON},
 		},
 		{
 			typeExpr: "jsonb",
-			expected: &schema.JSONType{T: tJSONB},
+			expected: &schema.JSONType{T: TypeJSONB},
 		},
 		{
 			typeExpr: "uuid",
-			expected: &UUIDType{T: tUUID},
+			expected: &UUIDType{T: TypeUUID},
 		},
 		{
 			typeExpr: "money",
-			expected: &CurrencyType{T: tMoney},
+			expected: &CurrencyType{T: TypeMoney},
 		},
 		{
 			typeExpr: `sql("int[]")`,