def orm_eval(predicate, instance):
    manager = type(instance)._default_manager

    orm_value = manager.filter(predicate, pk=instance.pk).exists()
    super_value = original_eval(predicate, instance)
    assert_equal(orm_value, super_value)

    return super_value
Implementation of P semantics that asserts the ORM and P have the same
dataset/ETHPy150Open django-predicate/django-predicate/predicate/debug.py/orm_eval