mirror of https://github.com/jackc/pgx.git
Added SanitizeSql bool support
parent
2699bf6187
commit
f079d84728
|
@ -60,6 +60,8 @@ func (c *Connection) SanitizeSql(sql string, args ...interface{}) (output string
|
|||
return strconv.FormatFloat(float64(arg), 'f', -1, 32)
|
||||
case float64:
|
||||
return strconv.FormatFloat(arg, 'f', -1, 64)
|
||||
case bool:
|
||||
return strconv.FormatBool(arg)
|
||||
case []byte:
|
||||
return `E'\\x` + hex.EncodeToString(arg) + `'`
|
||||
case []int16:
|
||||
|
|
|
@ -31,6 +31,10 @@ func TestSanitizeSql(t *testing.T) {
|
|||
t.Errorf("Failed to pass through float: %v - %v", san, err)
|
||||
}
|
||||
|
||||
if san, err := conn.SanitizeSql("select $1", true); err != nil || san != "select true" {
|
||||
t.Errorf("Failed to pass through bool: %v - %v", san, err)
|
||||
}
|
||||
|
||||
if san, err := conn.SanitizeSql("select $1, $2, $3", "Jack's", 42, 1.23); err != nil || san != "select 'Jack''s', 42, 1.23" {
|
||||
t.Errorf("Failed to sanitize multiple params: %v - %v", san, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue