Branch: master
Find file History
poy datastore: add error checking to Query.nextBatch
Currently, nextBatch will panic if the given query is somehow invalid.
This can happen when Filter is invoked with an invalid type:

```
type MyType int
var v MyType = 1
q := datastore.NewQuery("MyKind").Filter("fld=", v)
n, err := c.Count(ctx, q)
```

This happens because the type validation happens while running the query
and converting the query to protobuf (via toProto). If this fails, the
iterator will set an error, however nextBatch is not checking the error.
Therefore the iterator is in an invalid state and certain fields are
nil. When the user invokes Next again, the call panics (in nextBatch).

This CL fixes this problem by having nextBatch check the iterator's err
field.

Fixes #1306

Change-Id: I8cfe48a17258a1ab4a18580230bffc51e3b2c75c
Reviewed-on: https://code-review.googlesource.com/c/38170
Reviewed-by: Jean de Klerk <deklerk@google.com>
Latest commit 00c17f9 Feb 8, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
testdata cloud: fix the broken build Dec 2, 2014
client.go
datastore.go internal: clean ups triggered by staticcheck Jan 7, 2019
datastore.replay datastore: add datastore.replay Sep 7, 2018
datastore_test.go internal: clean ups triggered by staticcheck Jan 7, 2019
doc.go datastore: fix bug in example Feb 8, 2019
errors.go
example_test.go datastore: Add example for handling MultiError Nov 27, 2018
integration_test.go
key.go internal: inline context Nov 9, 2018
key_test.go all: modify copyright notice Jun 14, 2018
load.go
load_test.go internal: adds lint checker to CI Oct 23, 2018
mutation.go all: modify copyright notice Jun 14, 2018
mutation_test.go all: modify copyright notice Jun 14, 2018
oc_test.go all: remove 1.6, 1.7, 1.8 build flags and split files Nov 13, 2018
prop.go internal: clean ups triggered by staticcheck Jan 7, 2019
query.go
query_test.go datastore: add error checking to Query.nextBatch Feb 11, 2019
save.go all: small doc fixes Nov 7, 2018
save_test.go
time.go
time_test.go all: modify copyright notice Jun 14, 2018
transaction.go internal: inline context Nov 9, 2018
transaction_test.go internal: inline context Nov 9, 2018