Optional IQueryable<T> capability + in-house query AST (post-pilot follow-on) #10
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Optional follow-on capability for the
Repository<T>layer (parent: uwe.admin/fewo-webapp#458). Not blocking the current refactor — the pilot (uwe.admin/fewo-webapp#457) and Phases 4–7 should land first.Why
Repository<T>::list(filter)covers simple cases. Anything beyond "single-field equality" currently forces controllers to either reach into the underlying*Dbfor a hand-writtenQUERY, or pull rows and filter in C++. Both undo the point of the abstraction.A typed query builder restores the abstraction without the cost of a
std::functionpredicate (which can't push down to SQL — see in-conversation discussion).Scope
Add to webapp-scaffold a small expression-tree DSL and an optional capability interface:
Internally:
AndNode,OrNode,EqNode,LtNode,GtNode,InNode,LikeNode,IsNullNode, plusOrderBy,Limit,Offset).Schema<TDto>registration that maps members to column names. (Kept generic so the DSL doesn't know about specific tables.)Constraints
DbClient— emits SQL strings + a parameter bag the concrete repo can hand to oatpp's prepared-statement mechanism. Does not replaceQUERYmacros for simple cases.Out of scope (explicit non-goals)
COUNT,SUM,GROUP BY) — separate issue if ever neededRepository<T>::saveIQueryable— that comes per-entity, after the pilot validates the Repository layerSequencing
Acceptance
IQueryable<T>interface,Query<T>builder, AST nodes, and SQL emitter compile in webapp-scaffoldDecision deferred to implementation time
Schema<TDto>registration is a class template specialization, a free function, or a macro. Pick whichever produces the cleanest call site once we have 2–3 entities to test against.Agent Evaluation
Drafted as a follow-on capability after in-conversation discussion of predicate-based queries. Body above is the evaluation.
Feasibility: Bounded design — pointer-to-member + visitor pattern is well-trodden ground. The 500-LOC budget is the discipline that keeps it tractable.
Impact: Closes the last common reason for controllers to reach back into raw SQL: complex filters. Without it, the Repository abstraction leaks for any non-trivial query.
Effort: Medium. AST + visitor + tests. Larger than the decorators (uwe.admin/webapp-scaffold#9) but smaller than adopting sqlite_orm/sqlpp11 wholesale.
Recommendation: Accept, but do not implement until parent uwe.admin/fewo-webapp#458 Phases 1–3 land. Real query patterns from the pilot inform the AST surface — designing it sooner risks getting the operator set wrong.
Closed in favour of uwe.admin/oatpp-authkit#9 per the Option A decision (this issue's #8 thread). C++ work belongs in oatpp-authkit, not in this TypeScript scaffold package.