Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spanner: Add a .one and .one_or_none method. #3784

Merged
merged 2 commits into from
Aug 11, 2017

Conversation

lukesneeringer
Copy link
Contributor

@tseaver @jonparrott @vkedia This is a proposal that fixes #3021. I have not implemented tests yet because I want feedback on the surface first.

I basically followed the SQLAlchemy model; the iterator that comes back gets a .one() and .one_or_none() method, in lieu of a read_row() method on Database objects (although it would be easy to implement one and have it call this).

Essentially, where a developer calls .read() now, he or she could call .read().one() and get the single-result behavior.

If this is workable, then I will write tests.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 10, 2017
@lukesneeringer lukesneeringer self-assigned this Aug 10, 2017
@lukesneeringer lukesneeringer added api: spanner Issues related to the Spanner API. and removed cla: yes This human has signed the Contributor License Agreement. labels Aug 10, 2017
@theacodes
Copy link
Contributor

This seems sane to me.

@tseaver tseaver added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 10, 2017
@tseaver
Copy link
Contributor

tseaver commented Aug 10, 2017

The surface looks fine to me.

@vkedia
Copy link

vkedia commented Aug 10, 2017

cc @mcurtiss

@lukesneeringer
Copy link
Contributor Author

Okay, I will whip up tests.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 10, 2017
@lukesneeringer lukesneeringer removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 10, 2017
@lukesneeringer
Copy link
Contributor Author

@jonparrott @tseaver Requesting a review.

@lukesneeringer lukesneeringer merged commit 7e960e6 into googleapis:master Aug 11, 2017
@lukesneeringer lukesneeringer deleted the issue-3021 branch August 11, 2017 16:52
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a convenience method to fetch data for a single row
5 participants