Filtering by a non-relational scalar's length can already be accomplished via regex, e.g., ['Form', 'transcription', 'regex', '^.{15}$'] will return all Forms whose transcription has 15 characters.
Filtering by the count of a relational collection, i.e., getting all forms with 2 glosses or all collections with more than 50 forms is a bit more complicated: you have to use subqueries and joins. Below I show how to do it in SQLAlchemy.
Implementing this in SQLAQueryBuilder in an open-ended way may be tricky. I was thinking of allowing attribute names to have a 'dot' syntax so that a filter expression like ['Collection', 'files.count', '>', '50'] would return all collections with more than 50 forms associated. The tricky part would be keeping track of subqueries & joins. Anyways, no time for this now ...
How to get all Forms with 2 glosses
stmt = Session.query(model.Gloss.form_id, func.count('*').
label('gloss_count')).
group_by(model.Gloss.form_id).subquery()
r = Session.query(model.Form).
outerjoin(stmt, model.Form.id==stmt.c.form_id).
filter(stmt.c.gloss_count==2).all()
How to get all Forms with 2 files
stmt = Session.query(model.FormFile.form_id, func.count('*').
label('file_count')).
group_by(model.FormFile.form_id).subquery()
r = Session.query(model.Form).
outerjoin(stmt, model.Form.id==stmt.c.form_id).
filter(stmt.c.file_count==2).all()