Repository navigation
Description
Part of #138
Popularity: 1/7 corpus consumers (sqlgen)
Related issues
Related to #92 (Prototype unified wrapper composition, recursive trait peeling, and deep-unwrap, closed as out-of-scope for a broad wrapper rewrite) and #147 (wrapper boilerplate); however, exposing read-only public reflection-protocol traits is much narrower in scope than a full wrapper rewrite.
Problem
reflect-cpp's custom-type reflection protocol (T::ReflectionType + .reflection() and external rfl::Reflector<T> specializations) is checked internally via private rfl::internal::* traits (has_reflection_type_v, has_reflection_method_v, has_read_reflector, has_write_reflector, etc.), with no public traits or concepts for downstream libraries building their own schema/query/serialization layers on top of reflect-cpp.
Consequently, downstream consumers that want to honor reflect-cpp's custom-type and wrapper types (rfl::Pattern, rfl::Email, rfl::Timestamp, rfl::UUIDv*, sqlgen::PrimaryKey, sqlgen::ForeignKey, sqlgen::Unique, sqlgen::Varchar, etc.) must:
- Re-invent their own
has_reflection_methodconcept and recursiveRemoveReflection/is_nullablepeeling traits; - Hard-code stop-recursion exceptions for
reflect-cppsemantic wrappers likerfl::Timestamp<_format>(which exposesReflectionType = std::string); and - Often miss external
rfl::Reflector<T>specializations altogether, forcing users to write redundant specializations for bothrfl::Reflector<T>and the downstream library's own traits.
Observed Downstream Workaround
munich-data-engineering/sqlgen (265b0a17)
-
Hand-rolled
has_reflection_methodconcept:include/sqlgen/transpilation/has_reflection_method.hpp#L8-L11:template <typename T> concept has_reflection_method = requires(T _t) { { _t.reflection() } -> std::convertible_to<typename T::ReflectionType>; };
- Used across
include/sqlgen/parsing/Parser_default.hpp#L23-L26,L70-L83,include/sqlgen/duckdb/parsing/Parser_reflection_type.hpp#L15-L38,include/sqlgen/transpilation/to_value.hpp#L44-L45, andinclude/sqlgen/transpilation/is_nullable.hpp#L33-L41.
-
Hand-rolled recursive
RemoveReflectionwith manualrfl::Timestampspecial-case:include/sqlgen/transpilation/remove_reflection_t.hpp#L15-L48:template <rfl::internal::StringLiteral _format> struct RemoveReflection<rfl::Timestamp<_format>> { using Type = rfl::Timestamp<_format>; }; template <class T> requires has_reflection_method<T> struct RemoveReflection<T> { using Type = typename RemoveReflection<typename T::ReflectionType>::Type; };
-
External
rfl::Reflector<T>not unified with custom-type reflection:- Because
sqlgenonly re-implementshas_reflection_method(and has no publicrfl::has_reflector_v<T>/rfl::reflect_to/rfl::reflect_fromhelper), supporting a third-party type likeboost::uuids::uuidrequires writing separatesqlgen::parsing::Parser,sqlgen::duckdb::parsing::Parser,sqlgen::transpilation::ToValue, andrfl::Reflector<boost::uuids::uuid>specializations (seetests/sqlite/test_dynamic_type.cpp#L13-L66andtests/duckdb/test_dynamic_type.cpp#L14-L93).
- Because
Root Cause in reflect-cpp & Suggested Direction
reflect-cpp's reflection-protocol detection traits (has_reflection_type_v, has_reflection_method_v, has_read_reflector, has_write_reflector) are confined to rfl::internal::. Exposing a small, read-only public traits header (e.g., rfl::has_reflection_method_v<T>, rfl::has_reflector_v<T>, rfl::reflection_type_t<T>) would let downstream libraries cleanly support both .reflection() types and rfl::Reflector<T> specializations without duplicating internal detection logic.
Upstream Overlap
- "Standardize" interface for getting the underlying data in
rfl::wrapper-types munich-data-engineering/reflect-cpp#192 (open, partial) — "'Standardize' interface for getting the underlying data inrfl::wrapper-types", filed by an SQL-binding (SOCI) consumer hitting the same custom-trait /rfl::Timestampspecial-casing friction when integratingrfl::wrapper types into an external reflection layer. - Unfiled upstream: Public read-only reflection-protocol traits (
rfl::has_reflection_method_v<T>,rfl::has_reflector_v<T>,rfl::reflection_type_t<T>).
Activity
clockblocker commentedon Nov 29, 2026
Triage decision: closing as
wontfix(not planned) for the upstream adoption track.Rationale:
sqlgen-only custom-reflection / wrapper-peeling traits (has_reflection_method/RemoveReflection).sqlgenis authored byreflect-cpp's own maintainer; if wanted inrfl, he can promote it directly. Zero external adoption leverage.