def test_query_limit(client): """Add a LIMIT clause to the last example. """ query = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping":"IS NOT NULL"}) query.setLimit( (0,10) ) print(str(query)) res = client.search(query) assert len(res) == 10
def test_query_limit(client): """Add a LIMIT clause to the last example. """ query = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping": "IS NOT NULL"}) query.setLimit((0, 10)) print(str(query)) res = client.search(query) assert len(res) == 10
def cleanup(): query = Query(client, "Dataset", conditions={"name": "LIKE '%s-%%'" % testDatasetName}) wipe_data(client, query) query.setLimit((0, 500)) while True: objs = client.search(query) if not objs: break client.deleteMany(objs) client.logout()
def test_query_limit_placeholder(client): """LIMIT clauses are particular useful with placeholders. """ query = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping":"IS NOT NULL"}) query.setLimit( ("%d","%d") ) print(str(query)) print(str(query) % (0,30)) res = client.search(str(query) % (0,30)) assert len(res) == 30 print(str(query) % (30,30)) res = client.search(str(query) % (30,30)) assert len(res) == 14
def cleanup(): shutil.rmtree(proposaldir) client.login(conf.auth, conf.credentials) query = Query(client, "Dataset", conditions={"name": "LIKE '%s-%%'" % testDatasetPrefix}) wipe_data(client, query) query.setLimit((0, 500)) while True: objs = client.search(query) if not objs: break client.deleteMany(objs) client.logout()
def test_query_limit_placeholder(client): """LIMIT clauses are particular useful with placeholders. """ query = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping": "IS NOT NULL"}) query.setLimit(("%d", "%d")) print(str(query)) print(str(query) % (0, 30)) res = client.search(str(query) % (0, 30)) assert len(res) == 30 print(str(query) % (30, 30)) res = client.search(str(query) % (30, 30)) assert len(res) == 14
print("%d result(s)" % len(client.search(q))) print("\nRule does not have a constraint, id is included in the natural order.") q = Query(client, "Rule", order=True) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nOrdering on nullable relations emits a warning.") q = Query(client, "Rule", order=['grouping', 'what', 'id']) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nThe warning can be suppressed by making the condition explicit.") q = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping":"IS NOT NULL"}) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nAdd a LIMIT clause to the last example.") q.setLimit( (0,10) ) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nLIMIT clauses are particular useful with placeholders.") q.setLimit( ("%d","%d") ) print(str(q)) print(str(q) % (0,30)) print("%d result(s)" % len(client.search(str(q) % (0,30)))) print(str(q) % (30,30)) print("%d result(s)" % len(client.search(str(q) % (30,30))))
"\nRule does not have a constraint, id is included in the natural order.") q = Query(client, "Rule", order=True) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nOrdering on nullable relations emits a warning.") q = Query(client, "Rule", order=['grouping', 'what', 'id']) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nThe warning can be suppressed by making the condition explicit.") q = Query(client, "Rule", order=['grouping', 'what', 'id'], conditions={"grouping": "IS NOT NULL"}) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nAdd a LIMIT clause to the last example.") q.setLimit((0, 10)) print(str(q)) print("%d result(s)" % len(client.search(q))) print("\nLIMIT clauses are particular useful with placeholders.") q.setLimit(("%d", "%d")) print(str(q)) print(str(q) % (0, 30)) print("%d result(s)" % len(client.search(str(q) % (0, 30)))) print(str(q) % (30, 30)) print("%d result(s)" % len(client.search(str(q) % (30, 30))))