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

Change Datastore QueryResult#next? to use NOT_FINISHED #803

Merged
merged 1 commit into from
Aug 1, 2016
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 acceptance/datastore/datastore_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,16 @@
entities[2]["name"].must_equal arya["name"]
end

it "should paginate with all" do
query = Gcloud::Datastore::Query.new.
kind("Character").ancestor(book).
order("appearances")
entities = dataset.run(query).all.to_a
entities.count.must_equal 8
entities[0]["name"].must_equal rickard["name"]
entities[5]["name"].must_equal sansa["name"]
end

it "should resume from a start cursor" do
query = Gcloud::Datastore::Query.new.
kind("Character").ancestor(book).
Expand Down
2 changes: 1 addition & 1 deletion lib/gcloud/datastore/dataset/query_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def initialize arr = []
# end
#
def next?
!no_more?
not_finished?

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

end

##
Expand Down
9 changes: 4 additions & 5 deletions test/gcloud/datastore/query_results/all_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Google::Datastore::V1beta3::RunQueryResponse.new(
batch: Google::Datastore::V1beta3::QueryResultBatch.new(
entity_results: run_query_res_entities,
more_results: :MORE_RESULTS_AFTER_CURSOR,
more_results: :NOT_FINISHED,
end_cursor: "second-page-cursor".force_encoding("ASCII-8BIT")
)
)
Expand Down Expand Up @@ -101,10 +101,10 @@
end
first_entities.cursor.must_equal Gcloud::Datastore::Cursor.from_grpc("second-page-cursor")
first_entities.end_cursor.must_equal Gcloud::Datastore::Cursor.from_grpc("second-page-cursor")
first_entities.more_results.must_equal :MORE_RESULTS_AFTER_CURSOR
refute first_entities.not_finished?
first_entities.more_results.must_equal :NOT_FINISHED
assert first_entities.not_finished?
refute first_entities.more_after_limit?
assert first_entities.more_after_cursor?
refute first_entities.more_after_cursor?
refute first_entities.no_more?

assert first_entities.next?
Expand Down Expand Up @@ -137,7 +137,6 @@
refute next_entities.next?
end


it "run will fulfill a query and return an object that can paginate with all" do
entities = dataset.run dataset.query("Task")
entities.all.each do |entity|
Expand Down
4 changes: 2 additions & 2 deletions test/gcloud/datastore/query_results/all_with_more_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Google::Datastore::V1beta3::RunQueryResponse.new(
batch: Google::Datastore::V1beta3::QueryResultBatch.new(
entity_results: run_query_res_entities,
more_results: :MORE_RESULTS_AFTER_CURSOR,
more_results: :NOT_FINISHED,
end_cursor: "second-page-cursor".force_encoding("ASCII-8BIT")
)
)
Expand All @@ -64,7 +64,7 @@
Google::Datastore::V1beta3::RunQueryResponse.new(
batch: Google::Datastore::V1beta3::QueryResultBatch.new(
entity_results: run_query_res_entities,
more_results: :MORE_RESULTS_AFTER_CURSOR,
more_results: :NOT_FINISHED,
end_cursor: "third-page-cursor".force_encoding("ASCII-8BIT")
)
)
Expand Down