Skip to content

Improve the .one() and .all() methods#71

Merged
Changaco merged 4 commits intomasterfrom
values
Sep 19, 2019
Merged

Improve the .one() and .all() methods#71
Changaco merged 4 commits intomasterfrom
values

Conversation

@Changaco
Copy link
Copy Markdown
Member

The starting point of this branch was that the .one() and .all() methods currently choke on queries like SELECT values FROM something, because they assume that a values attribute is a callable similar to the dict.values() method. This is fixed by changing the condition from hasattr(out, 'values') to callable(getattr(out, 'values', None)), but while I was at it I also reorganized the code and added a few more tests.

When unpacking a row that contains a single item, always try `rec[0]` first, and only fall back to `tuple(rec.values())[0]` after checking that `rec.values` is callable.
@Changaco Changaco merged commit 1ee522e into master Sep 19, 2019
@Changaco Changaco deleted the values branch September 19, 2019 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant