Da looking for ideas/alternatives to providing a page/item count/navigation of items matching a GAE datastore query, ho trovato un suggerimento su come spostarsi indietro della pagina con un solo cursore di INVERSIONE DELL'ORDINE.L'impaginazione all'indietro con il cursore funziona ma manca un elemento
class CursorTests(test_utils.NDBTest):
def testFirst(self):
class Bar(model.Model):
value = model.IntegerProperty()
self.entities = []
for i in range(10):
e = Bar(value=i)
e.put()
self.entities.append(e)
q = Bar.query()
bars, next_cursor, more = q.order(Bar.key).fetch_page(3)
barz, another_cursor, more2 = q.order(-Bar.key).fetch_page(3, start_cursor=next_cursor)
self.assertEqual(len(bars), len(barz))
Sfortunatamente non è riuscito con questo errore.
Traceback (most recent call last): File "/Users/reiot/Documents/Works/appengine-ndb-experiment/ndb/query_test.py", line 32, in testFirst self.assertEqual(len(bars), len(baz)) AssertionError: 3 != 2
Sì, manca una voce in bound con query inversa.
bars = [Bar(key=Key('Bar', 1), value=0), Bar(key=Key('Bar', 2), value=1), Bar(key=Key('Bar', 3), value=2)]
bars = [Bar(key=Key('Bar', 2), value=1), Bar(key=Key('Bar', 1), value=0)]
Come posso risolvere questo problema?
Buona domanda. L'ho confermato. Ho chiamato gli esperti. Si comporta anche in questo modo sul datastore di produzione? –