Which dataset a lookup field takes its values from
For each lookup field of a form: the dataset that holds its table unfiltered, proved from the DFM and the index, ranked, or the tier fallback.
Read this before wiring a lookup with repo write-dfm, or when a lookup shows blanks. drag-lint repo lookup-source --form <file.dfm> resolves each lookup field of the form that the repository holds: PROVED, ACCEPTED (a filtered holder reviewed with dl:ok lookup-source-filtered), RANKED (offered, unchecked, with the doubt), LAYER (the fieldrepo.lookup.tier fallback) or BLOCKED. --table lists every holder of a table, --tables the lookup tables of the repository. It writes nothing.
How to run it
Full flag list: repo in the CLI reference.
Flags
| Flag | Argument | Meaning | Default |
|---|---|---|---|
--table | <T> | ||
--form | <file.dfm> | ||
--tables | |||
--field | <Dataset.Field> | ||
--repo | <file> | ||
--project | <project file> | ||
--db | <index> | ||
--server-unit | <file> | ||
--explain | |||
--fail-on | blocked|ranked | ||
--json |
Where to click
No IDE surface: this feature runs from the CLI (see How to run it).
Details
drag-lint 1.62. Report only: writes nothing.
A lookup field (FieldKind = fkLookup) shows the value of a row of another table. The field repository stores
WHAT is looked up (DESTTABLE, DESTKEY, DESTVALUE) and, since schema 7, the owner's choice of holder
(LOOKUP_DATASET). At run time the lookup reads a DATASET: LookupDataSet. If that dataset holds only some rows
of the table (a WHERE, parameters, a master link, a filter set in code), the lookup shows blanks for the others.
repo lookup-source answers, for each lookup field: which dataset holds the lookup table UNFILTERED, how sure DL
is, and what it would wire. repo write-dfm uses the same answer for its lookup changes.
Usage
drag-lint repo lookup-source (--table <T> | --form <file.dfm> | --tables) [--field <Dataset.Field>]
(--repo <file> | --project <project file>) [--db <index>] [--explain] [--fail-on blocked|ranked] [--json]
| Flag | Meaning |
|---|---|
--form <file.dfm> | every lookup field of the form that the repository holds, each resolved |
--table <T> | alone: every holder of T in the project (needs the index); with --form: only lookups into T |
--field <Dataset.Field> | with --form: one field |
--tables | the lookup tables of the repository (distinct DESTTABLE, plus / minus fieldrepo.lookup.layer.tables / .tables_exclude) with the number of lookup fields and holders |
--db <index> | the project index; default: <project folder>\_D-RAG\<project>.sqlite of --project when it exists |
--explain | every reason with file:line under each candidate, and the stated limits |
--fail-on blocked|ranked | exit 2 when the worst status reaches it |
--json | one object, schema lookup-source/1 |
Exit codes: 0 report printed (any status); 1 bad arguments, repository / DFM / index error; 2 only with --fail-on.
Example
tier: not set
lookup uOrders.dfm qryOrders.UNITNAME -> UNITS (key ID, value NAME)
status: PROVED dmMain.qryUnits
1 proved dmMain.qryUnits data module in uses dfm opened stored current
- filtered qryLocal same form uOrders.pas:48 Filter
fallback: none not available: set fieldrepo.lookup.tier (1, 2 or 3) in drag-lint-project.json to generate a lookup source
repo lookup-source: 1 lookups; 1 proved, 0 accepted, 0 ranked, 0 layer, 0 blocked
Where DL looks (in this order)
| Origin | What |
|---|---|
| same form | a dataset of the form (the lookup's own dataset excluded) |
| inherited | an inherited dataset: its properties are tested along the whole ancestor DFM chain, its SELECT is the merged one |
| data module in uses | a dataset of any data module of the project (index) whose unit the form's unit uses; any folder |
| data module not in uses | the same, unit not used: offered with "adds the unit to the uses" |
| frame | a dataset inside a frame the form hosts |
| code-created | a dataset field created in code and loaded by a loader named in fieldrepo.lookup.loaders |
Another FORM's dataset is never a candidate (the lookup breaks when that form is closed). Without an index only the
form, its ancestors, its frames and the DFMs of the form's folder that its unit names are searched (the 1.61 rule),
and the report says index: none.
How sure DL is
- DFM test (always, on the DFM files): parameters, a master link,
Filtered = True,OnFilterRecord,FetchOptions.RecsMax/RecsSkip,WHERE/HAVING/FIRST/SKIP/ROWS/FETCH/OFFSET= filtered; SQL macros, a SELECT that is not understood or does not read the table alone, no SELECT = a doubt. - Code proof (needs the index): every mention of the dataset's field in the project is checked against an allow
list.
Open,Close,Locate,First, edits (Edit,Post, ...) and handing it toLookupDataSet/DataSet/Assignedpass;Filter,Filtered,SetRange,Params,MasterSource, ... = filtered; anything else (SQL,Open(sql), passing it to a routine, an unresolved mention,FindComponent, an event handler the index does not hold) = a doubt. The event handlers the DFM assigns are searched too. Settingsfieldrepo.lookup.safe_members/unsafe_membersadjust the list. - Reachability: a data module must have its global variable and no construction in code.
- Opened:
Active = Trueor anOpen/Activemention. A holder nothing opens is never PROVED (1.63): it drops to RANKED, unchecked, reason "never opened", with the warning; never a block (a dynamic open the index cannot see keeps it a candidate). Without an index (DFM only) nothing is known about opening: unchanged.
Status
| Status | Meaning | write-dfm default |
|---|---|---|
| PROVED | one best holder, DFM test and code proof pass, same form / inherited / data module in uses | checked |
| ACCEPTED | the current or stored holder is filtered or doubtful, and the field declaration carries // dl:ok lookup-source-filtered@<hash> -- REVIEWED <date>: <why> | checked |
| RANKED | a doubt, a tie of two proved holders (2 equal candidates: a, b), or an origin that needs more (uses entry, frame, code) | unchecked |
| LAYER | no usable holder; the fieldrepo.lookup.tier fallback supplies one | unchecked |
| BLOCKED | no usable holder and no fallback (the reason names fieldrepo.lookup.tier) | -- |
The current LookupDataSet and the stored LOOKUP_DATASET are the owner's choice: they win whatever else exists. A
filtered one gives a warning with the exact dl:ok line to add (hash included), never a block. DL never picks a
filtered holder nobody named. LOOKUP_DATASET = @layer skips the search; @code:<field QName> names a code-created
holder.
Limits
The proof is "against the project's indexed code": loops over Components[], RTTI and code outside the index
(packages, other executables) are not searched. A read of Filtered counts as a write (the index has no read / write
mode for a library member) -- a false warning, never a false proof. Loaders are recognised only when named in
fieldrepo.lookup.loaders.
Generated lookup sources
When no usable holder exists, the fieldrepo.lookup.tier fallback generates one in the form or data module (tier 1 a
tblLookup<T>: TFDTable, tier 2 a qryLookup<T>: TFDQuery; the setting fieldrepo.lookup.local.component (table or query) picks the
component). The generated component is read-only, unchecked in the plan, opened before the dataset that uses it, and
reused per table: a second lookup into the same table in the same form takes the component the first one created.
Lint rule lookup-source-filtered
The rule lookup-source-filtered (OFF by default, opt-in via --enable lookup-source-filtered) reports a lookup field whose chosen, current or stored dataset holder is also filtered or ranked among the candidates that repo lookup-source lists. The warning is anchored at the field declaration (or DFM line 1 when no field is declared). To accept a filtered source on purpose, put the dl:ok marker text printed by drag-lint repo lookup-source (it carries a hash) on the declaration; a marker on a field that is no longer filtered is reported by review-marker-unused. The rule needs the fieldRepository setting to open the repo, and it finds nothing when no indexed DFM resolves a DESTTABLE row.
Tiers
The project setting fieldrepo.lookup.tier in drag-lint-project.json picks what DL generates when no usable holder exists:
| Tier | Generated | Where it shows |
|---|---|---|
| not set | nothing; the report says not available: set fieldrepo.lookup.tier | tier: not set |
| 1 | a tblLookup<T>: TFDTable in the form or data module | fallback: tier 1 (TFDTable) |
| 2 | a qryLookup<T>: TFDQuery | fallback: tier 2 (TFDQuery) |
| 3 | the interface unit and the generated wiring of the ORM3 lookup layer (implementation: fieldrepo.lookup.layer.impl) | fallback: tier 3 |
In the IDE the field dialogs of the Field Repository menu (Write Field Info into Dataset...) show the tier in the line under the
hint (Lookup tier: 2 (a generated TFDQuery); unknown when the engine has no repo lookup-source) and a Lookup source
column: for a lookup field the status and the holder that repo lookup-source --form <dfm> --json chose (PROVED dmMain.qryUnits),
else the generated fallback (BLOCKED qryLookupUNITS); blank for every other field. The dialog only reports: the tier is changed
in the project file, and the Field Repository group on the General page of the drag-lint IDE options names the key.
1.63: what is proved
With a 1.63 index the code proof reads the new index facts (filter reads, SQL set in code, Open's argument count,
CreateForm order, table loaders): see repo-lookup-source-proof. The flag
--server-unit <uDLLookupCache_SERVER.PAS> adds one line per table, server: route for <T> proved | not served | not known -- <reason>,
read from the unit's DL-LOOKUP-TABLES region; it is refused with --tables.
See also
repo-write-dfm, repo-read-dfm, the spec
docs\superpowers\specs\2026-12-01-fieldrepo-lookup-source-design.md.