Can anyone help with this? I have a query (see below)
dets = config.Se.query(db.A).filter(db.B.clientref != None,
db.A.id == db.B.clientref,
db.A.ignored == False).\
order_by(desc(db.B.date_lts))
if _querya != ():
tmp_dets = dets.filter(*_querya)
dets = tmp_dets
d_results2 = dets.limit(300).all()
d_results = dets.all()
print len(d_results2), len(d_results)
With my test query, the print statement returns 4 5.
What am I doing wrong? I am only selecting from table A (even though I use table B with many to one relation to A to limit and sort the result set). Let us assume table A contains clients and table B contains orders including date_lts (last seen), and I want to order the result set so that those clients with most recent orders are displayed first.
_querya we can ignore. It allows setting additional filters to query and this works fine.
I would like to limit the result set to max 300 lines from table A to avoid the GUI choking in case the user sets too wide query parameters. I noticed, however, that a test query that should return 5 rows (confirmed from database) returned only four.
To debug this I renamed the original query result set to d_results2 and created d_results without limit(300). And I can see a difference. d_results2 gets limited to four.
What is going on? I assumed limit(300) would not do anything as the result set in its entirety is just five rows.
Hannu