feroult / yawp

Kotlin/Java API framework for Google Appengine
http://yawp.io
MIT License
132 stars 20 forks source link

Query using "IN" condition returns null cursor #29

Closed danilodeLuca closed 9 years ago

danilodeLuca commented 9 years ago

Checkout the test bellow:

@Test
    public void testQueryUsingINCursorReturnsNull() {
        Child child = yawp.save(new Child("xpto1", yawp.save(new Parent()).getId()));
        Child child2 = yawp.save(new Child("xpto2", yawp.save(new Parent()).getId()));

        DatastoreQuery<Child> query = yawp(Child.class).limit(1);
        List<Child> list = query.list();
        Assert.assertEquals(1, list.size());
        Assert.assertNotNull(query.getCursor());

        DatastoreQuery<Child> query2 = yawp(Child.class).where(c("id", "in",Arrays.asList(child.getId(), child2.getId())));
        List<Child> list2 = query2.list();
        Assert.assertEquals(2, list2.size());
        Assert.assertNotNull(query2.getCursor());///fail
    }
feroult commented 9 years ago

@danilodeLuca It is a limitation of the datastore cursor mechanism. Since IN queries are executed as multiple index queries, it cannot create a cursor:

https://cloud.google.com/appengine/docs/java/datastore/queries#Java_Limitations_of_cursors