You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the QueryPredicate constructor (include/query_predicates.h), the member is located by scanning record.member_metadata for an entry whose offset matches the offset derived from the pointer-to-member:
for (auto i = 0; i < record.member_metadata.size(); ++i) {
if (record.member_metadata[i].offset == offset) {
member_name_ = record.member_metadata[i].name;
value_ = ...;
break;
}
}
If no entry matches (e.g. an unregistered type — see related issue #23 — or an offset-derivation problem), member_name_ stays empty and no error is raised.
Impact
Evaluate() then emits a clause like = ? (empty column name), producing malformed SQL that fails later at prepare time with a confusing message, rather than failing fast at the point of misuse.
Suggested direction
Throw a clear exception from the constructor when no member matches the pointer-to-member, naming the record type, so the error is reported at construction.
Put the throw ONLY in the member-matching QueryPredicate constructor(s) (the templated (fn, value, symbol, retrieval) one, which the (fn, value, symbol) overload delegates to). Do
NOT add it to the (symbol, member_name, value) constructor used by Clone(), and do NOT affect EmptyPredicate (the deliberate no-member, fetch-all path) — that must keep working.
Problem
In the
QueryPredicateconstructor (include/query_predicates.h), the member is located by scanningrecord.member_metadatafor an entry whoseoffsetmatches the offset derived from the pointer-to-member:If no entry matches (e.g. an unregistered type — see related issue #23 — or an offset-derivation problem),
member_name_stays empty and no error is raised.Impact
Evaluate()then emits a clause like= ?(empty column name), producing malformed SQL that fails later at prepare time with a confusing message, rather than failing fast at the point of misuse.Suggested direction
Throw a clear exception from the constructor when no member matches the pointer-to-member, naming the record type, so the error is reported at construction.
Notes for implementation
GetRecordFromTypeId(called atinclude/query_predicates.h:83) throw on an unregistered type, this constructor's own guardspecifically covers the registered-but-offset-mismatch case; both are needed.
QueryPredicateconstructor(s) (the templated(fn, value, symbol, retrieval)one, which the(fn, value, symbol)overload delegates to). DoNOT add it to the
(symbol, member_name, value)constructor used byClone(), and do NOT affectEmptyPredicate(the deliberate no-member, fetch-all path) — that must keep working.<stdexcept>may need including in the header.