Optional IQueryable<T> capability + in-house query AST (post-pilot follow-on) #9
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?
Migrated from uwe.admin/webapp-scaffold#10 per the Option A decision. Builds on uwe.admin/oatpp-authkit#7, uwe.admin/oatpp-authkit#8.
AST + IQueryable capability lands under
oatpp-authkit/include/oatpp-authkit/repo/next to the core repo headers.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 oatpp-authkitDecision 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.Evaluation carried over from closed uwe.admin/webapp-scaffold#10; the migration comment at the top of this issue body summarises the prior eval. No additional design questions remain.
Implemented #9 → commit
55516d4(include/oatpp-authkit/repo/IQueryable.hpp, ~250 LOC;test/test_queryable.cpp, 12 cases; README updated). Surface: equality / range / IN / LIKE / NULL / AND / OR / NOT / ORDER BY / LIMIT / OFFSET.field<&Dto::col>()with macro-registered column names;Query<T>::toSql()returns text + bind bag. All 7 ctest cases pass.Implemented in
55516d4(and verified — 7/7 tests pass, IQueryable.hpp 323 LOC ≤500 budget). Auto-closed viaCloses #9.