@@ -348,6 +348,19 @@ def _shortEntity(entity):
348348 return re .split (r"[.$]" , entity )[- 1 ] if entity else entity
349349
350350
351+ def _exists (truth , predicate ):
352+ """Existence probe helper: an unmapped entity/attribute makes the ORM query fail
353+ to compile (error page), which for a yes/no existence question is a definitive
354+ 'no'. Unlike value bisection - where a transient error must stay inconclusive so
355+ it never freezes a wrong bit - an inconclusive/error existence probe reads as
356+ false (matching the pre-recalibration oracle semantics these probes rely on)."""
357+
358+ try :
359+ return truth (predicate )
360+ except InconclusiveError :
361+ return False
362+
363+
351364def _bruteEntities (truth ):
352365 """Recover mapped entity names through the boolean oracle alone (no reflected
353366 diagnostic needed): a mapped name keeps the FROM clause valid, an unmapped one
@@ -356,7 +369,7 @@ def _bruteEntities(truth):
356369
357370 retVal = []
358371 for entity in HQL_COMMON_ENTITIES :
359- if truth ( "EXISTS(SELECT 1 FROM %s _h)" % entity ):
372+ if _exists ( truth , "EXISTS(SELECT 1 FROM %s _h)" % entity ):
360373 retVal .append (entity )
361374 return retVal
362375
@@ -370,7 +383,7 @@ def _enumFields(truth, entity):
370383 if len (fields ) >= HQL_MAX_FIELDS :
371384 break
372385 predicate = "EXISTS(SELECT _h.%s FROM %s _h)" % (field , entity )
373- if truth ( predicate ):
386+ if _exists ( truth , predicate ):
374387 fields .append (field )
375388 logger .info ("identified mapped attribute: '%s'" % field )
376389 return fields
0 commit comments