2 AL/BC patterns: TableRelation field length and RecordRef.Open Temp parameter - #208
Conversation
- data-modeling: tablerelation-field-length-must-match-related-field (exact length for unconditional relations, at least the longest target when all relations are conditional; no compile-time diagnostic) - testing: recordref-open-temp-parameter-defeats-real-table-checks (a temp-opened RecordRef is empty, so existence/uniqueness checks on it never see persisted rows; cross-links use-generateguid article) - Wire both into the review leaves and register the fixture pairs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- tablerelation: fields with ValidateTableRelation/TestTableRelation = false are skipped by codeunit 134926 and may be longer (filter/totaling fields); shorter is still a finding. Add Code/Text type rule, BaseApp evidence, a ValidateTableRelation = false filter field to the good fixture, and the carve-out to the data-modeling cue. - recordref: add FindLast/Next, relabel SplitLocalTableFilter as filter splitting, mark fixtures as test-library-style helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Table Relations Metadata mapping of where(...) filters to Condition Field No. is not documented and could not be verified; the rule does not depend on it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jesper Schulz-Wedde (JesperSchulz)
left a comment
There was a problem hiding this comment.
Reviewed 89411ef60a108a5ef0af37db474a4df45971c708. The relation compatibility guidance matches the cited Table Relation Test implementation, including unconditional/all-conditional length distinctions and disabled-validation/filter-field exceptions. RecordRef.Open(..., true) correctly describes the empty temporary instance and is narrowly routed to persisted-row existence/uniqueness checks, preserving metadata/view-parsing/sandbox uses and existing LibraryUtility ownership. Both pairs have reachable deterministic positive/clean coverage. Exact-head local frontmatter, knowledge index/retrieval, skill/schema, review-contract, and changed-path fixture validation pass (220 cases). No merge-critical issue found. GitHub validation workflows are awaiting approval and should run before merge.
|
Michael Dieringer (@MichaelDieringer), could you resolve the conflict? Looks good otherwise! |
Insert-only conflicts in al-data-modeling-review.md (scope line, token list, not-applicable list) and evaluation/review-fixtures.json: both sides kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Two new articles about silent mismatches that compile without a diagnostic:
data-modeling/tablerelation-field-length-must-match-related-field.md: a referencing field shorter than itsTableRelationtarget compiles cleanly. It fails at runtime ("The length of the string is N, but it must be less than or equal to M characters") once a real, longer related value is assigned or validated. The article states the exact rule from codeunit 134926 "Table Relation Test" (TableRelationTest.Codeunit.al:46, 48-49, 68-84):ValidateTableRelation = falseorTestTableRelation = falseare skipped by the check. Microsoft uses longer filter/totaling fields deliberately, e.g.WarehouseSourceFilter."Variant Code Filter"(Code[100] related to Code[10]),AnalysisViewFilter."Dimension Value Filter"andJobTask.Totaling. So "longer" is only flagged when neither flag is false. "Shorter" is always a finding.Cross-linked to
testing/table-relation-test-exclude-known-invalid-relations-via-event.mdanddata-modeling/transferfields-mirrored-fields-must-match-type-and-length.md.testing/recordref-open-temp-parameter-defeats-real-table-checks.md:RecordRef.Open(TableNo, true)refers to an empty temporary instance. AnyIsEmpty/Find*/Next/Get/Countexistence or uniqueness check on it never sees persisted rows, and a generate-until-unused loop exits on its first pass. The positional, unnamed Boolean makes the call site look harmless.Temp = trueuses are listed and excluded from the cue: a validation sandbox (ItemTempl.Table.al:1255), filter parsing/splitting viaSetView/GetFilter(QltyFilterHelpers.Codeunit.al:942,IntegrationRecordSynch.Codeunit.al:221) and metadata reads.use-generateguid-for-unique-test-fixture-values.mdfor whichLibraryUtilityhelper to call, and doesn't contradict it.LibraryUtility.Codeunit.al:288vs:309is cited as the Microsoft example.Verification
837ef8024.where(...)filter does not make a relation conditional. That was removed as unverifiable, and the rule doesn't depend on it.Wiring
al-data-modeling-review.md: scope line,Text[/ValidateTableRelation/TestTableRelationtokens, and a targeted check next to the existing TableRelation cue, including the carve-out.al-testing-review.md: scope line,RecordRef/RecRef.Open/IsEmptytokens, and a targeted check. It fires only on a literaltruefollowed by an existence/uniqueness call on the same RecordRef with noInsertin between. Non-literalTemp,SetView/GetFilter-only use, andGenerateRandomCodeitself are excluded.evaluation/review-fixtures.json.Test plan
validate_frontmatter.py: 0 errors (2 pre-existing warnings in unrelated files)Test-ReviewFixtures.ps1: 220 cases / 110 paired articlesTest-ReviewContract.ps1,Test-SkillIndex.ps1,Test-KnowledgeIndex.ps1,Test-KnowledgeRetrieval.ps1: passlicense/clacheck passes (CURABIS ApS company agreement on file)microsoft/knowledge/data-modeling/,microsoft/knowledge/testing/)🤖 Generated with Claude Code