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

Changes for v1beta3 #145

Merged
merged 1 commit into from
Apr 2, 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
2 changes: 1 addition & 1 deletion datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java-datastore</artifactId>
<version>0.1.5</version>
<version>0.1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
import com.google.gcloud.datastore.Query;
import com.google.gcloud.datastore.Query.ResultType;
import com.google.gcloud.datastore.QueryResults;
import com.google.gcloud.datastore.ReadOption;
import com.google.gcloud.datastore.StringValue;
import com.google.gcloud.datastore.StructuredQuery;
import com.google.gcloud.datastore.StructuredQuery.CompositeFilter;
import com.google.gcloud.datastore.StructuredQuery.OrderBy;
import com.google.gcloud.datastore.StructuredQuery.Projection;
import com.google.gcloud.datastore.StructuredQuery.PropertyFilter;
import com.google.gcloud.datastore.Transaction;
import com.google.gcloud.datastore.testing.LocalGcdHelper;
Expand Down Expand Up @@ -373,7 +373,8 @@ private void setUpQueryTests() {
.set("priority", 4)
.set("created", includedDate)
.set("percent_complete", 10.0)
.set("description", StringValue.builder("Learn Cloud Datastore").indexed(false).build())
.set("description",
StringValue.builder("Learn Cloud Datastore").excludeFromIndexes(true).build())
.set("tag", "fun", "l", "programming")
.build());
}
Expand Down Expand Up @@ -512,7 +513,7 @@ public void testProjectionQuery() {
// [START projection_query]
Query<ProjectionEntity> query = Query.projectionEntityQueryBuilder()
.kind("Task")
.projection(Projection.property("priority"), Projection.property("percent_complete"))
.projection("priority", "percent_complete")
.build();
// [END projection_query]
assertValidQuery(query);
Expand All @@ -523,7 +524,7 @@ public void testRunProjectionQuery() {
setUpQueryTests();
Query<ProjectionEntity> query = Query.projectionEntityQueryBuilder()
.kind("Task")
.projection(Projection.property("priority"), Projection.property("percent_complete"))
.projection("priority", "percent_complete")
.build();
// [START run_query_projection]
List<Long> priorities = new LinkedList<>();
Expand Down Expand Up @@ -565,8 +566,8 @@ public void testDistinctQuery() {
// [START distinct_query]
Query<ProjectionEntity> query = Query.projectionEntityQueryBuilder()
.kind("Task")
.projection(Projection.property("type"), Projection.property("priority"))
.groupBy("type", "priority")
.projection("type", "priority")
.distinctOn("type", "priority")
.orderBy(OrderBy.asc("type"), OrderBy.asc("priority"))
.build();
// [END distinct_query]
Expand All @@ -579,8 +580,8 @@ public void testDistinctOnQuery() {
// [START distinct_on_query]
Query<ProjectionEntity> query = Query.projectionEntityQueryBuilder()
.kind("Task")
.projection(Projection.property("type"), Projection.first("priority"))
.groupBy("type")
.projection("type", "priority")
.distinctOn("type")
.orderBy(OrderBy.asc("type"), OrderBy.asc("priority"))
.build();
// [END distinct_on_query]
Expand Down Expand Up @@ -726,9 +727,16 @@ private Cursor cursorPaging(int pageSize, Cursor pageCursor) {

@Test
public void testEventualConsistentQuery() {
setUpQueryTests();
// [START eventual_consistent_query]
// Read consistency cannot be specified in gcloud-java.
Query<Entity> query = Query.entityQueryBuilder()
.kind("Task")
.filter(PropertyFilter.hasAncestor(
datastore.newKeyFactory().kind("TaskList").newKey("default")))
.build();
datastore.run(query, ReadOption.eventualConsistency());
// [END eventual_consistent_query]
assertValidQuery(query);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TaskList {
Key addTask(String description) {
Key key = datastore.allocateId(keyFactory.newKey());
Entity task = Entity.builder(key)
.set("description", StringValue.builder(description).indexed(false).build())
.set("description", StringValue.builder(description).excludeFromIndexes(true).build())
.set("created", DateTime.now())
.set("done", false)
.build();
Expand Down