Do not release queries in Get/Select. Fix #25
Releasing query objects in Get/Select could easily lead to double-releases, which can cause dangerous and tricky data races. Remove the query field of Iterx and its usages (all release-related). This is a breaking API change, because it removes the exported method ReleaseQuery. Update documenting examples to demonstrate the deferred query release pattern clients can use to manage query release.
This commit is contained in:
committed by
Michał Matczuk
parent
255429a93c
commit
cbe2659e0d
@@ -146,6 +146,7 @@ func TestExample(t *testing.T) {
|
||||
q := gocqlx.Query(session.Query(stmt), names).BindMap(qb.M{
|
||||
"first_name": "Patricia",
|
||||
})
|
||||
defer q.Release()
|
||||
|
||||
var p Person
|
||||
if err := gocqlx.Get(&p, q.Query); err != nil {
|
||||
@@ -165,6 +166,7 @@ func TestExample(t *testing.T) {
|
||||
q := gocqlx.Query(session.Query(stmt), names).BindMap(qb.M{
|
||||
"first_name": []string{"Patricia", "Igy", "Ian"},
|
||||
})
|
||||
defer q.Release()
|
||||
|
||||
var people []Person
|
||||
if err := gocqlx.Select(&people, q.Query); err != nil {
|
||||
@@ -190,6 +192,7 @@ func TestExample(t *testing.T) {
|
||||
ToCql()
|
||||
|
||||
q := gocqlx.Query(session.Query(stmt), names).BindStruct(p)
|
||||
defer q.Release()
|
||||
|
||||
var people []Person
|
||||
if err := gocqlx.Select(&people, q.Query); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user