diegogub / aranGO

Golang driver for ArangoDB
Apache License 2.0
125 stars 31 forks source link

Problem with FetchOne #24

Closed spaske closed 7 years ago

spaske commented 8 years ago

We found strange problem with FetchOne when using LIMIT in query. Code:

        ...
    q := ara.NewQuery("FOR i IN cities LIMIT 0,5 RETURN i")
    c, err := adb.DB("test").Execute(q)
    if err != nil {
        log.Fatalf("%s", err)
    }
    if c.Err {
        log.Fatalf("error %s\n", c.ErrMsg)
    }
    var doc City
    for c.FetchOne(&doc) {
        log.Printf("%#v", doc)
    }

It prints only first 4 items, because in cursor.go handling of Index and max in FetchOne is not correct. We didn't test, but code in FetchBatch looks like it has same problem. By looking in cursor.go - this would happen without limit too, last result would not be printed.