Skip to content

feat(firestore): add limit_to_last samples #4196

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

Merged
merged 5 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions firestore/cloud-client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,16 @@ def order_where_limit():
print(results)


def order_limit_to_last():
db = firestore.Client()
# [START fs_order_by_name_limit_query]
cities_ref = db.collection("cities")
query = cities_ref.order_by("name").limit_to_last(2)
results = query.get()
# [END fs_order_by_name_limit_query]
print(results)


def order_where_valid():
db = firestore.Client()
# [START order_where_valid]
Expand Down
4 changes: 4 additions & 0 deletions firestore/cloud-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ def test_order_where_limit():
snippets.order_where_limit()


def test_order_limit_to_last():
snippets.order_limit_to_last()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to check the output?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IlyaFaer Could you comment on this?

You can return the results in the function and check them here if that's easier than checking the string output.

results = snippets.order_limit_to_last()
assert ...

Copy link
Author

@IlyaFaer IlyaFaer Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that slipped my radars. Yeah, I thought about that, but most of the snippets tests are written this way - just a call to snippet function. So, as I see it, if we're gonna add an assert, we should do this for all the tests to keep the fashion, which probably should be done in a separate issue. Adding an assert into this single test, while other similar tests doesn't have it, looks weird. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create an issue for it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will make a /cc to you when created. And I think I'll do this



def test_order_where_invalid():
snippets.order_where_invalid()

Expand Down