Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,31 @@ func (c *Conn) executeQuery(qry *Query) *Iter {
params: params,
}
} else {
values := qry.values

params.values = make([]queryValues, len(values))
hasSeenThVals := false
for i := 0; i < len(values); i++ {
v := &params.values[i]
value := values[i]
if thVal, isTh := value.(TypeHintedValue); isTh {
if !hasSeenThVals && i > 0 {
err := fmt.Errorf(
"type-hinted and non-hinted values must not be mixed")
return &Iter{err: err}
}
hasSeenThVals = true

if err := marshalQueryValue(thVal.TInfo, thVal.Value, v); err != nil {
return &Iter{err: err}
}
} else if hasSeenThVals {
err := fmt.Errorf(
"type-hinted and non-hinted values must not be mixed")
return &Iter{err: err}
}
}

frame = &writeQueryFrame{
statement: qry.stmt,
params: params,
Expand Down
2 changes: 1 addition & 1 deletion control.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (c *controlConn) HandleError(conn *Conn, err error, closed bool) {
}

oldConn := c.getConn()
if oldConn.conn != conn {
if oldConn != nil && oldConn.conn != conn {
return
}

Expand Down
6 changes: 6 additions & 0 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ type Unmarshaler interface {
UnmarshalCQL(info TypeInfo, data []byte) error
}

// TypeHintedValue is a hinted value to power binding non-prepared stmts
type TypeHintedValue struct {
Value interface{}
TInfo TypeInfo
}

// Marshal returns the CQL encoding of the value for the Cassandra
// internal type described by the info parameter.
func Marshal(info TypeInfo, value interface{}) ([]byte, error) {
Expand Down