Normalize results return

Description

Getting back a list or PagedResult can result in confusion, and possible code breakage when crossing fetch_size rows. For example, len(results) works with lists, breaks with the pagedResult.

We need to normalize this somehow.

Environment

None

Pull Requests

None

Activity

Show:
Adam Holmberg
October 8, 2015, 10:12 PM

https://github.com/datastax/python-driver/pull/415

What I was going for:

  • always return the same type of object

  • extend some backwards-compatibility by offering a "list mode" if the result set is accessed like that, as opposed to iterator

    • prevent list mode if results were iterated

    • warn if materializing list when results are paged

In this way, there should be no surprising changes within a given application context. No mode of access will ever break if result size changes, but they will receive warnings.

Adam Holmberg
October 13, 2015, 5:07 PM
Michael Penick
October 20, 2015, 5:44 PM

+1 Nice clean change. should ResultSet implement _len_? Might be useful.

Michael Penick
October 20, 2015, 6:30 PM
Edited

Disregard the _len_ comment explained that it's not implemented because _current_rows might not be something that has length (lazy results).

Greg Bestland
October 21, 2015, 6:40 PM

Complete

Assignee

Unassigned

Reporter

Adam Holmberg

Fix versions

Labels

PM Priority

A

External issue ID

None

Doc Impact

None

Reviewer

None

Size

None

Pull Request

None

Sprint

Priority

Major
Configure