Here's the tl;dr of a real-world example[2]:
query = Query().SELECT(...).WHERE(...) for subtags in tags: tag_query = BaseQuery({'(': [], ')': ['']}, {'(': 'OR'}) tag_add = partial(tag_query.add, '(') for subtag in subtags: tag_add(subtag) query.WHERE(str(tag_query))
for subtags in tags: tag_query = QList('OR') for subtag in subtags: tag_query.append(subtag) query.WHERE(str(tag_query))
[2]: https://github.com/lemon24/reader/blob/10ccabb9186f531da04db...
Here's the tl;dr of a real-world example[2]:
It can be shortened by making a special subclass, but I only needed this once or twice so I didn't bother yet: [1]: https://death.andgravity.com/query-builder-how#more-init[2]: https://github.com/lemon24/reader/blob/10ccabb9186f531da04db...