Skip to content

FK Distribution Strategies

By default, SqlProof picks parent rows uniformly when generating FK references. Distribution strategies let you simulate realistic skew or adversarial boundary cases.

proof.customize(
    "orders",
    fk_distribution={"customer_id": "uniform"},
)

proof.customize(
    "orders",
    fk_distribution={"customer_id": "zipf"},
)

proof.customize(
    "line_items",
    fk_distribution={"product_id": "adversarial"},
)
StrategyBehavior
uniformEach parent row has equal probability
zipfEarly parents are referenced more often
adversarialOnly first, middle, and last parents are used
singleAll children point to one parent
from hypothesis import strategies as st


def hottest_parent(parent_pks, ctx):
    return st.just(parent_pks[0])


proof.customize(
    "orders",
    fk_distribution={"customer_id": hottest_parent},
)

The callable returns a strategy, not a value, so Hypothesis can still shrink counterexamples.