func encodeSQLValue()

in pipe/sql.go [313:341]


func encodeSQLValue(tp string, d interface{}) string {
	switch f := d.(type) {
	case *sql.NullInt64:
		if f.Valid {
			return fmt.Sprintf("%v", f.Int64)
		}
	case *sql.NullString:
		if f.Valid {
			p := "'"
			if tp == clickhouse {
				return p + f.String + p //scan returns already escaped string, probably driver issue
			} else if tp == postgres {
				p = "E" + p
			}
			return p + util.MySQLEscape(true, f.String) + "'"
		}
	case *sql.NullFloat64:
		if f.Valid {
			return fmt.Sprintf("%v", f.Float64)
		}
	case *sql.RawBytes:
		if f != nil {
			return "0x" + hex.EncodeToString([]byte(*f))
		}
	default:
		return fmt.Sprintf("%v", d)
	}
	return "NULL"
}