max-melentyev commented on PR #1959:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1959#issuecomment-4711347617

   Query.Release() was removed in #1868, and the PR description recommends 
users to re-use Query objects instead. So I assume a code should be changed 
this way:
   ```go
   // v1
   query := session.Query("UPDATE x SET y = ? WHERE z = ?", y1, z1)
   query.Exec()
   query.Release()
   query := session.Query("UPDATE x SET y = ? WHERE z = ?", y2, z2) // Will 
reuse query object from memory pool
   query.Exec()
   
   // v2
   query := session.Query("UPDATE x SET y = ? WHERE z = ?", y1, z1)
   query.Exec()
   query := query.Bind(y2, z2)
   query.Exec()
   ```
   
   However there's no API for re-using queries created with session.Bind() 
method. This pr adds this API.
   
   My use-case is to add support for queries with named params and binding 
values from maps similar to gocqlx. Something like
   ```go
   namedQuery := parse("UPDATE x SET y = :y WHERE z = :z")
   query := session.New(namedQuery.CQL())
   namedQuery.BindMap(query, map[string]any{"y": y1, "z": z1})
   ```
   
   While I can user query.Bind() to set values, i need to set binding to make 
query fail in the case namedQuery.Bind cannot find necessary arguments:
   ```go
   namedQuery.BindMap(query, map[string]any{"y": y1})
   // I'd like to call this inside BindMap:
   query.Binding(func(_ QueryInfo) ([]any, error) { return nil, fmt.Errorf("z 
is missing") })
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to