z5labs/gogm

Empty result of queryRaw executing in transaction

palandlom opened this issue · 1 comments

When I try to execute raw query in opened transaction I get empty result - e.g:

config := ogm.NewBaseGogmConfig()
config.Host = "127.0.0.1"
config.Port = 7687
config.Username = "neo4j"
config.Password = "1"

_gogm, err := gogm.New(&config, ogm.NewSeIdKeyStartegy(), ogm.GetGogmTypes()...)
require.Nil(t, err)

sess, err := (*_gogm).NewSessionV2(gogm.SessionConfig{
AccessMode: gogm.AccessModeWrite,
})
require.Nil(t, err)

// === Open transaction ===
err = sess.Begin(context.Background())
require.Nil(t, err)

query := "MATCH (n) RETURN n"
res, _, err := sess.QueryRaw(context.Background(), query, map[string]interface{}{})
require.Nil(t, err)
require.NotEmpty(t, res)

res is empty in that case but If I comment out string err = sess.Begin(context.Background()) then all is OK - I get normal result.

PS: I have no such problem with execution of non-raw queries in transaction - i.e. with:

part := Part{}
err := s.Query(context.Background(), query, param, &part)

Hi @palandlom,
I reproduced and fixed the error. The problem was it was parsing the result before consuming the stream. There's an integration test to verify the fix as well.

Please update your GoGM version to v2.3.1 and reopen this issue if the problem persists