mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql: add driver.Valuer to ParamFormatter example
This commit is contained in:
committed by
Ariel Mashraki
parent
d64c10dae2
commit
efd225822c
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user