Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sql/types/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type GeometryValue interface {
}

var _ sql.Type = GeometryType{}
var _ sql.ValueType = GeometryType{}
var _ sql.SpatialColumnType = GeometryType{}
var _ sql.CollationCoercible = GeometryType{}

Expand Down Expand Up @@ -486,6 +487,26 @@ func (t GeometryType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltype
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface
func (t GeometryType) CompareValue(c *sql.Context, v sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for GeometryType")
}

// SQLValue implements the ValueType interface
func (t GeometryType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t GeometryType) String() string {
return "geometry"
Expand Down
20 changes: 20 additions & 0 deletions sql/types/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,26 @@ func (t JsonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Va
return sqltypes.MakeTrusted(sqltypes.TypeJSON, val), nil
}

// CompareValue implements the ValueType interface
func (t JsonType) CompareValue(c *sql.Context, v sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for JsonType")
}

// SQLValue implements the ValueType interface
func (t JsonType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.TypeJSON, v.Val), nil
}

// String implements Type interface.
func (t JsonType) String() string {
return "json"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/linestring.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type LineString struct {
}

var _ sql.Type = LineStringType{}
var _ sql.ValueType = LineStringType{}
var _ sql.SpatialColumnType = LineStringType{}
var _ sql.CollationCoercible = LineStringType{}
var _ GeometryValue = LineString{}
Expand Down Expand Up @@ -108,6 +109,26 @@ func (t LineStringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqlty
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t LineStringType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for LineStringType")
}

// SQLValue implements the ValueType interface.
func (t LineStringType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t LineStringType) String() string {
return "linestring"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/multilinestring.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
)

var _ sql.Type = MultiLineStringType{}
var _ sql.ValueType = MultiLineStringType{}
var _ sql.SpatialColumnType = MultiLineStringType{}
var _ sql.CollationCoercible = MultiLineStringType{}
var _ GeometryValue = MultiLineString{}
Expand Down Expand Up @@ -111,6 +112,26 @@ func (t MultiLineStringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t MultiLineStringType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for MultiLineStringType")
}

// SQLValue implements the ValueType interface.
func (t MultiLineStringType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t MultiLineStringType) String() string {
return "multilinestring"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/multipoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type MultiPoint struct {
}

var _ sql.Type = MultiPointType{}
var _ sql.ValueType = MultiPointType{}
var _ sql.SpatialColumnType = MultiPointType{}
var _ sql.CollationCoercible = MultiPointType{}
var _ GeometryValue = MultiPoint{}
Expand Down Expand Up @@ -115,6 +116,26 @@ func (t MultiPointType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqlty
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t MultiPointType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for MultiPointType")
}

// SQLValue implements the ValueType interface.
func (t MultiPointType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t MultiPointType) String() string {
return "multipoint"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/multipolygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
)

var _ sql.Type = MultiPolygonType{}
var _ sql.ValueType = MultiPolygonType{}
var _ sql.SpatialColumnType = MultiPolygonType{}
var _ sql.CollationCoercible = MultiPolygonType{}
var _ GeometryValue = MultiPolygon{}
Expand Down Expand Up @@ -111,6 +112,26 @@ func (t MultiPolygonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sql
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t MultiPolygonType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for MultiPolygonType")
}

// SQLValue implements the ValueType interface.
func (t MultiPolygonType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t MultiPolygonType) String() string {
return "multipolygon"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Point struct {
}

var _ sql.Type = PointType{}
var _ sql.ValueType = PointType{}
var _ sql.SpatialColumnType = PointType{}
var _ sql.CollationCoercible = PointType{}
var _ GeometryValue = Point{}
Expand Down Expand Up @@ -123,6 +124,26 @@ func (t PointType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.V
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t PointType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for PointType")
}

// SQLValue implements the ValueType interface.
func (t PointType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t PointType) String() string {
return "point"
Expand Down
21 changes: 21 additions & 0 deletions sql/types/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Polygon struct {
}

var _ sql.Type = PolygonType{}
var _ sql.ValueType = PolygonType{}
var _ sql.SpatialColumnType = PolygonType{}
var _ sql.CollationCoercible = PolygonType{}
var _ GeometryValue = Polygon{}
Expand Down Expand Up @@ -113,6 +114,26 @@ func (t PolygonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes
return sqltypes.MakeTrusted(sqltypes.Geometry, buf), nil
}

// CompareValue implements the ValueType interface.
func (t PolygonType) CompareValue(c *sql.Context, value sql.Value, value2 sql.Value) (int, error) {
panic("TODO: implement CompareValue for PolygonType")
}

// SQLValue implements the ValueType interface.
func (t PolygonType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.Value, error) {
if v.IsNull() {
return sqltypes.NULL, nil
}
if v.Val == nil {
var err error
v.Val, err = v.WrappedVal.Unwrap(ctx)
if err != nil {
return sqltypes.Value{}, err
}
}
return sqltypes.MakeTrusted(sqltypes.Geometry, v.Val), nil
}

// String implements Type interface.
func (t PolygonType) String() string {
return "polygon"
Expand Down