dialect/sql: add driver.Valuer to ParamFormatter example

This commit is contained in:
Ariel Mashraki
2021-05-03 13:56:55 +03:00
committed by Ariel Mashraki
parent d64c10dae2
commit efd225822c

View File

@@ -6,6 +6,7 @@ package sql
import (
"context"
"database/sql/driver"
"fmt"
"strconv"
"strings"
@@ -1520,11 +1521,17 @@ type point struct {
*testing.T
}
// FormatParam implements the sql.ParamFormatter interface.
func (p point) FormatParam(placeholder string, info *StmtInfo) string {
require.Equal(p.T, dialect.MySQL, info.Dialect)
return "ST_GeomFromWKB(" + placeholder + ")"
}
// Value implements the driver.Valuer interface.
func (p point) Value() (driver.Value, error) {
return p.xy, nil
}
func TestParamFormatter(t *testing.T) {
p := point{xy: []float64{1, 2}, T: t}
query, args := Dialect(dialect.MySQL).