Documentation ¶
Index ¶
- Variables
- func ConvertSQLGeometryToTypesGeometry(p sql.Geometry) types.Geometry
- func ConvertSQLLinestringToTypesLinestring(l sql.Linestring) types.Linestring
- func ConvertSQLPointToTypesPoint(p sql.Point) types.Point
- func ConvertSQLPolygonToTypesPolygon(p sql.Polygon) types.Polygon
- func ConvertTypesGeometryToSQLGeometry(g types.Geometry) sql.Geometry
- func ConvertTypesLinestringToSQLLinestring(l types.Linestring) sql.Linestring
- func ConvertTypesPointToSQLPoint(p types.Point) sql.Point
- func ConvertTypesPolygonToSQLPolygon(p types.Polygon) sql.Polygon
- func IsStringType(ti TypeInfo) bool
- type FloatWidth
- type Identifier
- type TypeConverter
- type TypeInfo
- func CreateBitTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateBlobStringTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateDatetimeTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateDecimalTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateEnumTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateFloatTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateInlineBlobTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateIntTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateSetTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateUintTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateVarBinaryTypeFromParams(params map[string]string) (TypeInfo, error)
- func CreateVarStringTypeFromParams(params map[string]string) (TypeInfo, error)
- func FromKind(kind types.NomsKind) TypeInfo
- func FromSqlType(sqlType sql.Type) (TypeInfo, error)
- func FromTypeParams(id Identifier, params map[string]string) (TypeInfo, error)
Constants ¶
This section is empty.
Variables ¶
var ( DateType = &datetimeType{sql.Date} DatetimeType = &datetimeType{sql.Datetime} TimestampType = &datetimeType{sql.Timestamp} )
var ( Float32Type = &floatType{sql.Float32} Float64Type = &floatType{sql.Float64} )
var ( Int8Type = &intType{sql.Int8} Int16Type = &intType{sql.Int16} Int24Type = &intType{sql.Int24} Int32Type = &intType{sql.Int32} Int64Type = &intType{sql.Int64} )
var ( Uint8Type = &uintType{sql.Uint8} Uint16Type = &uintType{sql.Uint16} Uint24Type = &uintType{sql.Uint24} Uint32Type = &uintType{sql.Uint32} Uint64Type = &uintType{sql.Uint64} )
var ( LegacyStringDefaultType = &varStringType{sql.CreateLongText(sql.Collation_Default)} StringDefaultType = &varStringType{sql.MustCreateStringWithDefaults(sqltypes.VarChar, 16383)} )
var GeometryType = &geometryType{sql.GeometryType{}, nil}
var Identifiers = map[Identifier]struct{}{ UnknownTypeIdentifier: {}, BitTypeIdentifier: {}, BlobStringTypeIdentifier: {}, BoolTypeIdentifier: {}, DatetimeTypeIdentifier: {}, DecimalTypeIdentifier: {}, EnumTypeIdentifier: {}, FloatTypeIdentifier: {}, JSONTypeIdentifier: {}, InlineBlobTypeIdentifier: {}, IntTypeIdentifier: {}, SetTypeIdentifier: {}, TimeTypeIdentifier: {}, TupleTypeIdentifier: {}, UintTypeIdentifier: {}, UuidTypeIdentifier: {}, VarBinaryTypeIdentifier: {}, VarStringTypeIdentifier: {}, YearTypeIdentifier: {}, GeometryTypeIdentifier: {}, PointTypeIdentifier: {}, LinestringTypeIdentifier: {}, PolygonTypeIdentifier: {}, }
var IncompatibleTypeConversion = errors.NewKind("`%s` cannot convert any values to `%s`")
var InvalidTypeConversion = errors.NewKind("`%s` cannot convert the value `%v` to `%s`")
var JSONType = &jsonType{sql.JSON}
var LinestringType = &linestringType{sql.LinestringType{}}
var PointType = &pointType{sql.PointType{}}
var PolygonType = &polygonType{sql.PolygonType{}}
var TimeType = &timeType{sql.Time}
var TupleType = &tupleType{}
This is for internal use only. Used in merge conflicts.
var UnhandledTypeConversion = errors.NewKind("`%s` does not know how to handle type conversions to `%s`")
var UuidType = &uuidType{sql.MustCreateString(sqltypes.Char, 36, sql.Collation_ascii_bin)}
var YearType = &yearType{sql.Year}
Functions ¶
func ConvertSQLLinestringToTypesLinestring ¶
func ConvertSQLLinestringToTypesLinestring(l sql.Linestring) types.Linestring
func ConvertTypesGeometryToSQLGeometry ¶
ConvertTypesGeometryToSQLGeometry basically makes a deep copy of sql.Geometry
func ConvertTypesLinestringToSQLLinestring ¶
func ConvertTypesLinestringToSQLLinestring(l types.Linestring) sql.Linestring
ConvertTypesLinestringToSQLLinestring basically makes a deep copy of sql.Linestring
func ConvertTypesPointToSQLPoint ¶
ConvertTypesPointToSQLPoint basically makes a deep copy of sql.Point
func ConvertTypesPolygonToSQLPolygon ¶
ConvertTypesPolygonToSQLPolygon basically makes a deep copy of sql.Linestring
func IsStringType ¶
IsStringType returns whether the given TypeInfo represents a CHAR, VARCHAR, or TEXT-derivative.
Types ¶
type FloatWidth ¶
type FloatWidth int8
type Identifier ¶
type Identifier string
const ( UnknownTypeIdentifier Identifier = "unknown" BitTypeIdentifier Identifier = "bit" BlobStringTypeIdentifier Identifier = "blobstring" BoolTypeIdentifier Identifier = "bool" DatetimeTypeIdentifier Identifier = "datetime" DecimalTypeIdentifier Identifier = "decimal" EnumTypeIdentifier Identifier = "enum" FloatTypeIdentifier Identifier = "float" JSONTypeIdentifier Identifier = "json" InlineBlobTypeIdentifier Identifier = "inlineblob" IntTypeIdentifier Identifier = "int" SetTypeIdentifier Identifier = "set" TimeTypeIdentifier Identifier = "time" TupleTypeIdentifier Identifier = "tuple" UintTypeIdentifier Identifier = "uint" UuidTypeIdentifier Identifier = "uuid" VarBinaryTypeIdentifier Identifier = "varbinary" VarStringTypeIdentifier Identifier = "varstring" YearTypeIdentifier Identifier = "year" GeometryTypeIdentifier Identifier = "geometry" PointTypeIdentifier Identifier = "point" LinestringTypeIdentifier Identifier = "linestring" PolygonTypeIdentifier Identifier = "polygon" )
func ParseIdentifier ¶
func ParseIdentifier(name string) Identifier
ParseIdentifier takes in an Identifier in string form and returns the matching Identifier. Returns UnknownTypeIdentifier when the string match is not found.
func (Identifier) String ¶
func (i Identifier) String() string
String returns a string representation of the identifier. This may later be used in parsing to retrieve the original identifier.
type TypeConverter ¶
type TypeConverter func(ctx context.Context, vrw types.ValueReadWriter, v types.Value) (types.Value, error)
TypeConverter is a function that is used to convert a Noms value from one TypeInfo to another.
func GetTypeConverter ¶
func GetTypeConverter(ctx context.Context, srcTi TypeInfo, destTi TypeInfo) (tc TypeConverter, needsConversion bool, err error)
GetTypeConverter returns a TypeConverter that will convert a Noms value from the source type to the destination type. If the source type does not have a valid converter for the destination type, then this returns an error. When the given types are similar enough, no conversion is needed, thus this will return false. In such cases, although a valid TypeConverter will still be returned, it is equivalent to calling IsValid on the destination TypeInfo. Rather than returning nil values, any such returned nils will instead be types.NullValue.
type TypeInfo ¶
type TypeInfo interface { // ConvertNomsValueToValue converts a Noms value to a go value. The expected NomsKind of the given // parameter is equivalent to the NomsKind returned by this type info. This is intended for retrieval // from storage, thus we do no validation as we assume the stored value is already validated against // the given type. ConvertNomsValueToValue(v types.Value) (interface{}, error) // ReadFrom reads a go value from a noms types.CodecReader directly ReadFrom(nbf *types.NomsBinFormat, reader types.CodecReader) (interface{}, error) // ConvertValueToNomsValue converts a go value or Noms value to a Noms value. The type of the Noms // value will be equivalent to the NomsKind returned from NomsKind. ConvertValueToNomsValue(ctx context.Context, vrw types.ValueReadWriter, v interface{}) (types.Value, error) // Equals returns whether the given TypeInfo is equivalent to this TypeInfo. Equals(other TypeInfo) bool // FormatValue returns the stringified version of the value. FormatValue(v types.Value) (*string, error) // GetTypeIdentifier returns an identifier for this type used for serialization. GetTypeIdentifier() Identifier // GetTypeParams returns a map[string]string containing the type parameters. This is used for // serialization and deserialization of type information. GetTypeParams() map[string]string // IsValid takes in a types.Value and returns whether it is valid for this type. IsValid(v types.Value) bool // NomsKind returns the NomsKind that best matches this TypeInfo. NomsKind() types.NomsKind // Promote will promote the current TypeInfo to the largest representing TypeInfo of the same kind, such as Int8 to Int64. Promote() TypeInfo // ToSqlType returns the TypeInfo as a sql.Type. If an exact match is able to be made then that is // the one returned, otherwise the sql.Type is the closest match possible. ToSqlType() sql.Type // Stringer results are used to inform users of the constraint's properties. fmt.Stringer }
TypeInfo is an interface used for encoding type information.
var BoolType TypeInfo = &boolType{sql.MustCreateBitType(1)}
var PseudoBoolType TypeInfo = &bitType{sql.MustCreateBitType(1)}
var UnknownType TypeInfo = &unknownType{}
func CreateBitTypeFromParams ¶
func CreateIntTypeFromParams ¶
func CreateSetTypeFromParams ¶
func FromSqlType ¶
FromSqlType takes in a sql.Type and returns the most relevant TypeInfo.
func FromTypeParams ¶
func FromTypeParams(id Identifier, params map[string]string) (TypeInfo, error)
FromTypeParams constructs a TypeInfo from the given identifier and parameters.