I found out that SQLAlchemy translates
db.query(...).filter(A.id.in_(ids))
into
SELECT ...
FROM a
WHERE a.id != a.id
I'm using:
if len(ids) > 0:
db.query(...).where(A.id.in_(ids))
else:
db.query(...).where(False)
I tried a .limit(0)
instead of the .where(false)
without success. There is some behind-the-scenes difference in the empty querysets that broke other stuff down the pipeline. This workaround, while could be faster, at least avoids your mentioned warning.