@@ -49,6 +49,7 @@ type GeometryValue interface {
4949}
5050
5151var _ sql.Type = GeometryType {}
52+ var _ sql.ValueType = GeometryType {}
5253var _ sql.SpatialColumnType = GeometryType {}
5354var _ sql.CollationCoercible = GeometryType {}
5455
@@ -486,6 +487,26 @@ func (t GeometryType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltype
486487 return sqltypes .MakeTrusted (sqltypes .Geometry , buf ), nil
487488}
488489
490+ // CompareValue implements the ValueType interface
491+ func (t GeometryType ) CompareValue (c * sql.Context , v sql.Value , value2 sql.Value ) (int , error ) {
492+ panic ("TODO: implement CompareValue for GeometryType" )
493+ }
494+
495+ // SQLValue implements the ValueType interface
496+ func (t GeometryType ) SQLValue (ctx * sql.Context , v sql.Value , dest []byte ) (sqltypes.Value , error ) {
497+ if v .IsNull () {
498+ return sqltypes .NULL , nil
499+ }
500+ if v .Val != nil {
501+ return sqltypes .MakeTrusted (sqltypes .Geometry , v .Val ), nil
502+ }
503+ geomBytes , err := v .WrappedVal .Unwrap (ctx )
504+ if err != nil {
505+ return sqltypes.Value {}, err
506+ }
507+ return sqltypes .MakeTrusted (sqltypes .Geometry , geomBytes ), nil
508+ }
509+
489510// String implements Type interface.
490511func (t GeometryType ) String () string {
491512 return "geometry"
0 commit comments