Description
DatastoreTemplate methods queryKeysSlice/queryKeysOrEntities do not iterate over results, and because of that, the cursor is not populated.
The results should be iterated in this reference, as it is already mentioned here.
Spring Cloud version 7.4.5
Sample
// More than one record in datastore
assertTrue(datastoreTemplate.queryKeys(query).iterator().hasNext());
// Using queryKeysSlice
Slice<Key> results = datastoreTemplate.queryKeysSlice(query, Key.class, Pageable.ofSize(1));
assertTrue(results.hasNext());
assertInstanceOf(DatastorePageable.class, results.nextPageable());
assertTrue(((DatastorePageable) results.nextPageable()).getUrlSafeCursor().isEmpty()); // Should not be empty
// Using queryKeysOrEntities
KeyQuery queryWithLimit = query.toBuilder().setLimit(1).build();
var objects = datastoreTemplate.queryKeysOrEntities(queryWithLimit, Key.class);
assertTrue(objects.getCursor().toUrlSafe().isEmpty()); // Should not be empty
// Workaround to use cursor with Key class
objects = datastoreTemplate.queryIterable(query, Function.identity());
assertFalse(objects.getCursor().toUrlSafe().isEmpty());
Description
DatastoreTemplatemethodsqueryKeysSlice/queryKeysOrEntitiesdo not iterate over results, and because of that, the cursor is not populated.The results should be iterated in this reference, as it is already mentioned here.
Spring Cloud version
7.4.5Sample