Skip to content

Should QueryResults extend Iterable rather than Iterator? #101

Closed
@eamonnmcmanus

Description

@eamonnmcmanus

If QueryResults<T> extended Iterable<T> rather than Iterator<T> then it could be used in a for-each loop:

QueryResults<Entity> results = datastore.run(query);
for (Entity result : results) {...}

However, this is potentially confusing, because the Iterable interface implies that the result can be iterated more than once, so we would either have to document that an attempt to do so will fail, or make it so that every time you call iterator() a new query is issued. Neither of these is very desirable, so perhaps we should just add a note to QueryResults that heads off this obvious question that users are going to ask.

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions