Skip to content

fix(test): reject mocks reached through reference calls that read referencing helpers - #1035

Merged
kvlonge merged 1 commit into
mainfrom
fix/mock-reachability-p013
Oct 8, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/mock-reachability-p013

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Why

Compile reports P013 when a mock the test uses reads a helper that calls a reference, because mocks are defined before the models a test runs and such a helper cannot resolve. That check only counted mocks a check reads by CTE name. A mock reached through a reference call, such as __source("item_returns") resolving to __source__item_returns, was missed, so the test compiled and then failed at run time with a missing table. The mock-only P013 also pointed at a source call when the message was about the model, and told users to "keep" a __ref() they had not written.

Changes

  • Mocks reached through reference calls in expected rows, assertions and the helpers they read now count as used. These are the same reads that drive helper resolution. A used mock that reads a helper calling a reference, directly or through a middle helper, fails compile with a located P013.
  • The mock-only P013 points at the mocked model's __ref( call when a check reads both a mocked source and a mocked model.
  • When the check reads the mocked model by CTE name, such as FROM __ref__items, its help says to call __ref("items") instead of keep it.

Python-only change; no native code touched.

Verification

  • DuckDB E2E on the python, native and native-preview engines: the reported repro, both directly and through a middle helper, plus both message cases. The new mock cases fail without the fix.
  • The bundled example projects, the e2e fixture and a fresh playground still compile with no new errors
  • Focused compile and attachment tests, make compiler-differential-shipped, tests/e2e/scripts/compiler_differential, make check-ci, hygiene scan

…erencing helpers

A mock a check reaches through a reference call such as __source("orders"),
directly or from a helper the check reads, is now checked like a mock read by
CTE name, so one that reads a helper calling a reference fails compile with a
located P013 instead of failing at run time. The mock-only P013 now points at
the mocked model's __ref() call, and its help says to call __ref() when the
check reads the mock by CTE name.
@kvlonge
kvlonge enabled auto-merge (squash) October 8, 2026 14:14
@kvlonge
kvlonge merged commit 4ba74a0 into main Oct 8, 2026
33 checks passed
@kvlonge
kvlonge deleted the fix/mock-reachability-p013 branch October 8, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant